Home · About · Services · Industries · Projects · Products · Process · Blog · Glossary · FAQ · Contact
WhatsApp Business chatbots: architecture, templates and limits How the WhatsApp Cloud API, message templates, the 24-hour window and opt-in rules shape a business chatbot, with a reference architecture.
A coaching institute in Jaipur gets three hundred WhatsApp messages a day during admissions. Most ask the same things: fees, batch timings, documents, hostel availability. Two staff members answer from their phones. Replies take hours, and nobody can see what was promised to whom. The director asks for "a bot on WhatsApp" and assumes it is a weekend job.
It is not a weekend job, but it is not a large project either. WhatsApp is a regulated channel with its own rules. Meta decides when you may message a user, what you may send outside a conversation, and how you are billed. A good WhatsApp assistant is designed around those rules first and the AI second. Get the channel constraints right and the chatbot part becomes ordinary backend work.
The pieces Meta gives you Businesses reach WhatsApp programmatically through the WhatsApp Business Platform. For new builds, that means the Cloud API, which Meta hosts. You no longer need to run your own WhatsApp server. You need a Meta Business account, a WhatsApp Business Account, a phone number registered to it, and an app in the Meta developer console.
A few points trip people up early:
A number registered on the API cannot be used in the regular WhatsApp or WhatsApp Business phone app at the same time. Plan a dedicated number, or migrate the existing one deliberately. Business verification raises your messaging limits. Unverified accounts start with a low cap on how many unique users you can message in 24 hours. Display name approval is separate. Meta reviews the name shown to users, and it must relate to your business. You can use the Cloud API directly or through a Business Solution Provider such as Gupshup, Interakt or Twilio. A provider adds a dashboard and support, plus a margin on top of Meta’s charges. The 24-hour window and templates This is the rule that shapes everything. When a user messages you, a 24-hour customer service window opens. Inside it, you can send free-form replies: text, images, documents, buttons and lists. Each new message from the user resets the window.
Outside the window, you can only send pre-approved message templates. A template is a fixed message with placeholders, submitted to Meta for review. Meta groups templates into categories: marketing, utility and authentication. Utility covers transactional updates such as an order shipped or an appointment confirmed. Authentication covers one-time passwords. Marketing covers everything promotional.
Two consequences matter for design. First, your bot cannot "follow up later" with an LLM-generated message once the window closes. It must use a template. Second, template category affects price and review. If you submit a promotional message as utility, Meta will reclassify or reject it.
Pricing is set by Meta, varies by country and category, and has changed more than once. Treat any number you read in a blog as stale. Check Meta’s current rate card for India before you estimate running costs, and build cost tracking into the system from day one.
Opt-in and quality rating You need the user’s opt-in before sending them business-initiated messages. The opt-in must make clear they will receive WhatsApp messages from your business. A checkbox on an admission form, worded plainly and stored with a timestamp, is a sensible pattern.
Meta also tracks a quality rating for your number based on user signals such as blocks and reports. Low quality can reduce your messaging limits or pause templates. The practical rules are simple. Message people who asked to hear from you. Make it easy to stop. Do not blast marketing templates to an old spreadsheet of numbers.
Store opt-in and opt-out as first-class data, not as a note in a CRM field. Your sending code should refuse to send a template to anyone without a valid opt-in record.
A reference architecture Here is the shape we usually recommend for a WhatsApp assistant that answers questions and hands over to people.
Webhook receiver: a small HTTPS endpoint that Meta calls for every inbound message and status update. It verifies the signature, writes the event to a queue and returns 200 quickly. Queue: Redis streams, RabbitMQ, SQS or a database-backed job table. Meta retries webhooks that fail or time out, so the receiver must not do slow work inline. Conversation worker: reads events, loads the conversation state, decides what to do and sends replies through the Cloud API. Conversation store: PostgreSQL tables for contacts, conversations, messages, opt-ins and window expiry times. Knowledge layer: if answers come from documents, a retrieval step over your fee structure, prospectus and FAQs, so the model answers from your content. Agent inbox: a simple web screen where staff see live conversations, take over from the bot and reply. Outbound sender: one module that every message goes through, which enforces the window, opt-in and rate limits. Keeping a single outbound sender is the most useful design decision here. It is where you check whether the 24-hour window is open and pick a template if it is not. It also logs every message with its cost category.
Webhook handling in practice Meta signs each webhook payload with your app secret using HMAC SHA-256. Verify it before trusting anything. Also expect duplicates: use the message ID as an idempotency key.
import hmac, hashlib, json
from fastapi import FastAPI, Request, HTTPException
app = FastAPI()
APP_SECRET = b"replace-with-app-secret"
@app.post("/webhooks/whatsapp")
async def receive(request: Request):
body = await request.body()
sig = request.headers.get("X-Hub-Signature-256", "")
expected = "sha256=" + hmac.new(APP_SECRET, body, hashlib.sha256).hexdigest()
if not hmac.compare_digest(sig, expected):
raise HTTPException(status_code=401)
payload = json.loads(body)
for entry in payload.get("entry", []):
for change in entry.get("changes", []):
value = change.get("value", {})
for msg in value.get("messages", []):
await enqueue("wa_inbound", msg["id"], msg)
for status in value.get("statuses", []):
await enqueue("wa_status", status["id"] + status["status"], status)
return {"ok": True}The GET verification handshake, where Meta sends hub.challenge, also needs handling when you register the webhook. Keep it in the same route file so nobody forgets it exists.
Where the LLM fits, and where it should not The model’s job is narrow: understand the question, retrieve the relevant content and draft a reply in the user’s language. Many Indian users mix Hindi and English in one message. Current models handle Hinglish reasonably, but test with real examples from your inbox before launch.
Keep deterministic logic out of the model. Fee amounts, seat availability and application status should come from your database through a lookup, not from the model’s memory. Buttons and list messages are better than free text for structured choices such as picking a course or a campus. They also cut token usage and make analytics easier.
Plan the handover path carefully. The bot should hand over when the user asks for a person or when retrieval finds nothing relevant. It should also hand over on sensitive topics, such as refunds or complaints. When a staff member takes over, the bot must stop replying in that conversation until the agent closes it. Users notice quickly when two voices answer at once.
Finally, watch the window. If a staff member replies 23 hours after the user’s last message, that reply is free-form. One hour later it must be a template. Show the window expiry in the agent inbox so staff are not surprised by a failed send.
Limits worth knowing before you promise anything Messaging limits: new numbers can contact a limited number of unique users per day in business-initiated conversations. The tier rises with verified status and good quality. Throughput: the Cloud API has per-number sending rate limits. Bulk campaigns need throttling on your side. Media: images, PDFs and audio have size limits, and media URLs from Meta expire. Download and store what you need. Templates: review can take minutes or longer, and rejections happen. Keep a small library of approved utility templates for common follow-ups. Groups: the Cloud API is built for one-to-one business conversations. Do not design around WhatsApp groups. Voice notes: users will send them. Decide whether you transcribe them or politely ask for text. A short build checklist Before writing the LLM part, get the plumbing right. The channel rules typically cause more rework than the AI does.
Register a dedicated number and complete business verification early. Write the opt-in wording and store opt-ins with source and timestamp. Build the webhook receiver with signature checks, a queue and idempotency on message IDs. Route every outbound message through one sender that enforces the window and opt-in. Draft and submit three to five utility templates before launch. Build the agent inbox and the handover rules before the bot answers anything. Track cost per conversation category from day one, using Meta’s current rate card. Pilot with one department or one campus, read the transcripts weekly, then widen. A WhatsApp assistant built this way is predictable to run. The model can change later. The channel rules, the opt-in data and the handover flow are what keep the number in good standing.
Infigini IT Services · GSTIN 05AAIFI1118B1Z3 · 11 Shree Ram Puram Lane No.2, Kanwali Road, Dehradun, Uttarakhand 248001, India · info@infigini.com · +91 95684 87789 · LinkedIn