Channels
WhatsApp Business
Connect Sophon to WhatsApp via the Business Cloud API.
Sophon connects to WhatsApp using the WhatsApp Business Cloud API. This requires a Meta Business account and a registered WhatsApp Business phone number.
Prerequisites
- A Meta Business account
- A phone number that can receive SMS or calls for verification
- A public URL for webhook delivery (or a tunneling tool like ngrok for development)
Step-by-Step Setup
1. Create a Meta App
- Go to Meta for Developers
- Click Create App > Other > Business
- Name it (e.g., "Sophon WhatsApp") and click Create App
2. Set Up WhatsApp Product
- In your app dashboard, find WhatsApp and click Set Up
- Select or create a Meta Business Account
- You'll get a test phone number to start with (or add your own later)
3. Get Your Credentials
Phone Number ID
- Go to WhatsApp > API Setup in the app dashboard
- Copy the Phone Number ID (numeric string)
Permanent Access Token
- Go to Business Settings > System Users
- Create a system user (Admin role)
- Click Generate New Token
- Select your app and add the
whatsapp_business_messagingpermission - Copy the token
Webhook Verify Token
Choose any custom string (e.g., sophon-verify-2026). You'll use this same string in both Sophon and the Meta webhook configuration.
4. Configure the Webhook
- Go to WhatsApp > Configuration in the app dashboard
- Click Edit on the Webhook section
- Set:
- Callback URL:
https://your-domain.com/api/channels/whatsapp/webhook - Verify Token: The custom string you chose above
- Callback URL:
- Click Verify and Save
- Subscribe to the
messageswebhook field
For local development, use a tunnel:
ngrok http 8080
# Use the HTTPS URL as your callback: https://xxxx.ngrok.io/api/channels/whatsapp/webhook5. Configure in Sophon Dashboard
- Go to Channels and click Add Channel
- Select WhatsApp Business
- Enter the Phone Number ID
- Enter the Permanent Access Token
- Enter the Webhook Verify Token (same string as in Meta)
- Click Test Connection
- Click Activate
6. Test It
Send a message to your WhatsApp Business number from any WhatsApp account. Sophon should respond.
Note: With the test phone number, you can only send messages to numbers added to the "To" list in the API Setup page. For production, you'll need to verify your business and register a real phone number.
Configuration Reference
| Field | Type | Required | Description |
|---|---|---|---|
phoneNumberId | text | Yes | Phone Number ID from WhatsApp API Setup |
accessToken | secret | Yes | Permanent access token from System Users |
verifyToken | text | Yes | Custom string for webhook verification |
Media Support
| Type | Inbound | Outbound |
|---|---|---|
| Text | Yes | Yes |
| Images (PNG, JPG, WEBP) | Yes | Yes |
| Audio (AAC, MP3, OGG) | Yes | Yes |
| Video (MP4) | Yes | Yes |
| Documents (PDF, DOCX, etc.) | Yes | Yes |
| Stickers (WEBP) | Yes (converted to image) | No |
channels.json Example
{
"id": "whatsapp-business",
"type": "whatsapp",
"name": "Sophon WhatsApp",
"enabled": true,
"config": {
"phoneNumberId": "1234567890",
"accessToken": "<encrypted>",
"verifyToken": "sophon-verify-2026"
},
"routing": {
"agentId": "default",
"dmBehavior": "main-session",
"groupBehavior": "mention-only"
},
"status": "connected"
}Troubleshooting
- Webhook verification fails — The verify token in Sophon must exactly match the one entered in Meta Developer Portal. Ensure Sophon is running and the callback URL is publicly accessible.
- "Access token is invalid" — System user tokens do not expire, but they can be revoked. Generate a new one in Business Settings > System Users.
- Messages not arriving — Check that you've subscribed to the
messageswebhook field in WhatsApp > Configuration. Also verify the callback URL is correct and responding with 200. - "Recipient not in allowed list" — On the test phone number, you can only message numbers added to the allowed list. Go to WhatsApp > API Setup and add the recipient number.
- Media download fails — Inbound media requires the access token to download from Meta's servers. Ensure the token has
whatsapp_business_messagingpermission.