C
Chatty

WhatsApp Business Integration

Deploy your Chatty AI assistant directly onto WhatsApp using the official Meta Cloud API. Customers can message your official business phone number, receive instant AI replies, send voice notes, and book calendar appointments without leaving WhatsApp.


Prerequisites

Before starting, ensure you have:

  1. A Meta for Developers account.
  2. A verified WhatsApp Business Account (WABA).
  3. A clean phone number dedicated to WhatsApp Business (not already registered on personal WhatsApp).

Step-by-Step Setup

1. Configure WhatsApp in Meta Developer Portal

  1. Go to your App Dashboard in Meta for Developers → WhatsApp → API Setup.
  2. Note your Phone Number ID and WhatsApp Business Account ID.
  3. Under Configuration, locate the Webhook section and click Edit:
    • Callback URL: https://api.chatty.personaliai.com/webhook/whatsapp
    • Verify Token: Enter a strong secret string (you will also save this in Chatty).
  4. Click Verify and Save.
  5. Under Webhook fields, subscribe to messages.

2. Connect Credentials in Chatty

In the Chatty Dashboard, navigate to Integrations → WhatsApp Business Integration:

SettingValue Description
Phone Number ID15-digit ID from Meta API Setup screen
WABA IDWhatsApp Business Account ID
Access TokenSystem User Permanent Access Token with whatsapp_business_messaging permission
Verify TokenThe exact token string entered in the Meta Webhook configuration
App SecretYour Meta App Secret (used for cryptographic HMAC payload verification)

After saving the credentials, use Test connection in the WhatsApp card. This performs a read-only Graph API lookup of the configured phone number; it does not send a message. A successful check confirms that the phone-number ID and access token are valid.

For inbound production messages, the Meta app must be published, the WABA must be subscribed to the app, and the messages webhook field must show Subscribed. Meta's dashboard sample webhook tester only proves that the callback can receive a test payload; it does not simulate a real customer conversation.

If a booking reply contains a link, Chatty replaces model-generated or legacy links with a signed https://chatty.personaliai.com/book/... URL bound to the WhatsApp sender. Older messages may still contain a previously generated link and are not rewritten.


Supported WhatsApp Message Formats

💬

Two-Way Text Chat

Handles multi-turn conversational dialog with full markdown rendering (bold, bullet points, numbered lists).

🎙️

Voice Notes & Audio

When customers send WhatsApp voice clips, Chatty automatically transcribes the audio using Gemini speech models and replies in text.

📸

Document & Photo Vision

Customers can upload receipts, error screenshots, or PDFs. The vision engine parses visual data alongside customer prompts.

🔘

Interactive Buttons

Render quick-reply buttons (e.g. "Book a Call", "View Pricing", "Talk to Human") for friction-free navigation.


Ecommerce Product Questions

Chatty can answer product questions from an indexed catalog, including image-based requests. Connect WooCommerce for automatic product, price, and stock synchronization, or use the manual catalog/webhook mode to push product and inventory changes from your own system. The same assistant route works on web and WhatsApp; WhatsApp responses are rendered as concise text, approved purchase links, and optional quick-reply buttons.


Security & Webhook Verification

Every incoming payload from Meta is cryptographically signed using your Meta App Secret. Chatty verifies the X-Hub-Signature-256 header before processing:

Webhook Signature Validation
import hmac
import hashlib
 
def verify_meta_signature(raw_payload: bytes, signature_header: str, app_secret: str) -> bool:
    expected_sig = "sha256=" + hmac.new(
        app_secret.encode("utf-8"),
        raw_payload,
        hashlib.sha256
    ).hexdigest()
    return hmac.compare_digest(expected_sig, signature_header)

If the signature does not match, Chatty discards the request with 401 Unauthorized.


24-Hour Messaging Window Rules

Meta enforces strict customer messaging window policies:

  • User-Initiated Window: When a customer sends a message, a 24-hour service window opens. Your bot can send unlimited conversational replies during this period.
  • Outside 24 Hours: Once 24 hours elapse since the customer's last message, you may only reach out using pre-approved WhatsApp Template Messages (e.g. appointment reminders or shipping updates).