Create a WhatsApp chatbot: step-by-step for 2026
Create a WhatsApp chatbot: step-by-step for 2026
The gap between “I want a WhatsApp chatbot” and “I have a working WhatsApp chatbot” is wider than most tutorials admit. The AI part — generating responses, understanding intent — is the easy part. The hard part is the plumbing: getting approved for the WhatsApp Business API, configuring webhooks, handling the 24-hour messaging window, and building a system that does not fall over when 200 messages arrive in the same minute.
Here is the direct path: you need a Meta Business Account, a WhatsApp Business API connection (direct or through a BSP), a webhook endpoint, and a processing layer. Meta reports that WhatsApp Business API handles over 600 million business messages per day globally (Meta), and a 2025 Juniper Research study projects that chatbot-driven messaging interactions will reach 134 billion annually by 2026 (Juniper Research).
Unlike generic AI automation posts, this guide shows real CodeWords workflows — not just theory. You will create a WhatsApp chatbot that handles real conversations with AI, not just button menus.
Related reading: WhatsApp AI chatbot, WhatsApp bot builder, build WhatsApp chatbot, telegram AI chatbot, CodeWords integrations, CodeWords pricing, CodeWords templates.
TL;DR
- Creating a WhatsApp chatbot requires a Meta Business Account, WhatsApp Business API access, a webhook server, and AI processing for natural conversation.
- The 24-hour conversation window is your primary design constraint — plan template messages for re-engagement outside this window.
- CodeWords handles the webhook, AI reasoning, integration wiring, and deployment as one serverless workflow.
What do you need to create a WhatsApp chatbot?
Two tracks run in parallel: Meta’s administrative requirements and your technical architecture.
Meta requirements (allow 1–5 business days):
- Meta Business Account at business.facebook.com
- WhatsApp Business API access — either through Meta Cloud API (fastest, free setup) or a Business Solution Provider like Twilio, MessageBird, or 360dialog
- A phone number not registered on any WhatsApp account
- Business verification (for production messaging volumes)
- Message template submissions for proactive outbound messages
Technical stack:
- A webhook URL accessible from the public internet (HTTPS required)
- Server logic to process incoming messages and generate responses
- An AI model for natural language understanding (OpenAI, Anthropic, or Gemini)
- Conversation state storage (Redis, database, or in-memory for prototypes)
- Logging for every message exchange
The Meta Cloud API is the fastest path for most developers. You get a test phone number immediately, webhook configuration through the Meta Developer Dashboard, and free service conversations for the first 1,000 per month.
How do you configure the WhatsApp webhook?
The webhook is the backbone. Meta sends every incoming message to your webhook URL as an HTTP POST.
Step 1: Set up the verification endpoint. Meta verifies your webhook by sending a GET request with three parameters: hub.mode, hub.verify_token, and hub.challenge. Your server checks that hub.verify_token matches a secret you configured and returns the hub.challenge value.
Step 2: Handle incoming messages. Every message arrives as a POST request with a JSON payload. The payload structure includes the sender’s phone number, message type (text, image, document, audio, location, interactive), timestamp, and content.
Step 3: Process and respond. Parse the incoming message, run it through your AI layer, and send the response via a POST to the WhatsApp Cloud API /messages endpoint.
In CodeWords, you describe this to Cody:
Create a WhatsApp chatbot webhook.
Handle webhook verification for the Meta WhatsApp API.
When a message arrives:
1. Parse the sender number and message content.
2. Load conversation history from Redis (last 10 messages).
3. Send the message + history to an AI model with this system prompt:
"You are a helpful customer support assistant for [Company].
Keep responses under 100 words. Be friendly and professional."
4. Save the AI response to conversation history.
5. Send the response back via WhatsApp Cloud API.
6. Log the exchange to Google Sheets.
Cody generates the FastAPI webhook, Redis state management, LLM integration, WhatsApp API calls, and Google Sheets logging — deployed as a single serverless service.
How do you add AI that understands context?
A chatbot without memory answers every message in isolation. A chatbot with memory maintains a conversation.
Conversation history. Store the last 8–12 messages per user in Redis (key: phone number, value: message array). Pass this history to the LLM with each new message. This gives the AI context about what has been discussed.
Intent classification. Before generating a free-form response, classify the message intent:
Classify this WhatsApp message into one of these categories:
- greeting
- product_inquiry
- support_request
- order_status
- appointment_booking
- complaint
- other
Return JSON: {"intent": "...", "confidence": 0.0-1.0}
Use the classified intent to route responses: product inquiries get product information, order status triggers a database lookup, complaints escalate to a human.
Structured responses. Ask the LLM to return JSON with response_text, intent, confidence, and needs_human_review. When confidence drops below 0.7, route the conversation to a human agent instead of guessing. CodeWords supports native LLM access — OpenAI, Anthropic, and Gemini — with no API key configuration.
What is the 24-hour window and how do you design around it?
The 24-hour conversation window is WhatsApp’s anti-spam mechanism. When a user messages your bot, you have 24 hours to send free-form responses. After 24 hours of inactivity, you can only send pre-approved template messages.
Design implications:
- Resolve conversations quickly. If the user’s question requires research, acknowledge immediately and follow up within the window.
- Prepare template messages. Submit templates for common follow-up scenarios: order updates, appointment reminders, feedback requests. Templates require Meta review and typically take 24–48 hours for approval.
- Re-engagement strategy. Use template messages to re-open conversations: “Hi {{name}}, your order has shipped! Reply with any questions.” This re-opens the 24-hour window for free-form messaging.
- Session tracking. Store the timestamp of the last user message per phone number. Before sending a free-form response, check whether the window is still open.
What mistakes kill WhatsApp chatbot projects?
Not handling media messages. Users send images, voice notes, and documents. A chatbot that only processes text and ignores everything else frustrates users. At minimum, acknowledge non-text messages: “I received your image. Let me take a look.”
Ignoring rate limits. WhatsApp enforces quality-based rate limits. If users report your messages as spam, Meta reduces your sending capacity or bans your number. Start conservatively and monitor your quality rating in the Meta Business Dashboard.
No human handoff. Every chatbot needs an escape hatch. When the AI cannot help or the user explicitly asks for a human, route the conversation to a support agent via Slack, email, or your helpdesk. CodeWords has native Slack integration for real-time agent notifications.
Synchronous processing. If your AI response takes 8 seconds, the user sees nothing during that time. Send a typing indicator immediately, process the response, then send it. For complex queries, send an acknowledgment (“Let me check that for you…”) and follow up with the answer.
Not logging conversations. Without logs, you cannot debug issues, improve prompts, or audit conversations. Log every message exchange — incoming text, outgoing response, intent classification, and any errors — to Google Sheets, Airtable, or a database.
FAQ
How much does it cost to create a WhatsApp chatbot?
WhatsApp Business API pricing varies by country and conversation category. Service conversations (user-initiated) are free for the first 1,000 per month. Marketing and utility conversations cost $0.005–0.08 per conversation depending on the country. AI model costs add $0.01–0.10 per message exchange. See CodeWords pricing for platform costs.
Can I create a WhatsApp chatbot without the Business API?
Unofficial libraries exist but violate WhatsApp’s terms of service and risk account bans. For production chatbots, the Business API is the only supported path. The Cloud API is free to set up and provides a test number for development.
How do I test my WhatsApp chatbot?
Use the Meta Cloud API test number first. Send messages from your personal WhatsApp to the test number and verify responses. Before going to production, test with 5–10 real users across different message types (text, images, voice notes), different intents, and different conversation lengths.
Can my WhatsApp chatbot support multiple languages?
Yes. Use the AI layer for automatic language detection. Pass the detected language into the system prompt so responses match the user’s language. Store the language preference per user in Redis so subsequent messages skip re-detection.
From chatbot to workflow hub
The first version of your WhatsApp chatbot answers questions. The second version connects to your backend systems — looking up orders, booking appointments, updating CRM records, processing payments. Each new capability is another workflow connected to the same webhook endpoint.
The chatbot is not the product. It is the interface to a system of automations behind it. The implication: the most valuable WhatsApp chatbots are not the ones with the best AI — they are the ones connected to the most workflows.
Create your WhatsApp chatbot in CodeWords, or explore the integrations catalog to see what you can connect.




