Dynamic Telegram Bot Menu System with Multi-Level Navigation - n8n Workflow

Build a sophisticated, multi-level Telegram bot menu system using this modular n8n workflow. This n8n template uses Function nodes for configuration and routing, offering unparalleled scalability for complex chatbot logic.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • n8n automation specialists looking for advanced flow control patterns.

  • Developers needing a scalable architecture for complex Telegram bots.

  • Businesses requiring interactive, deep menu systems for customer service or product access.

  • Users who need to decouple menu navigation logic from business action execution in an n8n workflow.

Overview

Developing a robust Telegram bot often requires complex, multi-level interactive menus that can respond to both text commands and inline button clicks. Traditional methods can lead to messy, hard-to-maintain flows. This specific n8n workflow solves this by implementing a powerful separation of concerns pattern.

It centralizes the entire menu structureโ€”text, buttons, and navigation keysโ€”within a single 'Load Menu Config' n8n node, making updates extremely simple. When a user interacts, the system routes the request through an 'Action Router' to one of several dedicated 'Handler' n8n nodes. These handlers execute the specific business logic (like updating a database or fetching stats) before seamlessly returning the user to the correct menu state. This architecture ensures a highly scalable and maintainable n8n workflow, leveraging core n8n node functionality for sophisticated, stateful interactions.

How it Works

The n8n workflow initiates using the Telegram Trigger n8n node, capturing both new messages and button callback queries. The flow immediately splits into two parallel paths:


  1. Configuration Loading: The 'Load Menu Config' Function n8n node loads the entire JavaScript object defining the bot's navigation structure and messages.

  2. Command Extraction: The 'Extract Command' Function n8n node determines the user's intent, identifying the specific command or callback data, user IDs, and chat details.

These two streams merge, and the 'Process Command' n8n node checks if the requested command requires executing any external business logic (like saving a setting or fetching data). If an action is required, the flow proceeds to the 'Action Router' Switch n8n node, which routes the request to the correct 'Handler' (e.g., Rating Handler, Settings Handler). These handler n8n nodes perform the specific task and inject custom data into the workflow item.

Whether an action was performed or not, the flow converges on the 'Build Response' Function n8n node. This essential n8n node dynamically substitutes placeholders in the menu text with user data or custom data generated by the handlers. Finally, the response is formatted and sent back to Telegram via HTTP Request n8n nodes, ensuring that callback queries update the existing message rather than sending a new one, providing a smooth user experience. This robust n8n trigger system ensures quick response times.

Installation Guide


  1. Import the n8n Workflow: Copy the provided JSON data and import it into your n8n instance using the 'New' -> 'Import from JSON' option.

  2. Configure Telegram Trigger: Ensure your Telegram API credentials are set up for the initial Telegram Trigger n8n node.

  3. Set Bot Token: Locate the 'Set Bot Token' n8n node (purple color). Replace the placeholder value [!!! PALCE YOUR BOT TOKEN HERE !!!] with the actual token provided by BotFather.

  4. Customize Menu Structure: Open the 'Load Menu Config' Function n8n node and modify the MENU_CONFIG object to define your desired navigation hierarchy, texts, and callback data. The sticky notes in the n8n workflow provide detailed modification examples.

  5. Activate Webhook: Activate the n8n workflow. Copy the generated webhook URL from the Telegram Trigger settings and use BotFather to set the webhook URL for your bot, enabling the n8n trigger.

Node Details

Telegram Trigger (n8n trigger): The entry point of this n8n workflow. It initiates the automation upon receiving any Telegram message or inline button callback query.
Load Menu Config (Function n8n node): This is the core configuration n8n node. It contains the MENU_CONFIG JavaScript object, which holds all menu text, HTML formatting, and keyboard arrays, defining the entire multi-level navigation structure.
Extract Command (Function n8n node): Essential for determining the flow, this n8n node parses the incoming Telegram data to identify the specific command (callback data or text command like /start).
Merge Config & Command (Merge n8n node): Combines the menu structure data with the user input data, ensuring all necessary context is available downstream.
Needs Action? (If n8n node): A crucial flow control n8n node that directs the automation. It checks the requiresAction flag set by 'Process Command' to determine if business logic (a 'Handler') must be executed before rendering the menu.
Action Router (Switch n8n node): This dynamic n8n node routes requests based on the command type (e.g., rating, language change) to the appropriate Handler n8n node (0-6) using a complex expression.
Handler Nodes (Function n8n nodes, e.g., Rating Handler, Settings Handler): These nodes simulate business logic execution. They process the specific command, interact with external systems (in a real-world scenario), and return dynamic content via the customData object, which populates the final menu response.
Build Response (Function n8n node): Responsible for final message generation. It dynamically replaces placeholders like {status} or {userName} within the stored menu text using the data collected throughout the n8n workflow.


  • Send to Telegram (HTTP Request n8n node): The final action, sending the formatted menu and inline keyboard back to the user. It uses the editMessageText method if the trigger was a callback query, or sendMessage if it was a new message.

Related n8n Workflows

Free

Nodes: 8 Nodes
Updated: December 26 2025
View all
Created by
Ruslan Elishev
Ruslan Elishev

Professional Product Director that cought vibe of Automaion and Solo Programming and Context Aware AI Vibe coding.

Featured*