الدرس 1 · الوحدة 5: Omnichannel Integration: WhatsApp, Telegram and MCP
Setting up the official WhatsApp Business Cloud API and message templates
الفيديو قريبًا
Learn it with your tutor on the live board
أهم نقاط الفيديو
Your phone is not a platform
- Customers already live on WhatsApp
- Bookings, prices and invoices arrive as chats
- The Business app on a phone cannot talk to an agent
- The official door is the Cloud API
What you will learn
- Set up a Meta app with a WhatsApp test number
- Collect the three values every automation needs
- Create message templates and know when you must use them
App versus API
- Business app: one person replying by hand
- API: software sends and receives
- Cloud API is hosted by Meta, no servers to run
- Simplest start: a fresh number for the API
The setup path
- Meta Business account (your company's profile)
- Developer app at developers.facebook.com
- Add the WhatsApp product to the app
- Use the free test number, add your phone as a recipient
- Send the hello world test message
Three values to copy
- Phone number ID: which number sends
- WhatsApp Business Account ID: where templates live
- Access token: your password for the API
- The temporary token expires after 24 hours
How one message travels
- Your agent calls the Graph API
- WhatsApp delivers to the customer
- Replies come back through a webhook
layout: side
direction: TB
components:
agent: {kind: service, label: Your agent}
graph: {kind: api, label: Graph API}
wa: {kind: cloud, label: WhatsApp Cloud}
cust: {kind: user, label: Customer}
hook: {kind: function, label: Webhook}
links: [agent->graph, graph->wa, wa->cust, wa->hook, hook->agent]
steps:
- at: "five pieces work together"
show: all
- at: "sends a booking reminder"
flow: ["agent>graph: POST messages", "graph>wa", "wa>cust: reminder"]
- at: "the customer answers yes"
flow: ["cust>wa: YES", "wa>hook: event", "hook>agent"]
highlight: [hook] The 24-hour window
- A customer message opens a 24-hour window
- Inside it: free-form replies, any text or media
- Outside it: only approved templates
- Each new customer message resets the clock
Message templates
- Pre-written messages Meta reviews before use
- Categories: marketing, utility, authentication
- Placeholders like {{1}} fill in per customer
- Utility = order updates, reminders, invoices
Worked example: a booking reminder
import json
TEXT = ("Hi {{1}}, your cake tasting is on {{2}}"
" at {{3}}. Reply YES to confirm.")
values = ["Mona", "Tuesday", "3 pm"]
preview = TEXT
for i, v in enumerate(values, start=1):
preview = preview.replace("{{%d}}" % i, v)
payload = {
"messaging_product": "whatsapp",
"to": "201001234567",
"type": "template",
"template": {
"name": "tasting_reminder",
"language": {"code": "en_US"},
"components": [{"type": "body", "parameters": [
{"type": "text", "text": v} for v in values]}],
},
}
print("Customer sees:", preview)
print(json.dumps(payload["template"]["components"])) Common mistake: building on sand
- The 24-hour token dies overnight
- Fix: a system user with a permanent token
- Promotions hidden in utility templates get recategorised
- Free text to cold leads fails outside the window
Recap
- The Cloud API is WhatsApp's door for software
- Keep three values: phone number ID, WABA ID, a system user token
- Outside the 24-hour window, only templates work
Your exercise
- Create a developer app and add WhatsApp
- Send hello world from the test number to your phone
- Submit one utility template with two placeholders
- Note your three values in a password manager
النص المكتوب
Your phone is not a platform. Meet Sara. She runs a small online cake shop, and every evening her phone buzzes nonstop. Customers ask about prices, book tasting appointments and chase their invoices, all on WhatsApp. She uses the free WhatsApp Business app, so every reply depends on her thumbs, and the pile of orders keeps growing. So what happens when she wants an AI agent to answer for her? The phone app has no door that software can walk through. The official door is the WhatsApp Business Cloud API, run by Meta. In this lesson we'll open that door properly, so the owner can finally hand the routine messages to an agent.
What you will learn. Here's the plan for the next few minutes. First, you'll set up a Meta developer app and get a free test number for WhatsApp, which takes about fifteen minutes the first time. Second, you'll collect the three values that every automation tool, from n8n to Make to your own code, will ask you for. Third, you'll learn about message templates: what they are, why Meta insists on them, and the one rule that decides when you can send a normal message and when you need a template. Get these right now, and the rest of this module builds on solid ground.
App versus API. Let's compare the two ways a business can use WhatsApp. On the left is the app, the WhatsApp Business app on your phone. It's great for one person replying by hand, with labels and quick replies, but nothing outside the phone can read or send messages through it. On the right is the API, which stands for application programming interface. Think of it as a service window at the back of the shop: instead of a person tapping a screen, your software hands over a request and gets a reply. The Cloud API is hosted by Meta, so you don't run any WhatsApp servers yourself. Usually a number is used by one or the other, so the simplest start is a fresh number for the API. Meta now also offers a coexistence option for some existing app numbers.
The setup path. Let's walk the setup path slowly, one box at a time. First, you need a Meta Business account, which is simply your company's profile inside Meta. Next, go to the Meta developers site, create an app, and pick the WhatsApp or Business option when Meta asks what the app is for. Inside that app, add the WhatsApp product. Meta then gives you a free test number straight away, so you can experiment before registering your real one. On the same screen, add your own phone as an allowed recipient; the test number can only message up to five verified numbers. Send yourself the sample hello world message, and if it lands on your phone, the pipe works.
Three values to copy. On the API setup page you'll find three values. Copy them somewhere safe, because every tool in this course asks for them. The phone number ID says which of your numbers is sending; note that it's a long ID, not the phone number itself. The WhatsApp Business Account ID, often shortened to WABA ID, is the account where your templates and numbers live. And the access token is like a password that proves your software is allowed to send. The token shown on that page is temporary and stops working after 24 hours. That's fine for testing today, and we'll fix it for production later in this lesson.
How one message travels. Here's the whole picture, and five pieces work together. Your agent, which could be an n8n workflow or a Python script, sends a booking reminder by making a request to Meta's Graph API, the web address that handles all Meta services. The Graph API passes it to WhatsApp, which delivers it to the customer's phone. Now the customer answers yes. That reply travels the other way: WhatsApp calls your webhook, which is a web address you own that Meta pings whenever something happens, like a doorbell for your software. The webhook hands the message to your agent. Sending is this lesson; receiving through the webhook is the next one.
The 24-hour window. This is the rule that shapes everything. When a customer messages you, a 24-hour customer service window opens, like a clock starting on the wall. Inside that window your agent can send any reply it likes: free text, images, a PDF invoice. Once the window closes, you can't send free-form messages anymore. The only way to start or restart a conversation is with a pre-approved message template. Every new message from the customer resets the clock. So if a lead asked about wedding cakes on Monday and you want to follow up on Friday, that follow-up must be a template, no matter how friendly your agent's reply would be.
Message templates. A message template is a pre-written message that Meta reviews before you're allowed to use it. Think of a printed form with blanks: the text is fixed, and placeholders, written as one inside double curly braces, two, three and so on, get filled with each customer's name, date or amount. You create templates in WhatsApp Manager, the part of your Meta Business settings where your numbers and templates are managed, and pick a category. Marketing is for promotions. Utility is for things the customer expects, like booking reminders, order updates and invoices. Authentication is for one-time login codes. Meta charges per template message, with prices that depend on category and country. Utility is usually cheaper than marketing, and a utility template sent while the 24-hour window is open costs nothing. Approval often takes minutes, sometimes a day.
Worked example: a booking reminder. Let's build a real utility template for Sara's shop: a tasting reminder with three placeholders, the name, the day and the time. The loop shows what the customer will actually see by swapping each numbered placeholder for its value. Below that is the payload, the package of data your agent sends to Meta. Notice you don't send the template text itself; you send its name, its language and the values in order. Run it, and the first line prints: Customer sees: Hi Mona, your cake tasting is on Tuesday at 3 pm. Reply YES to confirm. The second line is the list of values that n8n or your code sends with the template name.
Common mistake: building on sand. Here's the mistake that breaks most first projects. Someone builds a lovely workflow with the temporary token, it works all afternoon, and the next morning every message fails with an error. The fix is a system user: in Business Settings, create a system user, give it access to your app and WhatsApp account, and generate a token that doesn't expire. Store it in your tool's credentials, never in plain workflow text. To go live you'll also add your real number, a payment method and verify your business in Business Settings. Two more traps. Sneaking a discount into a utility template gets it recategorised as marketing or rejected. And sending free text to a lead who never wrote to you will simply fail.
Recap. Let's wrap up. First, the WhatsApp Business app on a phone is for people, while the Cloud API is the door your agent uses, hosted by Meta so you run no servers. Second, every automation needs three values: the phone number ID, the WhatsApp Business Account ID and an access token, and for real work that token comes from a system user so it never expires overnight. Third, a customer message opens a 24-hour window for free replies; outside it, only approved templates can reach people. With that, Sara's laptop can do the talking and her phone can finally rest.
Your exercise. Now it's your turn, and it's very doable in one sitting. Create a Meta developer app, add the WhatsApp product and send the hello world message from the test number to your own phone. Then pick a business you know, a salon, a tutor or a small shop, and submit one utility template with two placeholders, for example a booking reminder with a name and a time. Write down your phone number ID, your WhatsApp Business Account ID and your token, and keep them in a password manager. Next lesson, we'll plug those values into an agent that receives, replies and even sends invoices as files.
استكشف الرسم المتحرك
الرسوم المتحركة نفسها التي في الفيديو، دقيقة وتفاعلية: شغّلها أو أوقفها، أو اسحب المؤشر، أو انتقل إلى أي خطوة بالسرعة التي تناسبك.
Loading the animation...
ملخص الدرس
- مشاهدة الفيديو
- The Cloud API is WhatsApp's door for software
- Keep three values: phone number ID, WABA ID, a system user token
- Outside the 24-hour window, only templates work