Hosto

Sign In

Build a Telegram Bot with n8n: From Zero to Useful in an Afternoon

By Tushar Khatri

Person tapping the screen of a white smartphone with one finger

Building a Telegram bot used to mean writing code, wiring up a server, and babysitting a long-running process. With an n8n Telegram bot, you skip all of that. Telegram gives you a free, generous Bot API, and n8n gives you a visual editor with a ready-made Telegram Trigger node and Telegram node. Connect the two and you have a bot that can send alerts, answer commands, and even reply with AI-generated answers, all without writing a single line of code. This guide walks you through the entire process: creating the bot, connecting it to n8n, and building three progressively smarter bots you can actually use.

Why Telegram Plus n8n Is the Fastest Path to a Bot Without Code

Telegram is unusually developer-friendly among chat platforms. The Bot API is free, there is no app review process, and creating a bot takes about ninety seconds inside the Telegram app itself.

n8n complements this perfectly. It ships with two nodes that cover the whole conversation loop:

  • The Telegram Trigger node starts a workflow whenever your bot receives a message.
  • The Telegram node sends things back: text messages, photos, and documents.

That pairing means a complete request-and-response bot is a two-node workflow. Everything in between, such as looking up data, calling an API, or asking an AI model for an answer, is just more nodes dropped into the middle. If you have ever wanted a Telegram bot without code, this is the shortest route there.

One practical note before you start: Telegram delivers messages to n8n through webhooks, and webhooks require a public HTTPS URL. If you run n8n on your laptop, Telegram cannot reach localhost, so you will need a tunnel for development and a proper server for production. We will cover both at the end.

Step 1: Create Your Bot with BotFather

Every Telegram bot is born the same way: through @BotFather, Telegram's official bot for creating bots.

  1. Open Telegram and search for @BotFather. Make sure it is the verified account.
  2. Start a chat and send the command /newbot.
  3. BotFather asks for a display name. This is what people see in chats, so something like "Acme Alerts" works fine.
  4. Next, it asks for a username. This must be unique across Telegram and must end in bot, for example acme_alerts_bot.
  5. BotFather replies with your API token, a long string that looks something like 7213984:AAH-example-token-string.

That token is the key to your bot. Anyone who has it can send messages as your bot, so treat it like a password. Copy it somewhere safe, because it is the only thing n8n needs in the next step.

Step 2: Connect the Bot to n8n with a Credential

Back in n8n, add a Telegram Trigger node to a new workflow. The first thing it asks for is a credential.

  1. In the credential field, choose to create a new Telegram credential.
  2. Paste the API token you got from BotFather.
  3. Save.

That is the entire integration. n8n uses this token both to receive updates through the trigger and to send messages through the Telegram node, so one credential covers everything.

Before you test, send your bot a /start message from your own Telegram account. Bots cannot initiate conversations with users who have never messaged them, so this first message opens the channel. It also lets you grab your chat ID, which you will need whenever the bot should message you proactively. The easiest way to find it is to execute the Telegram Trigger node once, send the bot a message, and read the chat ID out of the incoming data.

Now let's build three bots, each one a step up from the last.

Bot 1: The Notify Bot That Pings Your Phone

The simplest useful bot does not even need a trigger from Telegram. It is a one-way alert channel: any workflow you already run in n8n can end with a Telegram node that messages you.

The setup:

  1. Take any existing workflow, for example one that checks a website, processes new orders, or watches an RSS feed.
  2. Add a Telegram node at the point where something noteworthy happens.
  3. Set the operation to send a message, use your Telegram credential, and paste your chat ID as the recipient.
  4. Write the message, pulling in data from earlier nodes with expressions, such as the order total or the error text.

That is it. Every time the workflow runs and hits that node, your phone buzzes. This pattern replaces slow email alerts and paid notification services. Server down, new signup, failed payment, big sale: whatever your workflows can detect, this bot can tell you about in seconds.

Because the Telegram node can also send photos and documents, you can attach a report file or chart image instead of plain text. A nightly workflow that sends you a PDF summary as a Telegram document is a fifteen-minute build.

Bot 2: The Command Bot That Answers "status"

The second bot is interactive. You send it a word, it does a lookup, and it replies with the answer. The classic example is a status command.

The workflow shape:

  1. Telegram Trigger node: fires whenever someone messages the bot. The incoming data includes the message text and the chat ID of the sender.
  2. IF node: checks whether the message text equals status (or starts with /status if you prefer command syntax). Messages that do not match can simply end the workflow or route to a fallback reply.
  3. HTTP Request node: calls whatever you want to check. This could be your own API's health endpoint, an uptime service, or an internal dashboard endpoint that returns JSON.
  4. Telegram node: sends the result back. Use an expression to set the chat ID from the trigger data, so the reply goes to whoever asked, and build the message text from the HTTP response.

Now you can be anywhere, type "status" into Telegram, and get a live answer from your infrastructure. Extend the same skeleton with more branches: "sales" pulls today's revenue, "queue" reports how many jobs are pending, "deploy" reports the last release. Each command is just another IF branch with its own lookup and reply.

The key habit here is always passing the chat ID from the trigger into the reply node, so the bot works for everyone who messages it, not just you.

Bot 3: The AI Answer Bot

The third bot turns Telegram into a chat interface for an AI model. The structure is remarkably small:

  1. Telegram Trigger node: receives the user's question.
  2. AI Agent or OpenAI node: takes the incoming message text as the prompt. Give it a system prompt that defines the bot's job, for example "You are a support assistant for our product; answer briefly and accurately."
  3. Telegram node: sends the model's answer back to the chat ID from the trigger.

That is a working AI assistant living in your pocket. Ask it to summarize pasted text, translate a message, draft a reply, or answer questions from its domain. Because the middle of the workflow is ordinary n8n, you can go further: add nodes that fetch context from your database or docs before the AI step, so answers are grounded in your real data.

A word of caution: an AI bot answers anyone who messages it, and AI calls usually cost money per request. Add an IF node right after the trigger that checks the sender's chat ID against a list of allowed users, and drop everything else. Two minutes of work, and strangers cannot run up your API bill.

For more workflow patterns to bolt onto these bots, browse these 12 n8n workflow examples.

Deploying Your Bot for Real

A bot on your laptop stops working the moment the lid closes. Here is what production actually requires.

Activate the workflow. While you build, the trigger only listens during test executions. Toggle the workflow to active so n8n registers the production webhook with Telegram and listens continuously.

Use a public HTTPS URL. Telegram delivers messages by calling a webhook, and it will only call a public HTTPS address. n8n derives that address from its WEBHOOK_URL setting, so it must point to a real domain with a valid certificate. On localhost, this is exactly why your trigger never fires: Telegram cannot reach your machine. A tunnel gets you through development, but it is not a production answer. If messages still do not arrive after activating, work through this n8n webhook troubleshooting guide, because the cause is almost always the webhook URL.

Run n8n on an always-on server. Bots are 24/7 creatures. People message them at midnight, alerts fire on weekends, and a bot that answers only when your laptop is awake is worse than no bot, because people learn not to trust it. The clean solution is a small dedicated server that runs n8n around the clock. Hosto n8n hosting gives you exactly that: a dedicated VM with unlimited executions from $9/mo billed annually, so your bot never sleeps and you never count workflow runs.

With hosting sorted, the whole project genuinely fits in an afternoon: BotFather, one credential, three workflows, one activation toggle.

FAQ

Do I need to know how to program to build an n8n Telegram bot?

No. The bot itself is created by chatting with @BotFather inside Telegram, and the logic is built visually in n8n by connecting nodes. The most technical thing you will do is paste an API token into a credential field and write short expressions to reference incoming data.

Why doesn't my Telegram Trigger fire when I message the bot?

Almost always because Telegram cannot reach your n8n instance. Webhooks require a public HTTPS URL, so an n8n running on localhost is invisible to Telegram unless you put a tunnel in front of it. Also confirm the workflow is activated, since the production webhook is only registered while the workflow is active.

Can one bot handle multiple commands?

Yes. Use a single Telegram Trigger node, then branch with IF or Switch logic on the message text. Each branch does its own work and ends in a Telegram node that replies to the chat ID from the trigger, so one workflow can serve an entire menu of commands.

Is the Telegram Bot API really free?

Yes. Creating bots through BotFather and sending or receiving messages through the Bot API costs nothing. Your only costs are whatever your workflows consume, such as AI API calls, plus the server that keeps n8n running around the clock.

Host it without the ops.

WordPress, WooCommerce, static sites, and dedicated n8n VMs. Same price at renewal, live in minutes.