Telegram Bot: Handling Inline Button Callbacks + Reset Command Across Workflows

I’m building a Telegram bot automation in n8n to handle AI-assisted script and audio generation for content creation.

:sparkles: Goal:

The user interacts with a Telegram bot, selects from a menu using inline keyboard buttons, and depending on the option:
• Enters a message
• That message is processed by an external AI API
• The result is optionally revised based on user input
• Once finalized, it’s sent to a text-to-speech service
• The audio is passed through an automatic silence remover
• Final audio file is uploaded to cloud storage and the link is sent back to the user

:white_check_mark: How It’s Structured:

Workflow 1: Entry Point
• Trigger: Telegram Trigger (message)
• Filters for /start
• Sends a greeting message with inline keyboard (3 buttons via reply_markup)
• Waits 2 seconds before sending the button prompt for UX smoothness

Workflow 2: Callback Query Handler
• Trigger: Telegram Trigger (callback query)
• Switch node routes the button pressed to the appropriate path (e.g. Option 1 starts the creation flow)
• Asks user to submit a message
• Sends it to Claude (Anthropic API) or other external AI
• Returns result, asks if they want changes or type done
• Loop based on user input until final version is confirmed
• Sends script to ElevenLabs
• Audio result passed to a silence-removal script
• Cleaned audio is uploaded to Google Drive (or cloud of choice)
• Final link is sent back to Telegram

:warning: Issues I’m Running Into:

  1. Multiple Workflows: Shared Context

Since I’m using two workflows (one triggered by message, the other by callback query), I’m struggling to:
• Pass the chat ID or session info from the first workflow into the second
• Maintain a smooth conversational flow across workflows

Is there a way to:
• Use one trigger node to handle both message and callback queries in the same workflow?
• Or pass chat context from one workflow to another cleanly?

  1. Restarting the Workflow

If the user sends /start again halfway through a flow, it doesn’t trigger the first workflow again.
I need to let users reset the flow at any time by typing /start again. Currently, this seems to be ignored once a workflow has already run for that user.

Any ideas on:
• Forcing /start to always restart the main workflow from the top?
• Or managing user sessions in a way that supports re-entry?

Bonus Steps:
• Audio is processed by a Python-based silence remover script (can run via Execute Command or external service)
• Final file naming and delivery is dynamic (e.g., title (channel).mp3)

Would really appreciate help figuring out how to:
• Consolidate this into one workflow if possible
• Or manage flow context + triggers cleanly across workflows
• And support /start as a true “reset” command at any point

Thanks in advance!

Hi,

Can you please share your workflow in a code section?

I think the only way this could work is to use a shared state between all of this. How is state currently handled. this state/context should be maintained/checked before going into the AI.

I could think of something like:

  1. if between workflow, if you have saved state in an external system with a large enough window the AI would be able to use it between workflows.

  2. if you want to handle /start for an existing session i guess you can check the session id or whatever you use from the memory and clear everything (from the db directly). this will empty any sub-sequent request from any workflow to have lost it’s “memory”

reg,
J.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.