AI Automation & Agents for Small BusinessMessaging and voice channels · Lesson 11 of 16

WhatsApp and messaging agents that follow the rules

Article · 14 min · 9 min lecture

Video lecture

WhatsApp and messaging agents that follow the rules

15 chapters · about 9 min · full transcript

Coming soon

Chapter 1 of 15

WhatsApp and messaging agents

  • Where customers already are
  • Platform rules that shape automation
  • Designing a compliant agent

The narrated lecture is in production

Every chapter is scripted and ready. Browse the chapters and read the full transcript now — the video will appear here when it’s published.

Chapters

Why messaging channels are different

For many customers in Pakistan, the UAE, Saudi Arabia and beyond, WhatsApp is the default way to talk to a business; Instagram and Facebook DMs are close behind for brands and creators. Automating these channels can transform response times, but they come with platform rules that email does not: opt-in requirements, message windows, pre-approved templates and policies about what kind of AI may run on them. Breaking them can get your number or account restricted.

WhatsApp: app vs platform

  • WhatsApp Business app: for small teams replying by hand on a phone or desktop, with simple quick replies, labels and away messages. Not built for AI automation at scale.
  • WhatsApp Business Platform (Cloud API): programmatic access for automations and agents, usually through Meta directly or a Business Solution Provider (BSP) or messaging platform. This is what automation tools and AI agent platforms connect to.

The rules that shape every WhatsApp automation (check Meta's current policies)

  1. Opt-in: you need the person's permission to message them on WhatsApp, collected clearly (for example a checkbox on your form or a click-to-WhatsApp ad they started).
  2. The customer service window: when a customer messages you, you can reply with free-form messages (including AI-generated ones) for 24 hours from their last message.
  3. Templates outside the window: to start a conversation or message after the window closes, you must use a pre-approved message template (categorised as marketing, utility or authentication). Pricing is per template message, varying by category and country; check Meta's current pricing.
  4. Quality and blocks: if many people block or report your messages, your number's quality rating and limits can drop.
  5. AI policy: since January 2026, Meta's WhatsApp Business terms prohibit general-purpose AI assistants as the primary service offered through the Business Platform. Business-specific AI (support, bookings, order tracking, lead qualification, sales) remains allowed. Your agent should stay on your business's topics.
  6. Human hand-off: always offer a way to reach a person; it is good practice and customers expect it.

Instagram and Facebook Messenger automation through Meta's APIs has similar concepts (a messaging window after the user's last message, restrictions on unsolicited messages). Never auto-DM people who have not contacted you.

Designing a WhatsApp agent

DecisionRecommendation
ScopeBusiness-specific: FAQs, bookings, order status, lead capture
First messageGreet, say it's an AI assistant, say what it can help with, offer "type AGENT for a person"
LanguageDetect and reply in the customer's language (English, Arabic, Urdu, Roman Urdu)
LengthShort messages; use lists and quick-reply buttons where your platform supports them
MediaVoice notes: transcribe and confirm understanding; images: only if your flow handles them safely
Hand-offComplaints, payments, anything sensitive, or on request: route to a human inbox with the transcript
Window logicTrack the 24-hour window; outside it, only approved templates
Consent recordsStore when and how opt-in happened; honour STOP / opt-out immediately

Worked example: a Lahore fashion brand

A modest-fashion brand receives hundreds of WhatsApp messages a day during sales. They connect the WhatsApp Business Platform via a messaging provider to an AI agent limited to: size guidance, delivery times by city, order status (via an order-lookup tool), exchange policy and taking custom-order requests. Complaints and payment issues go to a human inbox. Outside the 24-hour window, the only outbound messages are approved utility templates ("Your order has shipped") and marketing templates sent only to customers who opted in. Response times fall from hours to seconds for routine questions, and the team spends its time on complaints and custom orders.

Hands-on: window-aware replies and a template send

1. Window logic (pseudo-production Python you can adapt in a Code step or small service):

from datetime import datetime, timedelta, timezone

WINDOW = timedelta(hours=24)

def can_send_freeform(last_customer_message_at: datetime) -> bool:
    return datetime.now(timezone.utc) - last_customer_message_at < WINDOW

def choose_message(contact, ai_reply_text):
    if contact["opted_out"]:
        return None                                              # never message opted-out contacts
    if can_send_freeform(contact["last_inbound_at"]):
        return {"type": "text", "text": {"body": ai_reply_text}}
    if contact["opt_in_utility"]:
        return {"type": "template", "template": {"name": "order_update", "language": {"code": contact["lang"]},
                "components": [{"type": "body", "parameters": [{"type": "text", "text": contact["order_id"]}]}]}}
    return None                                                  # no permitted way to message; do nothing

2. Sending an approved template with the Cloud API (token in an environment variable; check Meta's docs for the current API version):

curl -X POST "https://graph.facebook.com/${GRAPH_API_VERSION}/${PHONE_NUMBER_ID}/messages" \
  -H "Authorization: Bearer ${WHATSAPP_TOKEN}" -H "Content-Type: application/json" \
  -d '{"messaging_product": "whatsapp", "to": "923001234567", "type": "template",
       "template": {"name": "order_update", "language": {"code": "en"},
                    "components": [{"type": "body", "parameters": [{"type": "text", "text": "A20931"}]}]}}'

3. The agent's opening message:

Assalam-o-alaikum! I'm Zara, the AI assistant for [Brand]. I can help with sizes, delivery times,
order status and exchanges. Type AGENT any time to chat with our team.

Most messaging platforms and BSPs handle window tracking and templates in their UI; the logic above is what they are doing, and what you must respect if you build directly.

Key takeaways

  • Use the WhatsApp Business Platform (Cloud API), usually via a provider, for automation; the Business app is for manual use.
  • Respect opt-in, the 24-hour customer service window and approved templates outside it; honour opt-outs immediately.
  • Since January 2026, general-purpose AI assistants are prohibited as the primary service on the Business Platform; business-specific AI is allowed.
  • Design agents with AI disclosure, language matching, short messages, window logic and easy human hand-off.

Check your understanding

Quick questions to lock in the lesson. They don’t count towards your certificate.

  1. A customer messaged you 30 hours ago and you want to send an AI-written follow-up. What is allowed?
  2. Which WhatsApp agent is consistent with Meta’s 2026 business AI policy?
  3. What should happen when a customer replies STOP?

Put it into practice

Design a WhatsApp (or Instagram DM) agent for your business: scope, opening message, hand-off triggers, window logic and two templates you would submit for approval.

Enrol for free to save your progress

Reading is always free. Enrol to keep your place, take the final assessment and earn a verifiable certificate.