n8n Telegram Bot Tutorial: Build a Bot Step by Step
Create a Telegram bot with BotFather, connect it to n8n, receive messages, and send an automatic reply. Then expand it with commands, notifications, AI responses, or a business workflow.
- BotFather token and n8n setup
- Working reply and chat ID
- AI, notification, and Sheets ideas
What is an n8n Telegram bot?
A Telegram bot connected to n8n workflows.
An n8n Telegram bot can receive messages, process information, perform workflow actions, and send a response through Telegram. Instead of building an entire bot application from scratch, you connect Telegram and other services using n8n nodes.
A bot can send notifications, answer commands, collect information, connect to Google Sheets or a CRM, or use an AI model to prepare replies. Start with a basic text reply, then add capabilities after the connection works.
For workflow fundamentals, see our n8n workflow automation guide or the n8n beginner tutorial.
What can you automate with a Telegram bot?
Choose a clear purpose before adding more nodes.
Basic chatbot
Respond to incoming text with a simple predefined answer.
AI Telegram bot
Use a model to interpret a question and draft a response.
Notification bot
Send alerts for website, workflow, or business events.
Lead collection bot
Ask for details, validate them, and save a lead for follow-up.
Spreadsheet bot
Look up or update information in Google Sheets.
File processing bot
Receive supported files and route them into a processing workflow.
What you need before creating a Telegram bot
- A Telegram account and access to the official BotFather.
- An n8n Cloud account or a self-hosted n8n instance.
- A bot token from BotFather.
- A publicly reachable HTTPS address for webhook-based incoming updates.
- A private test chat for trying the first workflow.
If you run n8n yourself, confirm its public URL and HTTPS setup are working. Our self-hosted n8n tutorial covers deployment considerations.
Create a Telegram bot with BotFather
BotFather creates and manages Telegram bots.
- 1
Open the official BotFather
In Telegram, find
@BotFatherand confirm you have the official account. - 2
Start a new bot
Start the conversation and send
/newbot. - 3
Choose a display name and username
Follow BotFather’s prompts. The username must follow Telegram’s current rules and end in “bot”.
- 4
Store the bot token privately
BotFather returns a token that authenticates the bot. Keep it secret; anyone with the token may control the bot.
Add Telegram credentials in n8n
- Create or open an n8n workflow.
- Add a Telegram Trigger node.
- Create a Telegram credential from the node’s credential selector.
- Paste the BotFather token into the credential field and save it securely.
- Select the credential in the trigger node and choose the update types your workflow needs.
Use n8n’s credential storage. Never put the token in public workflow JSON, screenshots, or source code.
Configure and test Telegram Trigger
- Choose your Telegram credential.
- Review available update types and select message updates for a basic bot.
- Use the node’s test or execute option.
- Open your bot chat, press Start or send
/start, then sendHello. - Return to n8n and inspect the trigger output.
A webhook-based trigger needs Telegram to reach the n8n instance over a publicly accessible HTTPS endpoint. A private local address cannot receive Telegram’s webhook requests.
Understand Telegram message data
The exact update shape depends on the event and message type.
| Field | Purpose |
|---|---|
message.text |
Text sent by the user in a normal message. |
message.chat.id |
Identifies the chat where the reply should go. |
message.message_id |
Identifies the message within the chat. |
| User and update data | Additional information that depends on the event. |
The chat ID is important: use the ID from the incoming message to reply to the same conversation. Inspect your own trigger output because media, commands, and other updates may have a different structure.
Build a basic Telegram auto-reply
Connect the trigger to a Telegram Send Message operation.
- 1
Add a Telegram node
After the trigger, add the Telegram node and choose the operation to send a message.
- 2
Set the Chat ID
Use the expression
{{ $json.message.chat.id }}for a standard incoming message, after confirming the path in your trigger output. - 3
Write a test message
For example: “Hello! Thanks for messaging my Telegram bot.”
- 4
Run the workflow and check Telegram
Send a test message from your private chat and confirm the reply returns to that chat.
- 5
Activate after testing
Check the complete execution before enabling the workflow for ongoing use.
Add /start, /help, and /about commands
Route command text to different responses using a Switch or IF node.
| Command | Example response |
|---|---|
/start |
Welcome message and brief instructions. |
/help |
List commands or explain what the bot can do. |
/about |
Explain the purpose of the bot. |
| Other text | Default response, AI answer, or human handoff. |
Workflow pattern: Telegram Trigger → Switch on message text → response branch → Telegram Send Message. Test each branch with the exact command and a normal message.
Example /start reply:
Welcome to my automation bot!
Use /help to see commands.
Use /about to learn what this bot does.
Build an AI-powered Telegram chatbot
Connect an AI model only after the basic Telegram reply works.
- Use Edit Fields to extract the user message into
user_messagewith{{ $json.message.text }}. - Extract the chat ID into
chat_idwith{{ $json.message.chat.id }}, checking your trigger output. - Connect an AI Agent or supported AI processing node and model.
- Send
user_messageto the AI input. - Map the model’s actual response field and
chat_idto Telegram Send Message. - Test the end-to-end workflow and inspect every node’s data.
Example system instruction: “You are a helpful Telegram assistant. Answer clearly and politely. Keep responses concise. If you do not know an answer, say so. Do not request passwords or sensitive account details.”
Model response fields vary. Inspect the actual AI node output instead of assuming a fixed field name. Learn more in our n8n AI chatbot tutorial, AI agent tutorial, and n8n AI automation guide.
Add conversation memory carefully
Without memory, an AI chatbot may handle each incoming message independently. A memory component can provide previous conversation context when it is configured with a stable session key.
For a Telegram bot, the chat ID can be used as a conversation identifier, for example {{ $json.chat_id }}, after confirming that the field is passed correctly.
- Keep conversations separated by chat or user as appropriate.
- Set sensible limits on how much history is retained.
- Avoid storing unnecessary personal information.
- Protect stored conversation data and define deletion handling.
- Test simultaneous conversations from different chats.
Create Telegram notification workflows
Telegram can also be a notification destination. A form, webhook, schedule, or other application event can start a workflow that sends a message to an authorized chat.
- New website enquiries or registrations.
- Order or payment status updates.
- Server and website monitoring alerts.
- Workflow failure notifications.
- Scheduled daily or weekly reports.
Send only information the recipient is authorized to see. For related use cases, browse n8n automation examples.
Five useful n8n Telegram bot workflows
Extend the basic bot with a single clear capability at a time.
AI customer support
Telegram message → retrieve approved help content → AI draft → human handoff or reply.
Lead generation
Ask for details → validate fields → save to a spreadsheet or CRM → confirm.
Website monitoring
Schedule a check → test availability → alert a Telegram chat if the site is down.
Google Sheets lookup
Telegram command → parse request → retrieve spreadsheet data → reply with result.
Daily report bot
Schedule → collect business data → format a summary → send a Telegram report.
Telegram features available in n8n
Supported operations depend on the node version and Telegram capabilities.
See the current n8n Telegram node documentation for the complete operation list.
Common Telegram bot problems and fixes
Trigger receives no messages
Check public HTTPS reachability, workflow listening or active status, credential token, update type, and execution history.
Bot does not reply
Confirm the trigger ran, Send Message is connected, message text is present, and the chat ID is correct.
Invalid bot token
Verify the BotFather token. If you regenerate it, update the n8n credential and test again.
Chat ID is missing
Inspect the trigger output and confirm the expression matches the received update shape.
Webhook conflict
Check whether another active workflow or app uses the same bot token and webhook.
AI response is empty
Inspect the AI output and map the actual generated-text field into the Telegram message.
Bot replies more than once
Review duplicate executions, multiple active listeners, and routing logic.
Security and reliability checklist
- Protect the bot token and store it in n8n credentials.
- Use HTTPS for webhook-based incoming updates.
- Test commands, text, and any supported media types.
- Check message data before assuming every update is plain text.
- Use the correct chat ID and avoid exposing private messages.
- Plan error handling, retries, duplicate prevention, and monitoring.
- Limit AI scope and review important generated responses.
- For production use, plan access controls, data retention, backups, and recovery.
Test with a private bot first. Add your own screenshots only after testing, and hide tokens, chat IDs, and personal data.
Can n8n run a production Telegram bot?
n8n can support useful Telegram workflows, but production suitability depends on hosting resources, message volume, workflow design, external service limits, and reliability requirements.
Plan for error handling, monitoring, persistent storage where needed, access control, privacy, and recovery. Start small and test the behavior before using a bot for important customer communication.
Frequently asked questions
Can I create a Telegram bot with n8n without coding?
Many bots can be built with n8n’s visual editor and Telegram nodes. Advanced workflows may need expressions, custom logic, or API requests.
Is n8n Telegram integration free?
Costs depend on n8n hosting and any additional connected services. Check current plans and terms.
How do I connect Telegram to n8n?
Create a bot with BotFather, add a Telegram Trigger, configure its credential using the bot token, then test by messaging the bot.
Does n8n need a public URL for Telegram?
For webhook-based incoming updates, Telegram needs to reach n8n through a publicly accessible HTTPS endpoint.
Can I build an AI Telegram chatbot?
Yes. Connect the incoming message to a supported AI node or agent, then map the generated response back to Telegram Send Message.
Can a Telegram bot receive files and images?
Telegram supports different message and media types. Configure the workflow for the relevant update and file operations supported by your node version.
Can I connect Telegram to Google Sheets?
Yes. A workflow can save submitted information, look up records, or update spreadsheet data when configured with appropriate access.
Can multiple people use one Telegram bot?
Yes. Keep each conversation’s data separate and use the chat ID from the incoming update when replying.
How can my AI bot remember previous messages?
Use a suitable memory or storage component with a session identifier per chat. Set retention limits and protect stored conversation data.
Continue learning
Explore our n8n AI agent tutorial, AI chatbot tutorial, and n8n AI automation guide. Connect a bot to Sheets with the Google Sheets integration guide, or browse practical automation examples.
For wider workflow concepts, read n8n workflow automation. n8n Automation AI is an independent learning resource and is not affiliated with, endorsed by, or officially connected to n8n GmbH.
Official resources
Check current node operations and bot requirements.
- n8n Telegram node documentation
- n8n Telegram integration directory
- Telegram BotFather and bot features
- Telegram Bot API
- n8n workflow library
Telegram and n8n interfaces and operations may change. Follow current official docs and test with a private bot before connecting business systems.
Start with one working reply
Create the bot, test the trigger, and send a reply before adding more features.
