IntegrationWhatsAppMarch 10, 2026ยท10 min read

OpenClaw WhatsApp Integration: Build an AI Agent for WhatsApp

WhatsApp has over 2 billion active users. For businesses in e-commerce, healthcare, hospitality, and services, it is the primary channel customers use to ask questions, book appointments, and track orders. This guide walks through connecting an OpenClaw agent to WhatsApp using the Meta Business API, from creating a Meta Developer account to deploying a production-ready agent that handles customer conversations around the clock.

Why WhatsApp for AI Agents

Most AI agent setups focus on Slack, Discord, or Telegram. These work well for internal teams and developer communities. But your customers are not on Slack. They are on WhatsApp. In Latin America, Southeast Asia, Europe, and Africa, WhatsApp is the default communication tool. If you want an AI agent that actually reaches your customers where they already are, WhatsApp is the channel to deploy on.

A WhatsApp-connected OpenClaw agent can handle customer support tickets, schedule appointments, send order status updates, qualify leads, and answer FAQs without a human in the loop. The agent responds instantly, works 24/7, and scales to thousands of simultaneous conversations. Unlike a chatbot widget buried on your website, WhatsApp messages land directly on the customer's phone with a push notification.

ChannelOpen RateBest For
WhatsApp98%Customer support, appointment booking, order tracking
Email20-25%Long-form updates, newsletters
SMS90%Alerts, OTP, short notifications
Website Chat15-30%On-site visitors only

Prerequisites: What You Need Before Starting

The WhatsApp Business API is not as simple as generating a bot token. Meta requires business verification and a specific account structure. Here is what you need before writing any configuration.

Meta Business Account

Create one at business.facebook.com. This is your organization-level account that owns the WhatsApp Business API access. You do not need a Facebook page, but you do need to verify your business with Meta (usually takes 1-3 business days).

A Phone Number

You need a phone number that is not currently registered on WhatsApp or WhatsApp Business app. Meta provides a free test number during development, but for production you need your own number. A virtual number from Twilio, MessageBird, or similar providers works fine.

OpenClaw Installed

You need OpenClaw installed locally or on a server. The gateway must be running and accessible. If you have not installed OpenClaw yet, follow the OpenClaw Setup Guide first.

A Public URL or Tunnel

WhatsApp sends webhook events to your server. Meta needs a publicly accessible HTTPS URL. For local development, use ngrok or Cloudflare Tunnel. For production, your server needs a domain with SSL.

Step 1: Meta Developer Setup

The Meta Developer Portal is where you create your app and get access to the WhatsApp Business API. The process is straightforward but has several steps that must be done in order.

1.1 Create a Meta App

Go to developers.facebook.com/apps. Click "Create App." Select "Business" as the app type. Give it a name like "OpenClaw WhatsApp Agent" and link it to your Meta Business Account.

1.2 Add WhatsApp Product

In your app dashboard, find "Add Products to Your App" and click "Set Up" on the WhatsApp card. This gives you access to the WhatsApp Business API, a test phone number, and the API playground for sending test messages.

1.3 Generate a Permanent Access Token

The temporary token from the API playground expires in 24 hours. For production, you need a permanent token. Go to Business Settings > System Users. Create a system user, assign it admin access to your WhatsApp Business Account, and generate a token with the whatsapp_business_messaging and whatsapp_business_management permissions.

Important: Store the permanent token securely. It does not expire but grants full access to your WhatsApp Business API. Never commit it to version control.

Step 2: WhatsApp Business API Configuration

With your Meta app created and the WhatsApp product enabled, you need to register a phone number and configure the API settings. Meta provides a test number for development, but you should plan to register your own number for production.

WhatsApp Business API key information
# You need these values from the Meta Developer Portal:

# 1. Phone Number ID (found in WhatsApp > API Setup)
PHONE_NUMBER_ID=123456789012345

# 2. WhatsApp Business Account ID
WABA_ID=987654321098765

# 3. Permanent Access Token (from System User)
ACCESS_TOKEN=EAAxxxxxxxxxxxxxxxxxxxxxxxx

# 4. App Secret (from App Settings > Basic)
APP_SECRET=abcdef1234567890

# Test sending a message via curl:
curl -X POST "https://graph.facebook.com/v21.0/${PHONE_NUMBER_ID}/messages" \
  -H "Authorization: Bearer ${ACCESS_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
    "messaging_product": "whatsapp",
    "to": "1234567890",
    "type": "text",
    "text": { "body": "Hello from OpenClaw!" }
  }'

If the test message sends successfully, your API credentials are working. Note the Phone Number ID and Access Token. You will need both for the OpenClaw configuration in the next step.

Test Mode: During development, Meta restricts your test number to only send messages to phone numbers you explicitly add in the API Setup page. Add your own number and any team members who need to test. Once your app passes Meta's review, this restriction is removed.

Step 3: Configure OpenClaw Gateway for WhatsApp

Now connect your WhatsApp Business API credentials to OpenClaw. The gateway acts as the bridge between incoming WhatsApp messages and your agent's SOUL.md logic.

OpenClaw WhatsApp channel configuration
# Required: WhatsApp Business API access token
openclaw config set channels.whatsapp.accessToken YOUR_PERMANENT_TOKEN

# Required: Phone Number ID from Meta Developer Portal
openclaw config set channels.whatsapp.phoneNumberId YOUR_PHONE_NUMBER_ID

# Required: App Secret for webhook signature verification
openclaw config set channels.whatsapp.appSecret YOUR_APP_SECRET

# Required: Webhook verify token (you choose this, must match Meta config)
openclaw config set channels.whatsapp.verifyToken my-openclaw-webhook-secret

# Optional: Download media attachments (images, voice notes, documents)
openclaw config set channels.whatsapp.downloadMedia true

# Optional: Transcribe voice notes to text before passing to agent
openclaw config set channels.whatsapp.transcribeVoice true

# Optional: Send "typing" indicator while agent processes
openclaw config set channels.whatsapp.sendTypingIndicator true

# Optional: Mark messages as read automatically
openclaw config set channels.whatsapp.autoMarkRead true

# Start or restart the gateway
openclaw gateway restart

After restarting, verify the WhatsApp channel is loaded:

# Check gateway logs
openclaw gateway logs | grep whatsapp

# Expected output:
# [channel:whatsapp] initialized with phone number ID 123456789012345
# [channel:whatsapp] webhook endpoint ready at /webhook/whatsapp

Step 4: SOUL.md Configuration for WhatsApp

Your agent's SOUL.md defines its personality, knowledge, and behavior. For WhatsApp, you need to account for the conversational nature of the platform. Messages are short, users expect quick replies, and rich formatting (bold, italic, monospace) uses WhatsApp's own markdown syntax, not standard markdown.

SOUL.md optimized for WhatsApp
# SOUL.md - WhatsApp Customer Support Agent

## Identity
You are a customer support agent for [Your Business].
You respond via WhatsApp, so keep messages short and conversational.

## Personality
- Friendly, professional, and concise
- Use short paragraphs (2-3 sentences max)
- Use emojis sparingly (1-2 per message, only when natural)
- Never send walls of text

## WhatsApp Formatting Rules
- *bold* for emphasis (single asterisks)
- _italic_ for secondary info (single underscores)
- ```code``` for order numbers, tracking codes
- Use line breaks between sections for readability

## Knowledge
- Business hours: Mon-Fri 9am-6pm EST
- Return policy: 30 days, original packaging required
- Shipping: 3-5 business days standard, 1-2 days express
- Current promotions: [list active promotions]

## Response Templates
When a user asks about order status:
1. Ask for order number
2. Look up status in system
3. Respond with: status, expected delivery, tracking link

When a user wants to return an item:
1. Confirm the item and reason
2. Check if within return window
3. Provide return label or instructions

## Boundaries
- Never share customer data with other customers
- Escalate to human agent when: payment disputes, complaints,
  complex technical issues
- Say "Let me connect you with a team member" for escalation
- Never make promises about refund timelines

## Channel-Specific
channel: whatsapp
max_response_length: 500
typing_delay: true
read_receipts: true

The key difference from a Telegram or Discord SOUL.md is message length. WhatsApp users expect conversational, short responses. If your agent sends a 2000-character response, it feels like spam. Keep individual messages under 500 characters and split longer responses into multiple messages when needed.

Step 5: Webhook Configuration

Unlike Telegram or Discord bots that maintain a persistent connection, WhatsApp uses webhooks. Meta sends an HTTP POST request to your server every time someone sends a message to your WhatsApp number. The OpenClaw gateway handles this automatically, but you need to register the webhook URL with Meta.

Set Up a Public URL

Expose your local gateway with ngrok (development)
# Start the OpenClaw gateway (default port 18789)
openclaw gateway start

# In another terminal, start ngrok
ngrok http 18789

# ngrok will show something like:
# Forwarding  https://abc123.ngrok.io -> http://localhost:18789

# Your webhook URL will be:
# https://abc123.ngrok.io/webhook/whatsapp

Register the Webhook in Meta Developer Portal

5.1 Navigate to Webhook Settings

In the Meta Developer Portal, go to your app > WhatsApp > Configuration. Find the "Webhook" section and click "Edit."

5.2 Enter Callback URL and Verify Token

Callback URL: https://your-domain.com/webhook/whatsapp. Verify Token: the same string you set in channels.whatsapp.verifyToken. Click "Verify and Save." Meta sends a GET request to your URL with the verify token. The OpenClaw gateway responds automatically.

5.3 Subscribe to Webhook Fields

After verification, you need to subscribe to the messages field. This tells Meta to send incoming message events to your webhook. Without this subscription, your webhook is verified but receives no messages. Also subscribe to message_deliveries and message_reads if you want delivery and read receipt tracking.

Production webhook setup with Nginx reverse proxy
# Nginx config for proxying WhatsApp webhooks to OpenClaw gateway
server {
    listen 443 ssl;
    server_name yourdomain.com;

    ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;

    location /webhook/whatsapp {
        proxy_pass http://127.0.0.1:18789/webhook/whatsapp;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

# Verify webhook receives events
# Check OpenClaw logs after sending a test message:
openclaw gateway logs | grep "webhook.*whatsapp"

# Expected:
# [webhook:whatsapp] received message from 1234567890
# [agent] processing message: "Hello"
# [webhook:whatsapp] sent response to 1234567890

Step 6: Test Your WhatsApp Agent

With the webhook configured and the gateway running, your agent is ready to receive messages. Here is how to test it end-to-end.

6.1 Send a Test Message

Open WhatsApp on your phone. Send a message to your WhatsApp Business API number (or the test number from Meta). You should see the message appear in the OpenClaw gateway logs within 1-2 seconds.

6.2 Check Gateway Logs

# Watch logs in real-time
openclaw gateway logs --follow | grep whatsapp

# You should see:
# [channel:whatsapp] message received from +1234567890: "Hi there"
# [agent] generating response...
# [channel:whatsapp] response sent to +1234567890 (247 chars, 1.3s)

6.3 Verify the Response in WhatsApp

Check your WhatsApp app. The agent's response should appear as a reply. If you enabled sendTypingIndicator, you will see the typing dots before the response arrives. Test multiple scenarios from your SOUL.md to make sure the agent handles different types of questions correctly.

6.4 Test Edge Cases

Send an image, a voice note, a location, and a contact card. Verify that the agent either handles them or responds with a helpful fallback message. Test rapid consecutive messages to check that the agent processes them in order and does not send overlapping responses.

Use Cases: What WhatsApp AI Agents Do Best

WhatsApp agents shine in scenarios where customers expect instant, conversational responses. Here are the three most impactful use cases.

Customer Support

Handle the 80% of support questions that have standard answers: business hours, return policies, shipping status, pricing, account issues. The agent resolves these instantly without a human touching the ticket. Complex issues get escalated to a human agent with the full conversation context.

# Example SOUL.md snippet for support
## Escalation Rules
escalate_to_human:
  - payment disputes over $100
  - legal or compliance questions
  - customer explicitly requests human
  - three failed resolution attempts

escalation_message: |
  I want to make sure you get the best help.
  Let me connect you with a team member who
  can assist further. One moment please.

Appointment Booking

Clinics, salons, repair shops, and consultants can let customers book appointments directly through WhatsApp. The agent checks availability, confirms the booking, and sends a reminder 24 hours before. No app download, no website visit, no phone call required.

# Example SOUL.md snippet for booking
## Booking Flow
1. Customer sends: "I want to book an appointment"
2. Ask: service type, preferred date, preferred time
3. Check calendar API for availability
4. Confirm slot: "*Tuesday, March 15 at 2:00 PM*"
5. Send confirmation with calendar link

## Skills
- calendar_check: GET /api/availability?date={date}
- calendar_book: POST /api/appointments
- send_reminder: scheduled 24h before appointment

Order Tracking

E-commerce businesses can let customers check order status by sending their order number on WhatsApp. The agent queries the order management system, returns the current status, expected delivery date, and tracking link. Proactive notifications can be sent when the order ships or is out for delivery.

# Example SOUL.md snippet for order tracking
## Order Lookup
When customer provides order number (format: ORD-XXXXX):
1. Query: GET /api/orders/{order_id}
2. Return: status, items, tracking URL, ETA
3. If delayed: apologize, provide updated ETA

## Proactive Notifications (via templates)
- order_shipped: "Your order {order_id} has shipped! Track: {url}"
- out_for_delivery: "Your order is out for delivery today."
- delivered: "Your order was delivered. How was everything?"

Troubleshooting Common Issues

WhatsApp integration has more moving parts than Telegram or Discord. Here are the most common issues and how to fix them.

Webhook Verification Fails

Meta sends a GET request with a hub.verify_token parameter. If it does not match your configured channels.whatsapp.verifyToken, verification fails.

# Check your configured verify token
openclaw config get channels.whatsapp.verifyToken

# Make sure it matches exactly what you entered in Meta Portal
# No trailing spaces, no quotes wrapping the value

# Test locally with curl:
curl "http://localhost:18789/webhook/whatsapp?hub.mode=subscribe&hub.verify_token=my-openclaw-webhook-secret&hub.challenge=test123"

# Should return: test123

Messages Received but No Response Sent

The webhook receives the message (you see it in logs) but the agent does not respond. Common causes: the access token expired (if using a temporary token), the phone number ID is wrong, or the agent is throwing an error during processing.

# Check for errors in the full logs
openclaw gateway logs --lines 50

# Test sending a message directly via API
curl -X POST "https://graph.facebook.com/v21.0/YOUR_PHONE_ID/messages" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"messaging_product":"whatsapp","to":"YOUR_NUMBER","type":"text","text":{"body":"Test"}}'

# If this fails with 401: your token is expired or invalid
# If this fails with 400: check the phone number format (include country code, no +)

24-Hour Window Expired

If a customer has not messaged in 24 hours, you cannot send free-form messages. You will see a 400 error with "outside allowed window." Use pre-approved message templates instead.

# Configure message templates in OpenClaw
openclaw config set channels.whatsapp.templates '{
  "follow_up": {
    "name": "customer_followup",
    "language": "en",
    "components": [
      {
        "type": "body",
        "parameters": [
          { "type": "text", "text": "{{customer_name}}" }
        ]
      }
    ]
  }
}'

# Templates must be pre-approved in Meta Business Manager
# Go to: WhatsApp Manager > Message Templates > Create Template
# Approval usually takes 1-24 hours

Rate Limiting (Error 429 or 131056)

WhatsApp has tiered rate limits based on your phone number quality rating and messaging tier. New numbers start at Tier 1 (1,000 unique customers per 24 hours). If you hit the limit, messages return error code 131056. Increase your tier by maintaining a high quality rating over time. In OpenClaw, set channels.whatsapp.rateLimitDelay 1000 to add a 1-second delay between outgoing messages and avoid bursting.

Skip the Setup with CrewClaw

The manual setup above works, but it involves creating Meta accounts, generating tokens, configuring webhooks, writing SOUL.md from scratch, and maintaining a server. If you want a WhatsApp-ready AI agent without managing infrastructure, CrewClaw gives you a pre-configured agent package with WhatsApp integration included.

Select a role template (customer support, appointment booking, order tracker, or any custom role), customize the SOUL.md in the visual builder, and get a complete deployment package with Docker config, WhatsApp channel setup, and a ready-to-use SOUL.md. You still need your own Meta Business API credentials, but the OpenClaw configuration, webhook handling, and agent logic are done for you.

Related Guides

Frequently Asked Questions

How do I connect OpenClaw to WhatsApp?

You need a Meta Business Account and a WhatsApp Business API phone number. Create an app in the Meta Developer Portal, enable the WhatsApp product, generate a permanent access token, and configure OpenClaw with 'openclaw config set channels.whatsapp.accessToken YOUR_TOKEN' and 'openclaw config set channels.whatsapp.phoneNumberId YOUR_PHONE_ID'. Set up a webhook to forward incoming messages to the OpenClaw gateway, then restart with 'openclaw gateway restart'.

Is the WhatsApp Business API free?

Meta charges per conversation, not per message. Business-initiated conversations (marketing, utility, authentication) cost between $0.005 and $0.08 depending on the country. User-initiated conversations (the customer messages you first) have a free tier of 1,000 conversations per month. After that, they cost $0.003 to $0.05 per conversation. For most AI agent use cases where customers initiate the chat, the free tier is sufficient to get started.

Can I use a regular WhatsApp number with OpenClaw?

No. WhatsApp requires a phone number registered through the WhatsApp Business API. You cannot use a personal WhatsApp account or a standard WhatsApp Business app number. The API number must be registered through a Business Solution Provider (BSP) or directly through the Meta Developer Portal. The number cannot be simultaneously active on the WhatsApp mobile app and the API.

Why is my OpenClaw WhatsApp agent not receiving messages?

The most common causes are: (1) The webhook URL is not publicly accessible -- Meta cannot reach localhost, so you need a public URL or tunnel like ngrok. (2) The webhook verification token does not match what you configured in OpenClaw. (3) The 'messages' field is not subscribed in the webhook configuration. (4) The phone number is still in test mode and the recipient is not added as a test number. Check the Meta Developer Portal webhook logs for delivery attempts and error codes.

How do I handle media messages (images, voice notes) from WhatsApp?

OpenClaw receives media messages as webhook events with a media ID. You can configure the gateway to download media automatically with 'openclaw config set channels.whatsapp.downloadMedia true'. Voice notes are downloaded as .ogg files, images as .jpeg. The agent receives the local file path in the message context. For voice notes, you can integrate a speech-to-text service by setting 'channels.whatsapp.transcribeVoice true' to convert audio to text before passing it to the agent.

Can one OpenClaw agent handle multiple WhatsApp numbers?

Yes, but each phone number needs its own webhook configuration pointing to the same OpenClaw gateway. Configure multiple phone number IDs in the OpenClaw config using an array: 'openclaw config set channels.whatsapp.phoneNumberIds ["ID1", "ID2"]'. The gateway routes incoming messages based on the phone number ID in the webhook payload. Each number maintains separate conversation contexts per customer.

What is the 24-hour messaging window on WhatsApp?

WhatsApp enforces a 24-hour customer service window. After a customer sends you a message, you have 24 hours to respond with any type of message (free-form text, images, etc.). After 24 hours, you can only send pre-approved message templates. OpenClaw tracks the window automatically and logs a warning when a conversation window expires. To re-engage a customer after 24 hours, configure approved templates in your SOUL.md under the whatsapp.templates section.

Build and Deploy Your WhatsApp AI Agent

Get a complete, pre-configured OpenClaw agent with SOUL.md, WhatsApp integration, deployment scripts, and Docker setup. Start with a template and customize it for your business.

Deploy a Ready-Made AI Agent

Skip the setup. Pick a template and deploy in 60 seconds.

Get a Working AI Employee

Pick a role. Your AI employee starts working in 60 seconds. WhatsApp, Telegram, Slack & Discord. No setup required.

Get Your AI Employee
โœ“ One-time paymentโœ“ Own the codeโœ“ Money-back guarantee