Build an advanced, stateful Telegram bot using this n8n workflow template. Learn how to manage conversation state across multiple users and commands using n8n nodes and static data.
Download this n8n workflow template and start using it instantly.
This expert-level n8n workflow provides the critical infrastructure for a sophisticated, conversational Telegram bot. Unlike simple request/response bots, this n8n automation template leverages static data storage via custom n8n node configuration to track the user's specific conversation state. This state management is essential for multi-step interactions, ensuring that when a user inputs follow-up data (after triggering a command like /start_survey), the n8n workflow knows exactly which process to route the data to. By maintaining state unique to each chat ID, this flow ensures scalability and reliable interaction, making it one of the most powerful n8n templates for building complex chat interfaces.
The entire process is initiated by the Telegram Trigger n8n node, which listens for incoming messages.
Send Typing action for a better user experience. The flow then passes the data to the Command Check n8n node (If node) to determine if the message is a new command (e.g., /command1).Switch (Command Routing) n8n node directs the execution based on the specific command text. A subsequent Code n8n node (e.g., Set waitingForContent1) then sets a conversation state flag in the workflow's global static data, linked to the user’s Chat ID. A Telegram n8n node immediately follows, requesting the user's necessary content.Command Check n8n node determines the input is not a command, the flow retrieves the existing state using the Prepare IF Value n8n node (which accesses the static data).Check State n8n node routes the follow-up message to the appropriate processing branch (Command1 processing, Command2 processing, etc., which are currently placeholders but where custom logic would reside).Clear State Code n8n node, which removes the state flag for that Chat ID, preparing the n8n workflow for the user's next command.To use this powerful n8n workflow template, follow these steps:
Telegram Trigger n8n node and all subsequent Telegram nodes.Telegram Trigger n8n node and save the configuration. If running n8n self-hosted, ensure your webhook URL is accessible.Temp to Initiate Static Data Code n8n node once. As the sticky note explains, this initializes the telegramStates object required for storing conversation state.NoOp nodes (Command1 processing, etc.) with your specific business logic (e.g., Google Sheets ops, database lookups, or AI calls). Telegram Trigger n8n node: The entry point for the n8n workflow. It listens for all incoming messages from your configured Telegram bot.
Command Check (If n8n node): Determines if the incoming message starts with a recognized command structure (e.g., /command). This is vital for differentiating initial requests from subsequent content inputs.
Switch (Command Routing) n8n node: Routes the flow based on the exact command received, initiating the correct state-setting sequence.
Set waitingForContentX (Code n8n node): These nodes are essential for state management. They use JavaScript to write the current waiting state (e.g., 'waitingForContent1') specific to the Chat ID into the global static data of the n8n workflow.
Prepare IF Value (Code n8n node): Reads the current state from the static data for a non-command message. This allows the subsequent logic to decide where the user is in the conversation flow.
Check State (Switch n8n node): This node uses the value retrieved by 'Prepare IF Value' to route the user's content to the relevant processing branch.
Find the best local restaurants instantly via Telegram. This n8n workflow uses a Telegram n8n trigger and SerpAPI to search Google Maps data, sort results by rating, and format a beautiful response.

Deploy an advanced Telegram bot using this n8n workflow template. Implement dynamic inline keyboards, multi-level navigation, and a 5-star feature rating system using custom n8n nodes and HTTP requests.

Automate appointment scheduling, cancellation, and lookup via Telegram using Google Calendar and Sheets. This powerful n8n workflow template handles parsing, validation, and database updates.

Deploy a persistent, context-aware AI chatbot using this advanced n8n workflow. Integrate Telegram and Supabase memory with the OpenAI Assistant API. Find robust n8n templates for context-aware bots.

Use this powerful n8n workflow to create a smart Telegram bot that routes messages: images for GPT-4o-Mini/NVIDIA Vila analysis, or text for Stable Diffusion 3 image generation.

Use this powerful n8n workflow to create a Telegram bot that extracts TikTok and LinkedIn profile data using Dumpling AI, transcribes voice messages, and automatically stores results in Google Sheets. Get started with n8n templates for data mining.


I specialize in building custom integrations for businesses, focusing on appointment systems, CRM-integrated chatbots, and data collection workflows. I streamline processes by connecting tools like calendars, CRMs, and messaging platforms (including WhatsApp and Voiceflow) to automate data gathering and user triage.







































