Home · Blog · How to connect an AI agent to a Telegram bot and check the answers
How to connect an AI agent to a Telegram bot and check the answers
An hour is a real time limit if the knowledge base is already in a text file and the map is at hand: AI in CHBT is available from the “Basic” plan (650 ₽ per bot per month), on the “Free” there is no “AI agent” block. You choose the model yourself - GPT-5, Claude, Gemini, DeepSeek or Qwen, by default Gemini 3 Flash for one credit per answer; powerful models are more expensive - this is worth knowing before you start, not after. Below is a timeline by minute: token from @BotFather, connecting a channel, creating an agent, a script of three blocks, test and launch. At the end there is a table of plugs at which an hour usually turns into an evening.
Before the start: what to prepare and two honest reservations
Application flows and conditions are available on the page "AI agent for business". Here are instructions for connecting it to the Telegram bot.
The hour is completed if the following are on the table at the beginning:
- account in CHBT (registration - e-mail and password, minute);
- Telegram on the phone and on the computer - it’s more convenient to test from the phone;
- text file with a knowledge base: prices, conditions, frequently asked questions - compact, without marketing. If it doesn’t exist, start with it, this is the only stage that cannot be accelerated; how to assemble - in the article about the knowledge base for the AI agent;
- bank card: AI agents are available from the plan "Basic" plan — 650 ₽ per bot per month. On “Free” the Telegram bot works, but there is no “AI agent” block in it.
The second caveat is about the model. The model is selected from ten in the agent card - GPT-5, Claude, Gemini, DeepSeek and Qwen, the list is sorted by price. For the database with prices and conditions, the default model, Gemini 3 Flash, is sufficient - one credit per answer; powerful models like Claude Sonnet 5 hold their role more accurately, but are more expensive. And one more thing: the AI agent responds only with text - without buttons, photos and files; the buttons give script blocks before and after the node. The agent will not show pictures of goods: photos of goods are shown only by cards of the AI seller, who responds according to the catalog, and not according to the knowledge base.
Next is the timeline. The time is indicated with a margin for “where is this button”.
0:00–0:07 — token from @BotFather
In Telegram, open @BotFather, send /newbot. He will ask for two names: a display name (any, can be in Russian) and a username - in Latin, necessarily with the ending bot, for example svet_electro_bot. In response, you will receive a token like 123456789:AAH.... Copy it entirely - without spaces at the beginning and end, this is a common reason for “the channel does not connect.”
The token is the key to the bot. Do not forward it to chats or publish it; if it's leaked, in @BotFather the command /revoke will produce a new one, and the old one will stop working (and will have to be replaced in CHBT). More information about BotFather, name, avatar and description can be found in the help about the token and in the article about creating a Telegram bot (link below).
0:07–0:17 — connect the channel and turn on the AI plan
In the CHBT account: create a bot (this is a project - one bot works in all connected channels), open the “Channels” → “Connect Telegram”, insert the token, save. CHBT will install a webhook with a secret token on its own—no need to configure anything manually. The connection status should appear in the channel card.
If you later revoke the token in @BotFather and forget to update it in CHBT, the webhook will start returning 401 - CHBT will send an email to the owner. While there is no script, the bot will not respond to messages - this is normal, we will return to the test at the 47th minute. Step-by-step help on connecting is available in the “Help” section.
The next five minutes - section “Payment”, without it the “AI Agent” block will not appear in the script. Two options:
- “Basic”, 650 ₽ - 150 AI responses per month, canvas, broadcasts, unlimited conversations. For a start and a small stream of questions.
- Trial period of “Business” - 1 day, activated there. Suitable for collecting and checking everything today, and paying when you decide. “Business” - 1290 ₽, 500 AI responses per month.
Payment by card via CloudPayments, auto-renewal is enabled by default - disabled in the same section; Cancellation does not cancel the paid period. Five minutes are allowed for card entry and confirmation. Comparison of Plans - on the page price.
0:17–0:37 — creating an AI agent
The longest stage. Section "AI Agents" → create. There are five fields on the card, in order:
- Name — the agent will introduce himself: “Consultant of the Svet studio.”
- Model - start with the middle one. Turn on strong if the agent confuses similar positions in the test.
- Temperature — below average, 0.3–0.4: we need prices from the base, not creativity.
- Person (role) - 6–8 lines: who he is, in what language and how briefly he answers, what he answers only from the database, what he does if there is no answer (“tell me what you want to clarify and offer to call an operator”), what he doesn’t promise (discounts, terms, results) and what he doesn’t ask (card details, passport).
- Knowledge base — insert the prepared text. The entire database goes to the model with each question, so shorten the long one first: cut out marketing paragraphs and repetitions.
Two things are not on the card, and you don’t need to look for them. The agent does not write a greeting - the first message with buttons is done in the “Message” block in the script, and it is free. There are also no trigger words for transmission to a person: the output to the operator is configured in the script - with the “did not understand” port of the “AI agent” block and a separate script for the word “operator” (more on this in the next step).
Save and open test chat in the agent card. Five questions: two - directly from the database, one - paraphrased with a typo, one - outside the database (must honestly refuse and offer an operator), one - a request to “call a person” (according to the role, the agent must agree and offer an operator, and not argue). If something is wrong, edit the database or person now: after launch, every mistake will cost the client credit and trust.
0:37–0:47 - flow of three blocks
Section “flows” → new flow. The “Canvas” mode is more convenient: you can see the branches. Trigger - /start command: any conversation with a Telegram bot begins with it, the “Start” button in Telegram sends it. Next:
- "Message" — a greeting with two buttons: “Ask a question” and “Contact a manager.” If you are planning broadcasts or collecting a database, here is a short text of consent to data processing.
- Click the “Ask a question” button - “AI agent”: select the created agent, the “Stay in conversation with AI” mode and check the “Separate port “did not understand”” checkbox. The agent conducts a conversation, taking into account up to 10 recent messages, and when he is not sure of the answer or does not find it in the database, he leaves using the “do not understand” port.
- After "AI Agent" - “Operator”: the conversation goes to “Conversations”, the bot becomes silent. Here enter the “don’t understand” port, the output of the block in case of exhaustion of credits and the “Contact the manager” button.
Two more minutes for the second flow: the “Keyword” trigger in the “contains” mode - operator, manager, person — → “Message” “I transmit” → “Operator”. Consider how he interacts with the agent: in the “Stay in conversation with AI” mode, the client’s text goes to the agent before the triggers are checked, and the word “operator” inside the conversation will be seen not by the script, but by the agent himself. There is only one way out of this mode - the “did not understand” port, and it is triggered when the agent’s response sounds like refusal or uncertainty: “I can’t”, “no information”, “check with...”, “unfortunately”. Therefore, add the line to the persona: “if you are asked to call a person, do not answer the question, but write: “Unfortunately, I can’t help myself - I’m passing it on to the operator.” Such a response takes the conversation to the “did not understand” port, and from it to the “Operator”. A script for the keyword is needed for all other cases: when a person writes “operator” from the menu, in the middle of a question about the phone, or after closing the conversation.
Optional, if you have a minute: before “AI agent” put “Action” → “Add tag” II, and before “Operator” - the tag escalation. In a week in “Contacts” these tags will show how many people reached the neural network and how many went to the person - there are no separate counters for blocks in CHBT.
An alternative to a push-button input is a trigger. “Any message”: the script starts on any text, and the person gets to the agent without pressing any buttons. This is more natural for the client, but more expensive: each “hello” and “thank you” is a separate response from the agent, that is, a loan. For the first launch, leave /start with the buttons; Switch to “Any message” when you understand the real flow and its cost.
The script is saved automatically; The version history will allow you to rollback if you break something during edits. If you want to correct something with words along the way, the editor has an AI edit with the text: “add a question about the city after the greeting.”
0:47–0:55 — test from phone
First “Check script” in the editor - test chat directly in CHBT, without Telegram: go through both buttons. Then - real Telegram from your phone: find the bot by username, click “Start”.
- Welcome with buttons arrived? If not, see “Channels”: whether the token is connected, and “flows”: whether the script is enabled.
- “Ask a question” → question from the database → answer based on facts.
- Question outside the base → refusal and offer from the operator, without a fictitious service.
- The request “call the operator” → the agent responds with a refusal phrase from the person, and in the office, in “Conversations”, a conversation with the status “Operator” appeared (the “Waiting for a response” tab), a notification was received (turn on the sound and browser notifications with the bell icon in the inbox).
- Reply from “Conversations” - the message should arrive in Telegram.
Every response from an agent in a real Telegram writes off the loan, so test it carefully: debug the wording and base in the agent’s test chat, and in Telegram - two or three control questions. If the bot is silent to all messages, see the checklist of reasons in the article “Why the Telegram bot does not respond” (link below).
0:55–1:00 — launch
- In @BotFather, set the bot description (
/setdescription) and avatar - this is visible before the first message. - Link
t.me/your_bot— in the channel description, in the signature on the website, in the profile. Use deep links for different sourcest.me/your_bot?start=site: the “Deeplink” trigger in the script catches the payload, and you will understand where people came from. - In the “Access” section, invite operators by e-mail with the “Operator” role - otherwise the transferred conversations will be waiting for you alone.
- Web Push in “Account → Notifications” - to see escalations when the tab is closed. There is also an e-mail about a new conversation if the office is not opened every day.
At this point the hour is over: the bot answers the database, transmits it to the person and collects contacts in “Contacts”. All the features of the Telegram channel in CHBT are on the page “Telegram chatbot without programming”.
Where is an hour usually lost?
| Plug | Cause | What do |
|---|---|---|
| Knowledge base “almost ready" | It is not in text form | Start with the base, not with the token. A scan without a text layer is not recognized - paste the text manually |
| Channel not connected | Space in token, token from another bot | Copy again from @BotFather entirely |
| No block “AI agent” | “Free” plan | “Payment” → “Basic” or trial day “Business” |
| The agent answers in general terms | The base is thin or marketing | Replace descriptions with the lines “service - price - term” |
| The agent is making up services | No obvious refusals | Section “What we don’t do” in the database, “only in the database” in roles |
| The word “operator” does not convey the conversation | There is no script for the keyword; or the agent is in the “Stay in conversation with AI” mode, and the “did not understand” port does not lead to “Operator” | Start the flow “Keyword” → “Operator”; port “did not understand” → “Operator” |
| The bot became silent after a week | Ended credits | Fallback thread → “Operator”; buttons for standard questions |
Another trap is expectations. The agent responds exactly to what is written in the database, no more. If clients ask about something that is not in the database, this is not a breakdown, but a signal to add the text: “Conversations” on the “Waiting for an answer” tab will show what exactly.
Week 1: Three edits you'll need
A bot assembled in an hour is a draft. After a week of actual conversation, three edits are almost always needed.
- Add the base. Open “Conversations”, the “Waiting for a response” tab, and what the operator has already answered and closed - on the “Closed” tab: there are conversations that the agent gave to the person. Write down questions that were not answered in the database and add them in question-answer pairs to the agent’s card.
- Expand keywords. Clients ask a person not with the word “operator”, but with “call the manager”, “can I be with a live person”, “is anyone there?” Add wording from real conversations to the “Keyword” trigger of the transfer script - and with the same line to the agent’s persona, so that he recognizes the request within the conversation.
- Remove repetitive stuff from AI. If one question is “how much does it cost to travel?” - asked in every third conversation, add it to the greeting button with a ready-made message. It's free and more accurate than the model's answer, and credits will remain for rare questions.
Evaluate credit consumption by tags from step “0:37–0:47”: in “Contacts” filter by tag II will show how many people reached the agent by tag escalation - how many went to the person. If by the end of the second week it is clear that 150 “Basic” credits are not enough, the transition to “Business” with 500 credits is done in “Payment” without rebuilding the bot.
What's next: MAX, website and support
The script is not tied to Telegram. Connect a channel in the same bot MAX or VKontakte - the same agent and the same block chain will work there without transfer. There is a separate assembly for the site with an “Open widget” trigger and a pre-chat form - in the article about AI consultant on the site. If the bot is needed for customer support, and not for consultations, the boundaries of “what to trust in a neural network” are discussed in the adjacent article about the first line of support using an AI agent.
After a week, look at “Analytics”: if on the graph “Operator’s responses” grow along with incoming ones, the database cannot cope (the agent’s responses there are included in “Bot’s responses”). And on the “Waiting for an answer” tab in “Conversations” there are questions that the database lacks. Create a bot and do it in an hour →
Telegram chatbot in CHBTHow to create a Telegram bot: BotFather, name, avatarWhy does the Telegram bot not respond?Knowledge base for AI agentFirst line of support on the AI agent