How to Build a WhatsApp AI Chatbot for Your Business
The honest build path: WhatsApp Business API access, an LLM behind it, and the guardrails that keep it from going off-script. What it costs and where it breaks.

If you’re looking to build a WhatsApp AI chatbot for business, skip the no-code circus. The real path — the one that handles Arabic sales conversations, human hand-offs, and bulk campaigns without getting your number banned — is wiring the WhatsApp Business API to a large language model and putting blunt guardrails around it. This guide walks through exactly that stack, pulled from a live system we built called Chatberry, an Arabic‑first WhatsApp marketing platform that combined GPT, webhooks, queues, and a multi‑agent shared inbox.
What a WhatsApp AI Chatbot for Business Actually Takes
The answer isn’t a chatbot builder. It’s three things: a verified WhatsApp Business Account, an LLM behind a controlled API endpoint, and a webhook-driven middleware that decides when the AI speaks, when a human jumps in, and how not to get flagged as spam.
Before a single line of AI code, you need:
- A Meta Business Account (verified).
- A phone number that can receive calls or SMS — this becomes the bot’s WhatsApp number.
- Access to the WhatsApp Business Cloud API (the hosted version, not the deprecated on‑premise API).
- A webhook endpoint that can handle incoming messages, send replies, and manage media IDs.
These are the table stakes. Without them, you’re building a demo, not a business tool.
The Architecture That Stops Your Bot Going Off‑Script
The biggest risk with an LLM on a public WhatsApp line isn’t bland replies — it’s hallucination that makes your brand look deranged. The fix is an architecture where the AI only talks inside a scaffold you define. Here’s how we built Chatberry to keep it nailed down.
Takeaway: Route every user message through a rules engine before it reaches the LLM, and sandwich the AI’s output with post‑processing that rejects anything outside approved boundaries.
// Example: Pre‑filter before handing to GPT
const isFAQ = fastMatch(message.body, FAQ_TRIGGERS);
if (isFAQ) {
return replyWithApprovedTemplate(isFAQ); // lock tight replies
}
// If unknown, pass to AI with a strict system prompt
const response = await openai.chat.completions.create({
model: "gpt-4",
messages: [
{ role: "system", content: `You are a support agent for ACME Corp. Only answer about product A and shipping to KSA. Never invent policies, prices, or offers. If you don't know, say "Let me connect you to a specialist."` },
{ role: "user", content: message.body },
],
temperature: 0.1,
});But prompts alone aren’t enough. Chatberry layered on a retry‑and‑fallback queue: if the AI’s output contained a forbidden phrase (like a hallucinated price), the message never sent — instead, the ticket flagged a human in the shared inbox.
Building a Multi‑Agent Inbox So Your Team Doesn’t Feel Replaced
An AI‑first WhatsApp line scares support teams. They worry the bot will fire off nonsense and bury real leads. The answer isn’t a better prompt — it’s a multi‑agent shared inbox that lets humans see what the bot said and take over silently.
In Chatberry, every incoming message — whether answered by AI or not — landed in a queue visible to all agents. The bot could hand off mid‑conversation via an internal command (++human) that triggered a webhook to reassign the thread to a live person, without the customer ever noticing.
sequenceDiagram
Customer->>WhatsApp Cloud API: Message
API->>Webhook (Next.js): Incoming webhook
Webhook->>Rules Engine: Match intent
Rules Engine->>GPT Agent: If AI route
GPT Agent-->>Rules Engine: Response + confidence
alt confidence low or handoff requested
Rules Engine->>Queue: Assign to human
Human->>WhatsApp API: Reply from dashboard
else AI replies
Rules Engine->>WhatsApp API: Send AI message
endThis architecture is what separates a toy from something you can run a sales team on. If you’d rather not build it from scratch, our WhatsApp AI agent service delivers exactly this — a production‑ready bot that plugs into your Meta app and hands off seamlessly.
Automating Marketing Flows Without Getting Banned
Bulk messaging over WhatsApp is a minefield. Meta imposes strict template approval and a 24‑hour customer‑initiated window. The bots that survive use interactive buttons and rule‑based reply automations to keep engagement within policy, while pushing campaigns only when a user has actively opted in.
Chatberry was built to send official WhatsApp marketing blasts to opted‑in lists, but every broadcast had to pass through Meta’s template review. The system matched the right template to the right user segment, then triggered sends only after a human‑approved drip logic. The takeaway: never script‑blast from a service number; always use pre‑approved messages and only after a qualifying inbound message or explicit opt‑in.
For AI‑driven flows, the trick is to treat every outbound as a reaction to an inbound trigger. If a customer messages “price,” the AI can reply with a button template that asks “New order or existing one?” — both safe, templated, and highly effective for conversion.
How Much This Costs and Where It Breaks
The budget‑killer isn’t the LLM — it’s the WhatsApp conversation charges. Meta bills per 24‑hour conversation (roughly $0.005–$0.10 depending on region and message type). A high‑volume sales bot can easily rack up thousands of conversations monthly before you even account for AI tokens.
From building Chatberry, the real cost drivers were:
- API conversation fees — the biggest line item.
- LLM inference — manageable when using GPT‑4‑mini for straightforward Q&A and a caching layer. Full GPT‑4 for every message is wasteful.
- Middleware infrastructure — the Next.js server, queue (BullMQ/Redis), and database for conversation state. If traffic spikes, the queue size and monitoring become a pain point.
- Template review delays — marketing campaigns stall waiting for Meta’s approval, which can take hours.
Where it breaks: when someone sends a voice note. The Cloud API returns a media ID, but speech‑to‑text isn’t built in. You need an external service to transcribe it before the LLM can even touch it — a gap most tutorials ignore.
Why We Built Chatberry This Way — and Why It Works
Chatberry wasn’t a theory. It was a full Arabic‑first marketing toolkit: AI chatbot, bulk official‑WhatsApp messaging, multi‑agent shared inbox, interactive buttons, and RTL‑ready UI — all running on a Next.js frontend, WhatsApp Business Cloud API, OpenAI GPT, and webhook/queue workflows. We documented the build in detail here: Chatberry case study.
The lesson? A WhatsApp AI chatbot for business is a systems‑integration job, not a plugin installation. When you get the guardrails, the inbox, and the marketing flows right, it becomes the highest‑converting channel you own. If you want that without the 6‑month build cycle, talk to us — we do exactly this.
FAQ
Can I use a free WhatsApp account with an AI chatbot?
No. A personal WhatsApp account has no official API and will be banned the moment you automate anything beyond the click‑to‑chat link. You need a WhatsApp Business API account, which requires a Meta business verification and a dedicated phone number.
How do I keep the AI from making up prices or policies?
Combine a strict system prompt with a post‑processing validation layer. In Chatberry, we rejected any AI‑generated message that contained dollar amounts or policy language unless the message matched an approved list. When in doubt, the system hands off to a human agent automatically.
What are the ongoing costs for a WhatsApp AI bot?
The two ongoing costs are Meta’s per‑conversation charges (you pay for each 24‑hour window a customer initiates with your bot) and the LLM API usage. Infrastructure and human‑review overhead add more. We recommend starting with a small‑scale pilot and tracking cost‑per‑conversation before scaling.