الدرس 4 · الوحدة 5: Omnichannel Integration: WhatsApp, Telegram and MCP
One brain, many channels: shared memory across WhatsApp, Telegram and web
- One bot per channel creates strangers
- How one customer ID links WhatsApp, Telegram and web
- How to store and load shared memory safely
Why this matters
A customer who messages your business on WhatsApp today and on Telegram tomorrow expects you to know them. When each app has its own bot, that person is treated as a stranger, repeats their details and may lose a booking.
Key ideas
- Chat IDs belong to one app. Each app gives every conversation its own number, so one customer has a different chat ID on each channel. If From the lesson: Giving agents memory: storing conversations and business data in a databaseSaved notes, past messages and facts that an agent stores in a database and reads before it answers.Review that lesson is filed under that number, the notes never meet.
- File memory under a customer ID. One number you own, such as C042, stands for the person on every app. A lookup table pairs each app's sender ID with that customer ID:
| Channel | Sender ID | Customer ID |
|---|---|---|
| +20 100 123 4567 | C042 | |
| Telegram | 88412093 | C042 |
A sender who is not in the table is a new contact.
- One router, one agent. Each message is first normalized, meaning turned into one standard shape with its channel, sender, text and time. The router then finds the customer ID, loads that customer's memory and passes everything to a single agent. The reply goes back out through the channel it came from.
- Two kinds of memory. Short-term memory holds the last ten or so messages. Long-term memory is a file card of facts such as name, booking and unpaid invoice. Summarize old messages, since the the amount of text a language model can read in one go is limited and extra text slows replies down.
- Link accounts only with proof. Use a shared phone number or a one-time code, never a name, since many people share one. Write numbers with a plus sign and country code before comparing them. No match means a new customer ID.
Try it before you watch
A patient books through your clinic's website, then later messages you on Telegram. Which ID should the agent file the memory under, and why not the Telegram chat ID?
Show answerHide answer
The customer ID, once both accounts are linked by proof. A Telegram chat ID belongs only to that app, so a website message would never reach the same notes. It shows that memory follows the person, not the app.
Words to know
- Customer ID: your own permanent number for one person, used on every app.
- Chat ID: the number an app gives one conversation. It is unique to that app.
- Normalize: convert a message from any app into one standard shape.
- Lookup table: a list of rows in a sheet or database that matches a sender to a customer ID.
- Identity linking: joining one person's accounts on different apps under one customer ID.
- Short-term memory: the most recent messages of a conversation.
What to watch for
- How the router turns each app's sender into one customer ID before the agent runs, so the agent never sees three different people.
- That a link is made only after proof, and that a matching name alone never counts.
- Which facts move onto the long-term file card and which old messages get summarized away.
تعلّمه مع معلمك على السبورة المباشرة
أهم نقاط الفيديو
The shop with amnesia
- Omar books a pickup on WhatsApp
- The next day he follows up on Telegram
- The bot asks for your name again
- He feels the shop lost its memory
layout: wide
parts:
shop: {chip: "Sara's shop", sub: "Candles online"}
msg: {chat: "Can I move my pickup?"}
steps:
- at: "who sells handmade candles"
spokes: {of: shop, items: ["Handmade candles", "Sells online"]}
- at: "messages her shop on WhatsApp"
note: "Monday, on WhatsApp"
- at: "opens Telegram"
note: "Tuesday, on Telegram"
- at: "wants to move the pickup"
send: msg
- at: "asks for your name again"
note: "Bot: can you tell me your name?"
- at: "lost its memory"
highlight: shop
note: "Memory lost"
- at: "told the shop everything"
note: "Yesterday: everything told"
- at: "one brain that remembers"
note: "One brain for every app" What you will learn
- One bot per channel creates strangers
- How one customer ID links WhatsApp, Telegram and web
- How to store and load shared memory safely
tree:
Today: [One bot per channel, One customer ID, Store memory in one place]
start: none
steps:
- at: "checklist for today"
show: Today
- at: "one bot per channel"
show: "One bot per channel"
- at: "one customer ID"
show: "One customer ID"
- at: "store memory in one place"
show: "Store memory in one place"
- at: "from the last lessons"
highlight: Today Three bots, three brains
- Each channel workflow keeps its own memory
- Memory is filed under that app's chat ID
- A booking on WhatsApp is unknown on Telegram
- One person ends up in three folders
layout: side
direction: LR
components:
wa_bot: {kind: service, label: WhatsApp bot}
tg_bot: {kind: service, label: Telegram bot}
web_bot: {kind: service, label: Web bot}
wa_mem: {kind: database, label: WhatsApp notebook}
tg_mem: {kind: database, label: Telegram notebook}
web_mem: {kind: database, label: Web notebook}
links: [wa_bot->wa_mem, tg_bot->tg_mem, web_bot->web_mem]
steps:
- at: "Let's see why it breaks"
show: []
note: "Why it breaks"
- at: "saved notes, past messages"
note: "Memory: saved notes and facts"
- at: "as its own workflow"
show: [wa_bot, tg_bot, web_bot]
note: "One workflow per channel"
- at: "the WhatsApp bot keeps"
show: [wa_bot, tg_bot, web_bot, wa_mem]
- at: "the Telegram bot keeps another"
show: [wa_bot, tg_bot, web_bot, wa_mem, tg_mem]
- at: "the web bot keeps a third"
show: all
- at: "filed under that app's chat ID"
note: "Filed under the chat ID"
- at: "a booking made on WhatsApp"
flow: ["wa_bot>wa_mem: booking"]
- at: "Nothing at all"
highlight: [tg_bot, tg_mem]
note: "Nothing at all"
- at: "zero shared facts"
note: "Three folders, zero shared facts" One brain, many doors
- Every channel sends messages to one router
- The router finds the customer, then calls one agent
- The agent reads and writes one shared memory
- Replies go back through the door they came in
layout: side
direction: TB
components:
wa: {kind: external, label: WhatsApp}
tg: {kind: external, label: Telegram}
web: {kind: browser, label: Web chat}
router: {kind: gateway, label: Channel router}
agent: {kind: llm, label: Agent}
mem: {kind: database, label: Shared memory}
links: [wa->router, tg->router, web->router, router->agent, agent->mem]
steps:
- at: "three front doors"
show: [wa, tg, web]
- at: "passes through one router"
show: all
- at: "the router turns the sender"
flow: ["tg>router: hi", "router>agent: C042"]
- at: "the agent loads that customer's history"
flow: ["agent>mem: load", "mem>agent: history"]
- at: "writes a reply"
flow: ["agent>router: reply"]
- at: "sends it back out through Telegram"
flow: ["router>tg: sent"] The identity key
links = {("whatsapp", "+201001234567"): "C042",
("telegram", "88412093"): "C042"}
memory = {"C042": {"name": "Omar",
"booking": "Tue 15:00"}}
def recall(channel, sender):
cid = links.get((channel, sender))
if cid is None:
return "New contact: ask who they are"
m = memory[cid]
return f"{cid}: {m['name']}, {m['booking']}"
print(recall("whatsapp", "+201001234567"))
print(recall("telegram", "88412093"))
print(recall("telegram", "55500011")) Every message, the same path
- Convert each app's message into one standard shape
- Look up the customer ID, then load memory
- Reply on the same channel the message came from
layout: full
parts:
hub: {chip: "Message", sub: "Any app"}
steps:
- at: "walks the same path"
note: "Every message, one path"
- at: "First it arrives"
note: "1. Message arrives"
- at: "we normalize it"
note: "2. Normalize: one standard shape"
- at: "three different paper forms"
note: "Many forms, one order slip"
- at: "find the customer ID"
note: "3. Find the customer ID"
- at: "load that customer's memory"
note: "4. Load memory"
- at: "The agent writes its reply"
note: "5. Agent writes the reply"
- at: "send it back"
note: "6. Send back on the same channel"
- at: "the wrong door"
note: "Never the wrong door" Two kinds of memory
- Short-term: the last messages of the conversation
- Long-term: facts like name, booking, lead stage, unpaid invoice
- Summarize old chat, keep the facts up to date
tree:
Memory:
Short-term:
Sticky notes:
Long-term:
File card: [Name, Booking, Lead, Unpaid invoice]
steps:
- at: "Not all memory is the same"
note: "Not all memory is the same"
- at: "recent conversation"
show: Short-term
- at: "like sticky notes on your desk"
grow: Short-term
- at: "the customer's file card"
show: Long-term
grow: Long-term
- at: "whether they're a hot lead"
grow: File card
- at: "A language model has a context window"
note: "Context window: the size of the desk"
- at: "replies get slower"
note: "Slower, pricier, confused"
- at: "summarize older ones into a line or two"
note: "Summarize older ones"
- at: "whenever a fact changes"
highlight: File card Worked example: Omar moves his pickup
- Monday, WhatsApp: pickup booked for Tuesday
- Router finds the same ID C042, same file card
- Tue, Telegram: move it to Wednesday morning
- Omar says yes, the agent updates his file card
layout: side
direction: LR
components:
omar: {kind: user, label: Omar}
router: {kind: gateway, label: Router}
agent: {kind: llm, label: Agent}
mem: {kind: database, label: C042 file card}
links: [omar->router, router->agent, agent->mem]
steps:
- at: "Let's follow Omar"
show: [omar]
- at: "texts the shop on WhatsApp"
note: "Monday, on WhatsApp"
- at: "The router finds"
show: [omar, router]
- at: "the agent saves the booking"
show: [omar, router, agent]
- at: "on his file card"
show: [omar, router, agent, mem]
flow: ["agent>mem: booking"]
- at: "and confirms"
flow: ["agent>router: confirms"]
- at: "On Tuesday he's at home"
note: "Tuesday, on Telegram"
- at: "writes on Telegram"
flow: ["omar>router: Wednesday morning"]
- at: "looks up his Telegram ID"
flow: ["router>agent: Telegram ID"]
- at: "opens the same notebook"
flow: ["agent>mem: same notebook"]
- at: "already knows his name"
flow: ["mem>agent: his name"]
- at: "checks the shop's free slots"
note: "Checks free slots"
- at: "Wednesday at eleven works"
flow: ["agent>router: Wednesday at eleven"]
- at: "Omar says yes"
flow: ["omar>router: yes"]
- at: "updates his file card"
flow: ["agent>mem: file card"]
- at: "sends a new confirmation"
flow: ["agent>router: confirmation"]
- at: "No questions repeated"
highlight: [mem]
note: "No questions repeated" Linking a new account safely
- Ask for proof: shared phone number or a one-time code
- Compare numbers in one format: plus and country code
- Nothing matches? Create a new customer ID
- Proof first, then link
layout: full
parts:
hub: {chip: "Telegram user", sub: "First message"}
steps:
- at: "get into the table"
note: "How did the ID get in?"
- at: "the router found no match"
note: "No match yet"
- at: "share his phone number"
note: "Ask for the phone number"
- at: "one-tap contact button"
note: "One tap to share contact"
- at: "apps write numbers differently"
note: "Plus sign and country code"
- at: "rewrite every number in one format"
note: "Same format, then compare"
- at: "The number matched his WhatsApp row"
highlight: hub
note: "Match found: link it"
- at: "we added the Telegram ID"
note: "Added to his customer record"
- at: "On your website"
note: "Website: login or code"
- at: "emailing a one-time code"
note: "Or email a one-time code"
- at: "If nothing matches"
note: "No match: new customer ID"
- at: "Proof first, then link"
note: "Proof first, then link" Common mistake: merging by name
- Two customers called Ahmed share one memory
- One Ahmed sees the other's order or invoice
- That's a privacy leak, not a small bug
- Link only on verified phone, email or code
graph: {directed: true, arrange: circle, edges: [["Ahmed one", "Name", "display name"], ["Ahmed two", "Name", "display name"]]}
steps:
- at: "the trap that bites small businesses"
note: "The trap: merging by name"
- at: "links accounts by display name"
show: Name
- at: "Ahmed one orders a gift box"
show: "Ahmed one"
- at: "Ahmed two writes on Telegram"
show: "Ahmed two"
- at: "the agent cheerfully tells"
highlight: "Ahmed two"
note: "Ahmed two sees Ahmed one's order"
- at: "a real privacy leak"
highlight: Name
note: "A real privacy leak"
- at: "Names, profile photos and similar spellings"
note: "A name is never proof"
- at: "Link only when a phone number"
note: "Link on proof only"
- at: "keep them separate"
note: "When in doubt, keep them separate"
- at: "a leaked invoice"
note: "A repeated question costs less" Recap
- Memory is filed by customer ID, never by chat ID
- One router: normalize, load memory, reply on the same channel
- Link new accounts only with proof, never by name
- Keep recent chat short, keep facts on a file card
tree:
Memory:
Customer ID:
One router:
Proof first:
Short-term chat:
start: none
steps:
- at: "Let's wrap up"
note: "Four things to remember"
- at: "file memory under your own customer ID"
show: [Memory, Customer ID]
- at: "through one router"
show: "One router"
- at: "link accounts only with proof"
show: "Proof first"
- at: "keep short-term chat separate"
show: "Short-term chat"
- at: "With one notebook behind every door"
highlight: Memory Your exercise
- Make a customers table: id, WhatsApp, Telegram, email, booking
- Add your own row with both IDs, or build the phone-share step
- Route both triggers into one workflow with a lookup step
- Set the agent's memory key to the customer ID
- Add a step that writes booking changes to the table
- Test: book on WhatsApp, change it on Telegram
tree:
Your turn: [Customers table, Add your row, Both triggers, Memory session key, Booking column, Test it]
start: none
steps:
- at: "Now it's your turn"
show: "Your turn"
- at: "Create a customers table"
show: "Customers table"
- at: "Add a row for yourself"
show: "Add your row"
- at: "point both the WhatsApp"
show: "Both triggers"
- at: "Set your agent's memory session key"
show: "Memory session key"
- at: "writes to the booking column"
show: "Booking column"
- at: "test it with your phone"
show: "Test it"
- at: "you're ready for MCP next lesson"
note: "Ready for MCP next lesson" النص المكتوب
The shop with amnesia. Picture Sara, who sells handmade candles online. On Monday, a customer called Omar messages her shop on WhatsApp and books a pickup for Tuesday at three. On Tuesday morning he opens Telegram, because that's where he follows the shop, and wants to move the pickup. Sara's Telegram bot answers: hi there, how can I help? Then it asks for your name again, as if it had never met him. To Omar, it feels like one shop that suddenly lost its memory. He told the shop everything yesterday. In this lesson we fix that, so every channel talks to one brain that remembers each person, whichever app they use.
What you will learn. Here's the checklist for today. First, you'll see why building one bot per channel quietly creates three strangers who never share notes. Second, you'll learn the key idea of the whole lesson: one customer ID that links a WhatsApp number, a Telegram account and a web login to the same person. Third, you'll learn how to store memory in one place, load it before every reply, and link new accounts without mixing people up. You already have a WhatsApp agent and a Telegram bot from the last lessons, so we're wiring together pieces you've built.
Three bots, three brains. Let's see why it breaks. An agent's memory is simply saved notes, past messages and facts, that the agent reads before it answers, like a shop assistant glancing at the order book. When you build each channel as its own workflow, the WhatsApp bot keeps its own notebook, the Telegram bot keeps another, and the web bot keeps a third. Each notebook is filed under that app's chat ID, the number the app gives a conversation. So what does the Telegram bot know about a booking made on WhatsApp? Nothing at all. Same person, three folders, zero shared facts.
One brain, many doors. Here's the better design. Think of your shop with three front doors: WhatsApp, Telegram and the chat box on your website. Every message passes through one router, a small step in your workflow that works out who is talking and which app they used. Then it calls one agent, and that agent reads and writes one shared memory. Watch a message from Telegram. The router turns the sender into customer C zero four two, the agent loads that customer's history, writes a reply, and the router sends it back out through Telegram. One brain, and every door leads to it.
The identity key. The trick is a small lookup table, often called identity linking. You won't type this code; it just shows the lookup your sheet will do. Each row pairs a channel and that channel's sender ID with your own customer ID. Omar's WhatsApp number and his Telegram ID both point to C zero four two. Memory is then filed under the customer ID, never under the chat ID. When we ask about the WhatsApp number, we get Omar and his Tuesday booking. Ask about the Telegram ID, and it's the same Omar, same booking. An unknown Telegram user gets "new contact". In n8n or Make, the no-code automation tools you've been using, this table is just a Google Sheet, Airtable or database table.
Every message, the same path. Every message, from any app, now walks the same path. First it arrives. Then we normalize it, which just means converting it into one standard shape: channel, sender ID, text, and time. It's like copying orders from three different paper forms onto your own order slip, so the rest of the shop only reads one format. Next we find the customer ID in the lookup table and load that customer's memory. The agent writes its reply, and finally we send it back on the same channel, keeping the channel name from step one so nothing goes out the wrong door.
Two kinds of memory. Not all memory is the same, so let's sort it into two piles. Short-term memory is the recent conversation, like sticky notes on your desk. Long-term memory is the customer's file card: name, current booking, whether they're a hot lead, any unpaid invoice. Why split them? A language model has a context window, the amount of text it can read in one go, like the size of a desk. Pile every old message on it and replies get slower, pricier and confused. So keep the last ten or so messages, summarize older ones into a line or two, and update the file card whenever a fact changes.
Worked example: Omar moves his pickup. Let's follow Omar. On Monday he's in a cafe and texts the shop on WhatsApp: can I pick up my order Tuesday at three? The router finds C zero four two, the agent saves the booking on his file card and confirms. On Tuesday he's at home on his laptop and writes on Telegram: can I move it to Wednesday morning? The router looks up his Telegram ID, finds the same customer ID, and opens the same notebook. The agent already knows his name and his booking, checks the shop's free slots, and asks: Wednesday at eleven works, shall I book it? Omar says yes, and the agent updates his file card and sends a new confirmation. No questions repeated.
Linking a new account safely. But how did Omar's Telegram ID get into the table in the first place? On his first Telegram message, the router found no match. So the bot asked him to share his phone number, which Telegram allows with a one-tap contact button. One small detail: apps write numbers differently, with or without the plus sign or the country code, so first rewrite every number in one format, plus sign and country code, then compare. The number matched his WhatsApp row, so we added the Telegram ID to C zero four two. On your website, the same job is done by a login, or by emailing a one-time code. If nothing matches, create a fresh customer ID and treat them as a new lead. Proof first, then link.
Common mistake: merging by name. Here's the trap that bites small businesses. Two customers called Ahmed share one memory. To save effort, someone links accounts by display name. Then Ahmed one orders a gift box of candles on WhatsApp, Ahmed two writes on Telegram, and the agent cheerfully tells Ahmed two about Ahmed one's order, or reads out his unpaid invoice. That's a real privacy leak, and in many countries a legal problem. Names, profile photos and similar spellings are never proof. Link only when a phone number, email or one-time code matches. When in doubt, keep them separate; a repeated question costs far less than a leaked invoice.
Recap. Let's wrap up. First, file memory under your own customer ID, never under each app's chat ID, so one person stays one person. Second, send every channel through one router to one agent, normalize the message, load memory, and reply on the same channel. Third, link accounts only with proof, like a shared phone number or a one-time code. And fourth, keep short-term chat separate from the long-term file card. With one notebook behind every door, your customers feel remembered everywhere, which is exactly what keeps them coming back.
Your exercise. Now it's your turn, and it's simple. Create a customers table in Google Sheets or Airtable with columns for ID, WhatsApp, Telegram, email and booking. Add a row for yourself with your WhatsApp number and your Telegram ID under one customer ID, or, for an extra challenge, build the share-your-phone-number step from earlier. In your tool, point both the WhatsApp and Telegram triggers into one workflow, add a normalize step, then a lookup step on that table. Set your agent's memory session key to the customer ID instead of the chat ID. Add a step, or give the agent a tool, that writes to the booking column whenever a booking changes. Finally, test it with your phone: book a slot on WhatsApp, and change it on Telegram. If the agent remembers you, you're ready for MCP next lesson.
استكشف الرسوم المتحركة
الرسوم المتحركة نفسها التي في الفيديو، دقيقة وتفاعلية: شغّلها أو أوقفها، أو اسحب المؤشر، أو انتقل إلى أي خطوة بالسرعة التي تناسبك.
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
أجب عن كل الأسئلة ثم تحقّق. تنجح بنسبة 70%، ويمكنك إعادة المحاولة كما تشاء.
ملخص الدرس
- القراءة
- مشاهدة الفيديو
- اجتياز الاختبار (70%)
- Memory is filed by customer ID, never by chat ID
- One router: normalize, load memory, reply on the same channel
- Link new accounts only with proof, never by name
- Keep recent chat short, keep facts on a file card