n8n Telegram AI Agent: When n8n Is Enough and When You Need Code
n8n is enough for a Telegram AI agent when it answers from a limited knowledge base and a human approves risky actions. When you need code, the traps to avoid, and what drives the cost.
6 min read
In this article
n8n is enough for a Telegram AI agent when the bot answers questions from a limited knowledge base, routes messages to people or other tools, and a human approves every risky action. You need custom code when the bot takes payments, runs multi-step conversations with state, serves many users at once, or must meet strict requirements for data handling, testing and cost control.
Below: how such a bot is put together, where n8n is strong, where it starts getting in the way, and which traps to avoid from day one.
What does an n8n Telegram AI agent look like?
The simplest n8n workflow has three parts:
- Telegram Trigger — the node that receives a new message from Telegram.
- AI Agent — the node you connect three things to: a language model, memory (so the bot remembers the conversation) and tools (for example a spreadsheet lookup, a calendar, a call to your own system).
- Telegram — the node that sends the reply back to the chat.
You can have a working prototype in an hour. The hard part is building one you can trust once customers start writing to it.
When is n8n enough?
- Answers from a limited knowledge base. Opening hours, services, delivery terms, frequent questions.
- Message routing. The bot works out what the person wants and passes the message to the right colleague or into the CRM.
- Internal bots for the team. On-demand reports, reminders, data lookups.
- Drafts for a human. AI prepares the reply; a person checks it and sends it with one tap.
- Testing before investing. First find out whether customers will use a bot at all.
Rule of thumb: while the workflow fits on one screen and one person maintains it, n8n is usually the fastest route.
When do you need custom code?
- Payments and money. Invoices, payment checks, refunds — mistakes here cost money, so you need tests and clear logic.
- Multi-step conversations with state. Sign-ups, order forms with validation, going back a step — in a visual workflow this turns into a tangle.
- Many users at once. With heavy message traffic, it matters how queues are handled and what happens when the AI service is slow.
- Strict data requirements. What is stored, where and for how long, and what is sent to the AI provider — easier to control and prove in code.
- A Telegram Mini App or your own interface. Button menus, forms, a catalogue — that's an app, not a workflow.
- Versioning and tests. When several people change the logic, you need to see what changed and be able to roll back.
A general comparison of n8n, Make and custom code: n8n vs Make vs custom code.
What traps wait in n8n and Telegram workflows?
- One bot, one webhook. Telegram allows a bot only one webhook address. Two n8n workflows using the same bot overwrite each other, and while you test, n8n temporarily points the bot at a test URL. Use a separate bot for a separate purpose, or one workflow with branches.
- A public HTTPS address. Telegram Trigger works via webhook, so your n8n instance must be reachable from the internet over HTTPS.
- Memory per chat. The memory key must be the chat ID, or the bot will mix up different people's conversations. The simplest memory is fine for testing; in production, keep memory in a database.
- Message length and formatting. A Telegram message can be up to 4,096 characters, and badly marked-up formatting (Markdown or HTML) can stop the message being sent. Trim and clean the AI's reply.
- AI costs. Every message is a model request, and tools plus long memory increase the tokens used. Set a spending limit in your AI provider account.
- Attempts to talk the bot round. People will try to make the bot do things it shouldn't. Tools should allow only what's necessary, and risky actions — prices, bookings, refunds — should go through human approval.
The hybrid: n8n for integrations, code for the bot's core
Often the best answer isn't either/or. The bot's core (conversation logic, state, payments) is written in code, and n8n stays for integrations: pushing data to a spreadsheet, CRM or email. The team can change integrations without a developer, while what must work reliably lives in code with tests.
AI in such a bot drafts; it doesn't decide. A reply or action with consequences is approved by a person. How a bot can help with customer service: Telegram bot for customer service.
What drives the cost of such a bot?
We don't publish a fixed price. It depends on:
- how many workflows there are and how many branches each has;
- how many tools and integrations the bot uses (spreadsheets, CRM, calendar, online shop);
- the size of the knowledge base and how it's updated;
- whether you need human approval and an admin panel;
- where n8n and the bot run — n8n's cloud or your own server;
- the expected volume of AI requests.
| Simple project | Complex project | |
|---|---|---|
| What it does | Answers frequent questions, hands hard ones to a person | Takes orders, checks stock, offers time slots, takes payments |
| How it's built | One n8n workflow | Bot core in code, n8n for integrations |
| Data | A knowledge base in one document | Database, CRM, online shop |
| Control | Log of AI replies | Human approval, spending limits, tests |
What to do tomorrow
- List the 20 questions customers ask you most and mark which ones can be answered without a person.
- Decide which actions the bot must never take without approval.
- Check that your n8n instance is reachable over HTTPS and that the Telegram bot isn't used in another workflow.
Stuck on an n8n workflow, or want the bot to be reliable from day one? Describe what the bot should do and we'll suggest what to keep in n8n and what to write in code. More on the Telegram bots and automation pages.
Frequently asked questions
Is n8n good for a Telegram AI bot?
Yes, when the bot answers from a limited knowledge base, routes messages and a person approves risky actions. For payments, complex conversations and heavy traffic, custom code is more reliable.
Why does the n8n Telegram Trigger stop receiving messages?
Most often because another workflow or a test run set the webhook for the same bot — a Telegram bot can have only one webhook address.
Do I need my own server for n8n?
Not necessarily: you can use n8n's cloud or install it on your own server. For Telegram Trigger, n8n must be reachable from the internet over HTTPS.
Can an AI bot answer customers without a human?
It can, but replies with consequences — prices, bookings, refunds — should go through human approval. AI works best as a draft writer.
How much does an n8n Telegram AI agent cost?
It depends on the workflows, integrations, knowledge base and control requirements. Beyond the build, you pay monthly for n8n (cloud or server) and AI requests.