Lesson 3 · Module 5: Omnichannel Integration: WhatsApp, Telegram and MCP
Building a Telegram bot and linking it to the same agent
Video coming soon
Learn it with your tutor on the live board
Key points from the video
One shop, two chat apps
- Your WhatsApp agent already answers customers
- Many customers live on Telegram instead
- Goal: same agent, a second front door
What you will learn
- Create a Telegram bot and get its token
- Receive messages by webhook and reply
- Plug Telegram into your existing agent
Meet BotFather
- Open Telegram, search for BotFather
- Send /newbot, pick a name and username
- Copy the token, store it as a secret
- No business verification needed
How a message reaches you
- A webhook is a URL Telegram calls for you
- Register it once with setWebhook
- Add a secret_token, check it every call
What Telegram actually sends
import json
update = {
"update_id": 901,
"message": {
"chat": {"id": 5551234, "type": "private"},
"from": {"id": 5551234, "first_name": "Sara"},
"text": "Can I book a consultation on Friday?",
},
}
def to_common(update):
msg = update["message"]
return {
"channel": "telegram",
"user_id": f"tg:{msg['from']['id']}",
"name": msg["from"]["first_name"],
"text": msg["text"],
}
incoming = to_common(update)
print(incoming)
reply = {"chat_id": 5551234,
"text": f"Hi {incoming['name']}! Pick a time below."}
print(json.dumps(reply)) One agent, two doors
- Each channel gets a thin adapter
- Adapters translate to one common message
- The agent never knows which app was used
layout: wide
direction: LR
components:
waUser: {kind: user, label: WhatsApp customer}
tguser: {kind: user, label: Telegram customer}
tg: {kind: external, label: Telegram}
wa: {kind: external, label: WhatsApp}
adapter: {kind: api, label: Channel adapters}
agent: {kind: llm, label: Agent}
cal: {kind: database, label: Calendar}
links: [waUser->wa, tguser->tg, tg->adapter, wa->adapter, adapter->agent, agent->cal]
steps:
- at: "two front doors"
show: [waUser, tguser, tg, wa, adapter]
- at: "the same brain"
show: all
- at: "Sara asks for Friday"
flow: ["tguser>tg: book Friday", "tg>adapter: update", "adapter>agent: common message", "agent>cal: free slots", "cal>agent: 10 and 14", "agent>adapter: reply", "adapter>tg: sendMessage"] Worked example: booking on Telegram
- Sara asks for a consultation on Friday
- Agent replies with inline time buttons
- Tap sends a callback query: answer it
- Agent books, confirms, sends invoice link
The no-code build in n8n
- Telegram Trigger: messages and button taps
- Button tap? Answer Query first
- Set node: map fields to the common format
- Call the same AI Agent sub-workflow
- Telegram node: send text or buttons
How Telegram differs from WhatsApp
- No 24-hour window, no template approval
- Free to send, no per-message fees
- A bot can't message someone first
- Customers find you by username or link
Common mistake: an open webhook
- Webhook URL with no secret check
- Anyone can post fake "customer" messages
- Fakes trigger bookings, refunds, AI costs
- Fix: set secret_token, reject mismatches
Recap
- BotFather gives you a bot and a token
- Protect the webhook with a secret token
- Adapters turn each channel into one message
- One shared agent serves every door
Your exercise
- Create a test bot with BotFather
- Build the n8n flow, button taps included
- Route it to your existing agent
- Book one slot with an inline button
Transcript
One shop, two chat apps. Picture Mona, who runs a small online skincare shop and sells video consultations. In the last lesson her agent learned to answer on WhatsApp: questions about products, bookings, invoices. Then a customer writes, "Do you have Telegram? I don't use WhatsApp." A week later three more ask the same thing. So does Mona need a second agent, a second set of prompts, a second calendar? No. The agent is the brain, and WhatsApp is just one door into it. Today we add Telegram as a second door, so the same agent answers in both places with the same knowledge and the same booking rules.
What you will learn. By the end of this lesson you'll be able to do three things. First, create a Telegram bot and get its token, the secret key that lets your system speak as that bot. Second, receive customer messages through a webhook and send replies back. Third, and most important, connect Telegram to the agent you already built, so you don't rebuild anything. We'll do it in n8n, the no-code tool we've been using, and I'll show a few short lines of Python so you can see exactly what data moves between the pieces.
Meet BotFather. Telegram makes this part refreshingly quick. Inside the Telegram app you search for an official account called BotFather. You send it the command slash newbot, give your bot a display name like Mona Skincare, and a username that must end in "bot", like mona skincare bot. BotFather replies with a token, a long string of numbers and letters. Treat that token like a password: anyone who has it can control your bot. Put it in n8n's credentials, never in a shared document. Compare this with WhatsApp, where you needed a business account, a verified number and approved templates. Here there's no review at all.
How a message reaches you. When a customer types to your bot, the message first lands on Telegram's servers. Telegram then has to tell you about it. The cleanest way is a webhook. Think of it as giving the post office your home address: instead of you walking to the post office every few minutes to ask "anything for me?", they bring each letter to your door. You register your address once with a call named setWebhook, and you include a secret token. Telegram sends that secret back on every delivery in a header, a small label that travels with each delivery, so your workflow can check it before doing anything. Then the agent thinks, and you reply with sendMessage.
What Telegram actually sends. Let's slow down and look at the real data. Telegram sends a small package called an update. Inside is the message: the chat id, which is the conversation's address, who sent it, and the text. Our little function, to common, reshapes it into the same simple format our WhatsApp side already produces: which channel, a user id, a name, and the text. Notice the user id gets a prefix, t g colon, so a Telegram number can never clash with a WhatsApp phone number. The reply is even simpler: a chat id and the text to send. That's all sendMessage needs.
One agent, two doors. Here's the whole idea in one picture. Mona's shop now has two front doors, WhatsApp and Telegram, and each door has a thin adapter that translates its own format into the common message we just built. Behind the adapters sits the same brain you already made, with the same prompt, the same tools and the same calendar. Watch what happens when Sara asks for Friday. Telegram delivers the update, the adapter translates it, the agent checks the calendar, finds two free slots, writes a reply, and the adapter sends it back through Telegram. The agent never needed to know which app Sara used.
Worked example: booking on Telegram. Let's follow one real booking. Sara's first message asks, "Can I book a consultation on Friday?" The agent replies with a short message: "Happy to help, Sara. These times are free on Friday." Under it are buttons, ten o'clock, two o'clock, or "another day". Telegram calls these inline keyboard buttons, and each one carries a hidden code like slot ten. When Sara taps one, Telegram sends a callback query instead of text. Your workflow answers it so the button stops spinning, then the agent books the calendar slot, confirms in the chat, and sends the invoice link. One tap instead of typing times back and forth.
The no-code build in n8n. In n8n this takes four main nodes and one small extra. Start with the Telegram Trigger, paste your bot's credential, and choose two update types: messages, and callback queries, which are button taps. n8n registers the webhook, and current versions also check the secret token for you. When the update is a button tap, a Telegram node with Answer Query tells Telegram you got it, so the button stops spinning. Next, a Set node maps the fields into the common format: channel, user id, name and text; for a tap, the button's hidden code becomes the text. Then call your existing agent, saved as its own sub-workflow, so both channels share exactly the same one. If its answer includes choices, like time slots, send inline buttons; otherwise send plain text. Change the agent once, and both channels improve.
How Telegram differs from WhatsApp. A few rules change between the two doors. On WhatsApp you had a 24-hour reply window and approved templates for anything outside it. Telegram has neither, and sending messages costs nothing. The catch is that a bot can only message people who have started a chat with it first, so you can't import a list of customers and send a promotion. That's why Mona puts a t dot me link on her invoices and order emails. One tap opens the bot, the customer presses Start, and from then on the agent can send reminders and invoice updates.
Common mistake: an open webhook. Here's the mistake I see most often. People set up the webhook, it works, and they never add the secret check. Your webhook is just a public web address, and anyone who finds it can send it something that looks exactly like a Telegram update. A stranger could fake a customer, book every slot on Friday, ask for refunds, or simply spam you until your AI bill jumps. The fix takes two minutes. Set a secret token when you register the webhook, and make the first step of your workflow compare the header. In n8n the Telegram Trigger does this for you; with a plain Webhook node, an IF node does it. If it doesn't match, stop right there.
Recap. Let's recap. BotFather creates your Telegram bot in a minute and gives you a token, which you guard like a password. Telegram delivers each message to your webhook, and you protect that webhook with a secret token. A thin adapter turns every channel's format into one common message, with prefixed user ids so customers never get mixed up. And behind every door sits one shared agent, so a fix to its prompt or tools helps WhatsApp and Telegram at once. Next lesson we give that agent one memory across all its doors.
Your exercise. Now it's your turn. Create a test bot with BotFather for your own business idea, or for Mona's shop. Build the flow in n8n: the Telegram Trigger listening to messages and callback queries, an Answer Query step for button taps, a Set node for the common format, a call to the agent you built for WhatsApp, and a Telegram send node. Make sure the secret token check is on: the trigger handles it, and if you used a plain Webhook node, add the IF node that compares the header. Then message your bot from your phone, ask for an appointment, and complete one booking by tapping an inline button. If the same agent answers you on both WhatsApp and Telegram, you're ready for the next lesson.
Explore the animation
The animations from the video, exact and live: play them, pause, drag the slider or jump to a step at your own pace.
Loading the animation...
Lesson summary
- Video watched
- BotFather gives you a bot and a token
- Protect the webhook with a secret token
- Adapters turn each channel into one message
- One shared agent serves every door