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

MethodEndpointDescription
POST/platforms/whatsapp/connectConnect a WhatsApp Business account
GET/platforms/whatsapp/listList all WhatsApp connections
DELETE/platforms/whatsapp/:connectionIdDisconnect a WhatsApp account
POST/platforms/whatsapp/:connectionId/toggleEnable/disable a connection
PATCH/platforms/whatsapp/:connectionId/tokenUpdate the access token
GET/platforms/whatsapp/:connectionId/conversationsList conversations
GET/platforms/whatsapp/:connectionId/conversations/:convId/messagesGet messages in a conversation
POST/platforms/whatsapp/:connectionId/sendSend a WhatsApp message
GET/platforms/whatsapp/:connectionId/contactsList contacts
POST/platforms/whatsapp/:connectionId/contactsAdd or update a contact
DELETE/platforms/whatsapp/:connectionId/contacts/:phoneDelete a contact
GET/platforms/whatsapp/:connectionId/specialized-contactsSpecialized/segmented contacts
POST/platforms/broadcastBroadcast a message to all (or filtered) contacts
WhatsApp Business — CognitionDesk Docs