How to Build a WhatsApp Bot for Business in 2026
WhatsApp is where your customers already are. In most of Asia, the Middle East, Latin America, and CIS countries, WhatsApp is the primary communication channel — not email, not live chat on your website. A WhatsApp bot means you're meeting customers where they actually spend time.
Here's how to build one that works.
What WhatsApp Bots Are Actually Good At
Before architecture: use cases where WhatsApp bots genuinely outperform alternatives.
Order status and tracking. Customer texts "where is my order?" — bot pulls from your order management system and replies in 3 seconds. No human needed.
Appointment booking. Show available slots, confirm booking, send reminders. Reduces no-shows by 30-40% in most deployments because WhatsApp reminders actually get read.
Lead qualification. Someone clicks your ad, lands on WhatsApp. Bot asks 3-4 qualifying questions, scores the lead, routes hot leads to sales immediately and cold leads to a nurture sequence.
FAQ deflection. 60-70% of support tickets at most businesses are the same 10 questions. A bot handles these instantly, 24/7.
Payment notifications and receipts. Send payment confirmations, invoice links, and receipts via WhatsApp. Open rates are 90%+ vs 20% for email.
The WhatsApp API Landscape in 2026
You have two access paths:
WhatsApp Business API (via Meta)
The official route. You apply through Meta's Business Manager, get approved (takes 1-5 business days for established businesses), and connect to the API via a cloud provider.
Meta's Cloud API — free to use (you pay per conversation, not per message). Easiest setup. 1,000 free conversations/month, then $0.01-0.08 per conversation depending on country.
On-premises API — deprecated by Meta but some providers still run it. Avoid for new projects.
BSPs (Business Solution Providers)
Companies like Twilio, 360dialog, Vonage, and WATI sit between you and Meta's API. They handle the technical complexity, provide dashboards, and often include a no-code bot builder.
Use a BSP if: you want to move fast and don't have backend engineering resources. Go direct to Meta Cloud API if: you're building a custom integration and want the lowest cost.
Architecture for a Custom WhatsApp Bot
User → WhatsApp → Meta Cloud API → Your Webhook
↓
Bot Logic (Node.js / Python)
↓
[NLP / LLM if needed]
↓
[Your Systems: CRM, Orders, DB]
↓
Reply via Meta Cloud API → User
Step 1: Set Up Meta Cloud API
- Create a Meta Business account at business.facebook.com
- Create a WhatsApp Business App in the Meta Developer Portal
- Add a phone number (test number available immediately; production number requires business verification)
- Get your
WHATSAPP_TOKENandPHONE_NUMBER_ID
Step 2: Build the Webhook
Meta sends all incoming messages to a webhook URL you register. The webhook must:
- Respond to GET verification requests (Meta checks it's live)
- Handle POST requests with message payloads
// Express.js webhook handler
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) {
res.status(200).send(challenge);
} else {
res.sendStatus(403);
}
});
app.post('/webhook', async (req, res) => {
const body = req.body;
if (body.object === 'whatsapp_business_account') {
const messages = body.entry?.[0]?.changes?.[0]?.value?.messages;
if (messages?.[0]) {
await handleMessage(messages[0]);
}
}
res.sendStatus(200); // Always 200 quickly, or Meta will retry
});
Step 3: Handle Message Types
WhatsApp supports text, images, audio, video, documents, location, and interactive messages (buttons, lists).
async function handleMessage(message) {
const from = message.from; // User's phone number
const type = message.type;
if (type === 'text') {
const text = message.text.body.toLowerCase();
await processTextMessage(from, text);
} else if (type === 'interactive') {
const reply = message.interactive.button_reply || message.interactive.list_reply;
await processButtonReply(from, reply.id);
}
}
Step 4: Send Replies
async function sendMessage(to, text) {
await fetch(
`https://graph.facebook.com/v19.0/${process.env.PHONE_NUMBER_ID}/messages`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.WHATSAPP_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
messaging_product: 'whatsapp',
to,
type: 'text',
text: { body: text },
}),
}
);
}
async function sendButtons(to, bodyText, buttons) {
await fetch(
`https://graph.facebook.com/v19.0/${process.env.PHONE_NUMBER_ID}/messages`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.WHATSAPP_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
messaging_product: 'whatsapp',
to,
type: 'interactive',
interactive: {
type: 'button',
body: { text: bodyText },
action: {
buttons: buttons.map((b) => ({
type: 'reply',
reply: { id: b.id, title: b.title },
})),
},
},
}),
}
);
}
Step 5: Conversation State
WhatsApp bots need state — you need to know where in a conversation flow each user is.
Simple approach: Redis with TTL.
const redis = require('redis');
const client = redis.createClient();
async function getState(userId) {
const state = await client.get(`whatsapp:state:${userId}`);
return state ? JSON.parse(state) : { step: 'welcome' };
}
async function setState(userId, state) {
await client.setEx(
`whatsapp:state:${userId}`,
3600, // 1 hour TTL
JSON.stringify(state)
);
}
Step 6: Add an LLM for Open-Ended Questions
For anything beyond a fixed decision tree, add an LLM:
async function processTextMessage(userId, text) {
const state = await getState(userId);
// Try to match intent first (faster, cheaper)
if (text.includes('order') || text.includes('track')) {
return handleOrderTracking(userId);
}
// Fall back to LLM for complex questions
const response = await openai.chat.completions.create({
model: 'gpt-4o-mini',
messages: [
{
role: 'system',
content: `You are a helpful customer service agent for [Company].
Answer questions about: ${COMPANY_CONTEXT}.
Keep responses under 3 sentences. Use casual, friendly tone.
If you can't answer, say you'll connect them with a human.`,
},
{ role: 'user', content: text },
],
max_tokens: 150,
});
await sendMessage(userId, response.choices[0].message.content);
}
Common Mistakes
Sending too many messages. WhatsApp has strict anti-spam policies. Businesses that send unsolicited promotional messages get banned. Stick to transactional messages and conversations the user initiated.
Not handling opt-outs. Always honor "STOP" or "unsubscribe" immediately. Build this in from day one.
Ignoring the 24-hour window. You can reply freely within 24 hours of the user's last message. After that, you can only send pre-approved template messages. Design your flows around this.
No human fallback. Some conversations need a human. Build an escalation path. Users who get stuck in a bot loop are the most frustrated customers you'll ever have.
Hardcoded flows only. Decision trees work for simple cases but break down fast. Combine with an LLM for anything conversational.
Pricing Reality Check
Meta Cloud API pricing (2026):
- Marketing conversations: ~$0.05-0.08 per conversation (varies by country)
- Utility conversations: ~$0.02-0.04 per conversation
- Authentication: ~$0.02-0.05 per conversation
- Service conversations (customer-initiated): Free in most countries
For a business handling 5,000 customer service conversations/month, WhatsApp API cost is typically $100-400/month — comparable to a single month of a live chat SaaS subscription, with dramatically higher engagement rates.
Aunimeda builds custom WhatsApp bots for businesses across CIS, Europe, and globally — from simple FAQ bots to fully integrated systems with CRM, order management, and AI.
Contact us to discuss your WhatsApp automation project. See also: WhatsApp Bot Development, Telegram Bot Development, Business Automation