Why Build a Telegram Bot?
Telegram bots are one of the most versatile tools in the messaging world. Unlike WhatsApp or iMessage, Telegram was designed from the ground up with bot support baked into its core platform. There are over 900 million active Telegram users worldwide, and bots handle everything from customer support and order tracking to news delivery and smart home control.
The traditional approach to building a Telegram bot involves writing Python or Node.js code, setting up a server, managing webhooks, handling updates, and parsing JSON payloads. For developers, that is a familiar workflow. But what if you are a marketer, small business owner, community manager, or someone who simply wants to automate tasks without learning to code?
That is where n8n changes the game. n8n is an open-source workflow automation platform with a native Telegram integration that lets you build fully functional bots using a visual drag-and-drop interface. You connect nodes on a canvas, configure settings through simple forms, and your bot is live in minutes, not days.
In this tutorial, you will build a complete Telegram bot from scratch. Your bot will respond to commands, fetch live weather data, perform web searches, and reply with formatted messages. By the end, you will also have three advanced bot ideas you can build next. No coding required at any step.
Prerequisites
Before we start building, make sure you have these ready:
- An n8n account — sign up for a free n8n Cloud account, or run n8n locally with Docker (
docker run -it --rm -p 5678:5678 n8nio/n8n) - A Telegram account — any personal Telegram account on mobile or desktop
- BotFather access — search for
@BotFatherin Telegram (it is the official bot for creating bots) - About 15–20 minutes — enough time to set up everything and test your first bot
Optional but recommended: a basic understanding of what APIs are (you do not need to write API code, just understand that bots talk to services through them).
Step 1: Create Your Bot with BotFather
Every Telegram bot starts with BotFather. It is Telegram's official tool for registering new bots and managing existing ones. Think of it as the admin panel for all Telegram bots.
Open BotFather
Open Telegram on your phone or desktop. In the search bar, type @BotFather and select the verified account (it has a blue checkmark). Tap Start to begin the conversation.
Create a new bot
Send the command /newbot. BotFather will ask you two things:
- Display name: This is what users see in the chat header. Choose something descriptive, like "My Assistant Bot" or "WeatherHelper"
- Username: This must be unique across all of Telegram and must end with
bot. For example:my_assistant_2026_botorweatherhelper_bot
Save your API token
After creating the bot, BotFather replies with an HTTP API token that looks like this:
123456789:ABCdefGhIjKlMnOpQrStUvWxYz-1234567
Copy this token immediately and store it somewhere safe. You will need it in the next step to connect n8n to your bot. Never share this token publicly, as anyone with it can control your bot.
Optionally, you can also send /setdescription and /setabouttext to BotFather to customize your bot's profile. You can also upload a profile photo with /setuserpic.
Step 2: Set Up the n8n Telegram Trigger Node
Now that your bot exists on Telegram, you need to connect it to n8n so that incoming messages are captured and processed.
Create a new workflow
Log into your n8n instance (Cloud or self-hosted). Click "New Workflow" and name it something like "Telegram Bot".
Add the Telegram Trigger node
Click the "+" button on the canvas or press Tab. Search for "Telegram Trigger" and add it. This node listens for incoming messages, commands, and callbacks sent to your bot.
Configure Telegram credentials
In the Telegram Trigger node settings, click "Create New Credential". Paste the API token you received from BotFather into the "Access Token" field. Click "Save". n8n will automatically set up a webhook with Telegram so that messages are delivered to your workflow in real time.
Set trigger updates
Under "Updates", select the types of messages your bot should listen for. At minimum, check "message". You can also enable "callback_query" if you plan to use inline keyboards later.
Important note for self-hosted n8n: The Telegram Trigger uses webhooks, which means Telegram needs to reach your n8n instance over the internet. If you are running n8n locally, you will need a tool like ngrok or Cloudflare Tunnel to expose your instance. On n8n Cloud, webhooks work out of the box.
Step 3: Add Message Routing with the Switch Node
Your bot will receive all kinds of messages: commands like /start, /help, and /weather, as well as regular text. You need to route each type to the correct handler. The Switch node in n8n is perfect for this.
- Click the "+" on the Telegram Trigger node's output and add a Switch node
- Set the "Value" field to the incoming message text:
{{ $json.message.text }} - Add routing rules for each command:
- Rule 1: Value equals
/start→ Output 0 - Rule 2: Value equals
/help→ Output 1 - Rule 3: Value starts with
/weather→ Output 2 - Rule 4: Value starts with
/search→ Output 3 - Fallback: Everything else → Output 4 (default/unknown command)
- Rule 1: Value equals
The Switch node creates separate output branches for each rule. You will connect a different response chain to each output. This architecture keeps your workflow organized and makes it easy to add new commands later; just add a new rule and connect a new branch.
Step 4: Build /start and /help Responses
Every good bot needs a welcome message and a help command. These are the first things users interact with.
The /start command
Connect a Telegram node (the action node, not the trigger) to Output 0 of your Switch node:
- Add a Telegram node and select "Send Message" as the operation
- Set "Chat ID" to
{{ $json.message.chat.id }}(this sends the reply to the correct user) - Set "Text" to your welcome message:
Welcome to MyAssistantBot!
I can help you with:
/weather [city] - Get current weather
/search [query] - Search the web
/help - Show all commands
Try sending /weather Paris to get started.
Set "Parse Mode" to Markdown if you want to use bold, italic, or other formatting.
The /help command
Connect another Telegram node to Output 1 with a similar setup. The help message should list all available commands with brief descriptions:
Available Commands:
/start - Welcome message
/weather [city] - Current weather for any city
/search [query] - Search the web
/help - This help message
Examples:
/weather London
/search best automation tools 2026
These two commands establish the basic interaction pattern. Users know what your bot can do and how to use it. The chat.id expression ensures replies go back to the user who sent the message, even if multiple people are using the bot simultaneously.
Step 5: Add a Weather Command (HTTP Request to wttr.in)
Now for the fun part: making your bot actually do something useful. The /weather command will fetch real-time weather data from wttr.in, a free weather API that requires no API key.
Extract the city name
Connect a Set node (or Code node) to Output 2 of the Switch. Use an expression to extract the city from the command. The user sends /weather Paris, and you need just Paris:
{{ $json.message.text.replace('/weather ', '').trim() }}
Fetch weather data
Add an HTTP Request node after the Set node. Configure it:
- Method: GET
- URL:
https://wttr.in/{{ $json.city }}?format=3
The ?format=3 parameter returns a compact one-line weather summary like Paris: +12°C Partly cloudy.
Send the weather response
Add a Telegram node after the HTTP Request. Set the text to the API response:
Current Weather:
{{ $json.data }}
Powered by wttr.in
For a richer experience, you can use ?format=j1 instead to get JSON data, then extract specific fields like temperature, humidity, wind speed, and UV index to build a beautifully formatted multi-line response. You can even add emoji based on the weather condition (sunny, cloudy, rainy) using IF nodes.
Step 6: Add a Web Search Command
A search command turns your Telegram bot into a mini search engine. You can use any search API for this; here we will use the free DuckDuckGo Instant Answer API.
Extract the search query
Connect a Set node to Output 3 of the Switch node. Extract the query:
{{ $json.message.text.replace('/search ', '').trim() }}
Call the search API
Add an HTTP Request node with:
- Method: GET
- URL:
https://api.duckduckgo.com/?q={{ encodeURIComponent($json.query) }}&format=json&no_html=1
Format and send results
Add a Telegram node. Parse the API response to extract the AbstractText and AbstractURL fields. Send a formatted message with the summary and a link to full results.
If DuckDuckGo does not return a result for a query (it only answers factual queries), add an IF node to check whether the response is empty. If it is, send a fallback message like "No instant answer found. Try a more specific query." This kind of error handling makes your bot feel polished and professional.
Step 7: Deploy and Test Your Bot
Your workflow is complete. Time to make it live and verify everything works.
Test manually first
Click "Execute Workflow" in n8n, then go to Telegram and send /start to your bot. Switch back to n8n and check if the Telegram Trigger node received the message. Inspect the data flowing through each node.
Test every command
Send each command to your bot and verify the responses:
/start— should show the welcome message/help— should list all available commands/weather Tokyo— should return current weather/search artificial intelligence— should return search results- Random text — should trigger the fallback/default response
Activate the workflow
Once everything checks out, toggle the "Active" switch in the top right corner of n8n. Your bot is now running 24/7. On n8n Cloud, it stays active even when you close the browser. For self-hosted, make sure your Docker container or server stays running.
Monitor your bot's activity from the "Executions" tab in n8n. This shows a log of every message received and every action taken. If any errors occur, you will see the exact node that failed and the error message, making debugging straightforward.
3 Advanced Bot Ideas to Build Next
Once you have mastered the basics, here are three powerful bots you can build with the same no-code approach.
1. Expense Tracker Bot (Telegram to Google Sheets)
Build a personal finance bot that logs expenses directly to a Google Sheets spreadsheet. The user sends a message like Coffee 4.50 or /expense Lunch 12.00, and the bot automatically parses the description and amount, adds a timestamp, and appends a new row to your spreadsheet.
Workflow structure:
Telegram Trigger
→ Set Node (parse description + amount from message)
→ Google Sheets: Append Row
- Column A: Date/Time
- Column B: Description
- Column C: Amount
- Column D: Category (optional, use IF node)
→ Telegram: Send confirmation
"Logged: Coffee $4.50 on March 12, 2026"
You can extend this with a /report command that reads the last 30 days of expenses from the sheet and sends a formatted summary. Add category detection using keyword matching: "coffee" and "lunch" go to "Food", "uber" goes to "Transport", and so on.
2. Daily News Digest Bot (RSS to Telegram)
Create a bot that delivers a curated news digest to your Telegram chat every morning at 8 AM. Instead of checking multiple news sites, your bot aggregates headlines from RSS feeds and sends them in a single formatted message.
Workflow structure:
Schedule Trigger (every day at 8:00 AM)
→ RSS Feed Read (TechCrunch feed URL)
→ RSS Feed Read (Hacker News feed URL)
→ Merge Node (combine all items)
→ Limit Node (top 10 articles)
→ Code Node (format as numbered list)
→ Telegram: Send Message to your chat ID
"Good morning! Here are today's top stories:
1. [Title] - Source
2. [Title] - Source
..."
Since this uses a Schedule Trigger instead of a Telegram Trigger, it runs automatically without user input. You can add multiple RSS feeds for different topics and use the Merge node to combine them all.
3. Task Manager Bot (Telegram to Notion)
Turn your Telegram into a quick-capture tool for your Notion task database. Send a message like /task Write blog post about n8n and the bot creates a new page in your Notion Tasks database with the title, timestamp, and a default "To Do" status.
Workflow structure:
Telegram Trigger (filter: starts with /task)
→ Set Node (extract task title from message)
→ Notion: Create Database Page
- Title: {{ $json.taskTitle }}
- Status: "To Do"
- Created: {{ $now }}
- Source: "Telegram"
→ Telegram: Send confirmation
"Task created: Write blog post about n8n"
Extend it further with /tasks to list your open tasks, /done [task number] to mark tasks complete, and /priority [task] high to set priority levels. Each command gets its own branch in the Switch node.
Troubleshooting Common Issues
Webhook Not Registering
Problem: Your bot does not respond to any messages even though the workflow is active.
Solution: Telegram webhooks require HTTPS. If you are self-hosting n8n, make sure it is behind a reverse proxy with a valid SSL certificate. On n8n Cloud, this is handled automatically. You can also verify the webhook status by visiting https://api.telegram.org/bot<YOUR_TOKEN>/getWebhookInfo in your browser. If the url field is empty, the webhook was not set. Try deactivating and reactivating the workflow in n8n.
Bot Not Responding to Commands
Problem: The bot receives messages (you can see executions in n8n) but does not send replies.
Solution: Check the Chat ID expression in your Telegram response nodes. It must be {{ $json.message.chat.id }}. A common mistake is using $json.chat.id without the message level. Also verify that your Switch node conditions match exactly: /start with a lowercase s, no trailing spaces.
Rate Limiting from Telegram
Problem: Your bot starts returning "429 Too Many Requests" errors.
Solution: Telegram limits bots to approximately 30 messages per second to different chats and 1 message per second to the same chat. If your bot is in a group with many users, add a Wait node (1 second delay) between consecutive Telegram send nodes. For high-traffic bots, batch messages together instead of sending multiple short messages.
Weather or Search API Returns Errors
Problem: The HTTP Request node fails with connection errors or empty responses.
Solution: Add error handling to your workflow. Enable "Continue On Fail" on the HTTP Request node, then add an IF node after it to check whether the response contains data. If the API failed, send a friendly error message to the user instead of crashing the workflow silently. Also check that the city name or search query does not contain special characters that break the URL.
Build Your First Bot Today
With n8n, you can create powerful Telegram bots in minutes without writing a single line of code. Start with the free plan and scale as you grow.
Try n8n Free Compare n8n vs ZapierFrequently Asked Questions
Can I build a Telegram bot without coding?
Yes, absolutely. With n8n's visual workflow builder, you can create fully functional Telegram bots by connecting nodes in a drag-and-drop interface. No programming languages are required. You configure triggers, logic, and responses through simple forms and menus.
Is n8n free for building Telegram bots?
n8n offers a free self-hosted option using Docker where you can run unlimited workflows including Telegram bots. The n8n Cloud free tier includes a limited number of executions per month. For most personal Telegram bots, the free self-hosted version handles the load without any issues.
How do I get a Telegram Bot API token?
Open Telegram and search for @BotFather. Send the /newbot command, choose a display name and a unique username ending in "bot". BotFather will immediately reply with your HTTP API token. Copy this token and paste it into n8n's Telegram credential settings.
Related Articles
How to Automate Gmail with n8n
Step-by-step guide to automating Gmail with triggers, filters, and auto-replies using n8n.
n8n vs Zapier: The Complete Comparison
See how n8n stacks up against Zapier on features, pricing, and flexibility.
Automate Google Sheets with Make.com
Learn how to automate spreadsheet workflows with Make.com, step by step.