Messaging
WhatsApp Business
CognitionDesk integrates with the WhatsApp Business API via Meta's Cloud API. Connect your WhatsApp Business Account, assign an AI assistant, and your bot will automatically respond to incoming messages.
Prerequisites
- → A Meta Business Account with WhatsApp Business API access
- → A verified phone number registered with WhatsApp Business
- → A permanent system user access token from your Meta app
- → Webhook configured in the Meta developer dashboard
1. Connect your account
JSON
POST /platforms/whatsapp/connect
Authorization: Bearer <token>
{
"phoneNumberId": "123456789",
"accessToken": "EAAxxxxxxxx...",
"wabaId": "987654321",
"assistantId": "asst_abc123" // AI assistant to handle messages
}2. Send a message
Send text or template messages to any WhatsApp number:
JSON
POST /platforms/whatsapp/:connectionId/send
Authorization: Bearer <token>
{
"to": "+1234567890",
"type": "text",
"text": { "body": "Hello! How can I help you today?" }
}
// Or send a template message:
{
"to": "+1234567890",
"type": "template",
"template": {
"name": "order_confirmation",
"language": { "code": "en_US" },
"components": [
{ "type": "body", "parameters": [{ "type": "text", "text": "ORD-12345" }] }
]
}
}3. Broadcast
Send a message to all (or filtered) contacts at once:
JSON
POST /platforms/broadcast
Authorization: Bearer <token>
{
"platform": "whatsapp",
"connectionId": "conn_abc123",
"message": {
"type": "text",
"text": { "body": "We have a special offer for you! 🎉" }
},
"filter": {
"tag": "premium-users" // optional — filter contacts by tag
}
}Incoming messages (webhooks)
When a user messages your WhatsApp number, Meta sends a webhook event to CognitionDesk. The platform verifies the signature, routes the message to the linked AI assistant, and sends back the response automatically:
Incoming webhook payload
JSON
// WhatsApp sends events to your configured webhook URL.
// CognitionDesk verifies the signature and routes to your assistant.
// Incoming message event:
{
"object": "whatsapp_business_account",
"entry": [{
"changes": [{
"value": {
"messages": [{
"from": "1234567890",
"type": "text",
"text": { "body": "What are your hours?" },
"timestamp": "1700000000"
}]
}
}]
}]
}Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /platforms/whatsapp/connect | Connect a WhatsApp Business account |
| GET | /platforms/whatsapp/list | List all WhatsApp connections |
| DELETE | /platforms/whatsapp/:connectionId | Disconnect a WhatsApp account |
| POST | /platforms/whatsapp/:connectionId/toggle | Enable/disable a connection |
| PATCH | /platforms/whatsapp/:connectionId/token | Update the access token |
| GET | /platforms/whatsapp/:connectionId/conversations | List conversations |
| GET | /platforms/whatsapp/:connectionId/conversations/:convId/messages | Get messages in a conversation |
| POST | /platforms/whatsapp/:connectionId/send | Send a WhatsApp message |
| GET | /platforms/whatsapp/:connectionId/contacts | List contacts |
| POST | /platforms/whatsapp/:connectionId/contacts | Add or update a contact |
| DELETE | /platforms/whatsapp/:connectionId/contacts/:phone | Delete a contact |
| GET | /platforms/whatsapp/:connectionId/specialized-contacts | Specialized/segmented contacts |
| POST | /platforms/broadcast | Broadcast a message to all (or filtered) contacts |