1. What you need before you start
To build a chatbot on the official route you need a Meta business account, a WhatsApp Business Platform app with a phone number registered to it, and access to the Cloud API. Business verification may be required to unlock higher limits, so start the paperwork early.
Apart from WhatsApp, you need somewhere to run the logic, such as n8n, a language model API key and a place to keep the knowledge the bot should answer from, like your FAQs, price lists and policies. Decide up front what the bot is allowed to do and what it must always hand to a person.
2. How the pieces fit together
The flow is straightforward. A customer messages your number. WhatsApp sends the message to a webhook URL you control. Your workflow reads it, looks up the conversation history, asks the AI to draft a reply using your knowledge, applies your rules and sends the reply back through the Cloud API.
n8n has a WhatsApp Business Cloud node and a trigger for incoming messages, so much of this can be built visually. The parts that need care are the rules around the AI, the memory of the conversation and what happens when something goes wrong.
3. Receiving messages
Meta verifies your webhook once by sending a request with a challenge value. Your endpoint must echo it back when the verify token matches. n8n's trigger handles this for you, but it helps to know what is happening, and the snippet shows the idea if you build the endpoint yourself.
After verification, incoming messages arrive as JSON. Always acknowledge quickly with a success response and process the message afterwards, otherwise WhatsApp may retry and you will see duplicates. Store each message ID so you can ignore repeats.
// Express example: Meta calls this once to verify your webhook URL
app.get('/webhook', (req, res) => {
const mode = req.query['hub.mode'];
const token = req.query['hub.verify_token'];
const challenge = req.query['hub.challenge'];
if (mode === 'subscribe' && token === process.env.VERIFY_TOKEN) {
return res.status(200).send(challenge);
}
return res.sendStatus(403);
});4. The 24-hour window and templates
WhatsApp limits how businesses can message customers. When a customer messages you, a customer service window opens, and within roughly 24 hours of their last message you can reply with free-form text. Outside that window you can only start a conversation with a pre-approved message template.
This shapes the design. Reminders, order updates and follow-ups usually need approved templates, so write and submit them early. The chatbot itself mostly works inside the window, replying to people who have just written. Check Meta's current policies and pricing, since both change from time to time.
5. Writing the AI reply safely
Do not let the model answer from general knowledge. Give it your documents and instruct it to answer only from them, and to say it does not know when the answer is missing. This approach, often called retrieval-augmented generation, is the main defence against made-up answers.
Add guardrails in the workflow, not only in the prompt:
• Keep the reply short and in the customer's language
• Never ask for card numbers, passwords or one-time codes; send a secure payment link instead
• Block actions the bot should not take, such as refunds or price changes, and hand those to a person
• Log every message and answer so you can review and improve them
Keep conversation memory limited to the last few messages plus a short summary, to control cost and avoid confusing the model.
6. Handing over to a person
A chatbot earns trust by knowing its limits. Define triggers for handover: the customer asks for a human, the question is outside the knowledge base, the sentiment is angry, or the topic is sensitive. When a trigger fires, tell the customer a person will reply, alert your team with the conversation attached and stop the bot from answering that thread until someone resolves it.
Make sure the person has the full context so the customer never has to repeat themselves.
7. Testing, compliance and launch
Test with real questions from your inbox, including awkward, misspelled and off-topic ones, and in every language your customers use. Review the logs after the first days and tighten the knowledge base where the bot hesitated.
Respect WhatsApp's business policy and local privacy rules: get opt-in before sending messages, state clearly that customers are talking to an automated assistant, and offer a way to reach a person. If you would rather not build and run all this yourself, a done-for-you service can configure the whole thing for you, which is the idea behind our Clientager product.