How to Build a WhatsApp Chatbot: Best Practice and Step-by-Step Guide

Content

topic1 cover en 13

Building a WhatsApp chatbot means combining approved templates, the 24-hour session, and opt-in so your bot can start conversations and reply within WhatsApp Business API rules. With Spoki you send templates, receive inbound messages via webhook, and keep automation compliant.

This guide walks you through best practice and step-by-step how to build a WhatsApp chatbot: from template design and opt-in to webhook setup and session handling. You will find links to registration, pricing, support, book, and the ROI calculator.

Step 1: Understand WhatsApp Business API Rules

The WhatsApp Business API does not allow free-form text for the first message to a user or after the 24-hour session has ended. Your chatbot must:

  • Use approved templates to start: The first outbound message (or any message after 24h of no reply) must be an approved template. Spoki helps you create and send templates (e.g. “Hi {{1}}, how can we help? Reply 1 for support, 2 for sales.”). See registration and support.
  • Use session messages for replies: Once the user replies, you have 24 hours to send session messages—free-form replies, buttons, or quick replies (within API limits). No template is required for each answer. Spoki delivers inbound messages to your webhook so your chatbot logic can reply via Spoki. Use pricing and the ROI calculator.

Best practice: Design templates that open a conversation (e.g. menu, welcome, reminder). Use session messages for the actual dialogue. Spoki sits between your chatbot and the API so you do not have to manage template vs session rules by hand.

Step 2: Collect and Store Opt-In

WhatsApp requires that users have agreed to receive messages before you send them. Step-by-step for opt-in:

  • Capture consent clearly: When a user registers, clicks a WhatsApp link, or fills a form, ask explicitly if they want messages via WhatsApp. Store opt-in (and scope, e.g. “support and sales”) in your CRM or Spoki. Spoki helps you respect opt-out (e.g. STOP) so your chatbot list stays compliant. See registration and support.
  • Scope and honour opt-out: Do not use the same opt-in for unrelated campaigns. When a user sends STOP, your chatbot or app must process it (update database, stop sending). Spoki can forward opt-out events to your webhook. Use book for webhook design.

Best practice: Check opt-in before every template send. Spoki helps you segment contacts so the chatbot only messages those who have opt-in for that use case.

Step 3: Design Templates That Start Conversations

Templates are the only way to initiate (or re-open after 24h). Step-by-step:

  • Choose a use case: Support (e.g. “Reply with your order ID”), lead qualification (“Reply 1 for sales, 2 for info”), reminder (“Your appointment is tomorrow at {{1}}. Reply YES to confirm.”). Spoki supports template variables and approval workflow. See support and pricing.
  • Keep copy clear and actionable: Templates should tell the user what to do next (reply with a number, confirm, etc.). That way your chatbot can branch on the reply. Use registration and the ROI calculator.
  • Submit for approval: WhatsApp must approve templates before use. Spoki helps you submit and track template status. Once approved, your chatbot can send them to start conversations. Links: book, support.

Step 4: Set Up Your Webhook and Chatbot Logic

Spoki sends inbound WhatsApp messages to a webhook URL you configure. Step-by-step:

  • Configure webhook in Spoki: In Spoki set your webhook URL. When a user sends a WhatsApp message, Spoki posts the event (sender, message body, etc.) to that URL. Your chatbot (on your server, CRM, or no-code tool) receives it and runs logic. See registration and support.
  • Parse and respond: Your chatbot parses the inbound message (e.g. “1” for support, “2” for sales). It then calls Spoki to send a session message back (e.g. “We’ll connect you with support. What’s your order ID?”). Spoki delivers the reply within the 24-hour session. Use pricing and book.
  • Handle opt-out: If the message is STOP (or your opt-out keyword), your chatbot must update your database and stop sending. Spoki can notify your webhook of opt-out events. See the ROI calculator to plan volume.

Best practice: Reply quickly so the conversation stays within the 24-hour window. Spoki handles delivery and session rules; your chatbot focuses on logic and content.

Chatbot logic can run on your own server, a CRM (e.g. with Spoki integration), or a no-code platform that calls Spoki API. The important part is that inbound messages from WhatsApp reach your webhook (via Spoki), and your chatbot replies within the 24-hour session using Spoki to send session messages. If you need to send a template again (e.g. after 24h of no reply), Spoki lets you do that too. Opt-in and opt-out must be checked and stored; Spoki helps you keep compliance so your chatbot does not message users who have opted out. Use registration, support, and pricing to design your webhook and chatbot flow.

Step 5: Test and Go Live

Before going live:

  • Test templates: Send approved templates to a test number. Confirm variables (e.g. {{1}}) are filled correctly. Spoki lets you test from the dashboard or API. See support.
  • Test webhook: Trigger inbound messages and confirm your webhook receives them and your chatbot replies with session messages. Check opt-in and opt-out handling. Use registration and book.
  • Monitor: Use Spoki to monitor delivery and webhook responses. Fix timeouts or errors so users get replies within the 24-hour window. Over time, refine templates and chatbot flows. Links: pricing, ROI calculator.

Conclusion

To build a WhatsApp chatbot: (1) use approved templates to start and after 24h, (2) collect and store opt-in, (3) design templates that start conversations, (4) set up a webhook and chatbot logic to reply with session messages, (5) test and go live. Spoki works with the WhatsApp Business API so you manage templates, webhooks, and consent in one place.

Ready to build your WhatsApp chatbot? Visit Spoki for the WhatsApp Business API, registration, and pricing. Use support or book for webhook and template design, and the ROI calculator to plan volume.

Related Articles

Frequently Asked Questions

What is Spoki?

Spoki is a comprehensive WhatsApp Business API platform that enables businesses to transform WhatsApp into a powerful channel for marketing, sales, and customer support.

With Spoki, you can:

Automate communications: Send automated messages, create chatbots, and set up intelligent workflows

Manage customer support: Multi-operator team management with ticketing system and conversation routing

Increase sales: Recover abandoned carts, send payment requests, and manage your product catalog directly on WhatsApp

Marketing campaigns: Send bulk messages to thousands of contacts with personalized templates

AI-powered features: Leverage artificial intelligence to automate responses and qualify leads 24/7

Integrate with your tools: Connect with over 4,000 platforms including CRM, e-commerce, and marketing tools

Spoki is an official Meta Tech Partner, guaranteeing reliability, security, and access to all official WhatsApp Business API features.

How does the WhatsApp Business API work?

The WhatsApp Business App and the WhatsApp Business API (used by Spoki) are two completely different solutions designed for different business needs:

WhatsApp Business App: • Designed for small businesses and sole proprietors • Manual message management • Limited to 5 devices simultaneously • Maximum 256 contacts per broadcast • No automation capabilities • Free but with significant limitations • No CRM or integration support

WhatsApp Business API (Spoki): • Designed for medium to large businesses • Unlimited operators: Your entire team can manage conversations simultaneously • Unlimited broadcasts: Send messages to thousands of contacts • Advanced automation: Chatbots, automatic responses, intelligent workflows • CRM integration: Connect with your existing tools (HubSpot, Salesforce, etc.) • Analytics & reporting: Detailed statistics on your communications • No ban risk: Official API approved by Meta for bulk messaging • Cloud-based: No need to keep a phone connected • Multi-channel: Integrate WhatsApp with SMS, Voice, and other channels

How much does a Spoki subscription cost?

We have different plans suitable for various needs. Visit the Pricing page for updated details.

Is there a free trial?

Yes, Spoki usually offers a trial period or a free plan to test the platform.

Can I integrate Spoki with other tools?

Spoki integrates with thousands of platforms through native integrations, Zapier, Make (Integromat), and Webhooks.

Native Integrations:

E-commerce: Shopify, WooCommerce, PrestaShop, Magento

CRM: HubSpot, Salesforce, Pipedrive, Zoho, ActiveCampaign

Marketing: Mailchimp, Google Sheets

Payment: Stripe, PayPal

Support: Zendesk

Via Zapier/Make:

Connect to 4,000+ platforms including: • Google Workspace (Sheets, Calendar, Drive) • Microsoft Office 365 • Slack, Trello, Asana • WordPress, Webflow • Custom apps via API

Webhooks & API:

Full REST API for developers to build custom integrations.

Try Spoki for Free

No credit card required

I accept the General Terms and Conditions and the processing of personal data related to the use of the Services pursuant to the Privacy Policy. *

I accept specific articles of the Client Agreement, the GDPR Data Processing Agreement, and the General Terms and Conditions. *