Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.gateway.connexease.com/llms.txt

Use this file to discover all available pages before exploring further.

When a user sends a message to your WhatsApp number, the Connexease Gateway receives the event from Meta and forwards it to your registered webhook URL. The top-level envelope is always the same — entry[0].changes[0].value — but the inner shape depends on what the user sent. This page is the complete reference for every incoming message type, with field descriptions for each.

Envelope Structure

Every incoming message arrives wrapped in this envelope:
{
  "object": "whatsapp_business_account",
  "entry": [{
    "id": "WABA_ID_123456",
    "changes": [{
      "field": "messages",
      "value": {
        "messaging_product": "whatsapp",
        "metadata": {
          "display_phone_number": "905321234567",
          "phone_number_id": "PHONE_NUMBER_ID_123"
        },
        "contacts": [{
          "profile": { "name": "John Smith" },
          "wa_id": "905399876543"
        }],
        "messages": [{ "...message object..." }]
      }
    }]
  }]
}
Envelope Fields:
FieldTypeDescription
entry[0].idstringYour WhatsApp Business Account (WABA) ID
value.metadata.phone_number_idstringMeta ID of the phone number that received the message
value.metadata.display_phone_numberstringHuman-readable phone number
value.contacts[0].wa_idstringSender’s WhatsApp phone number
value.contacts[0].profile.namestringSender’s WhatsApp display name
value.messages[0]objectThe message object — structure varies by type

Common Message Fields

Every message object, regardless of type, contains:
FieldTypeDescription
fromstringSender’s phone number (same as contacts[0].wa_id)
idstringUnique incoming message ID (wamid)
timestampstringUnix timestamp in seconds
typestringMessage type — see sections below

Message Types

Received when a user sends a plain text message.
{
  "from": "905399876543",
  "id": "wamid.HBgNOTA1Mzk5ODc2NTQzFQIAERgSM0Y3RDg5NjREOUNBMkFFNEE3AA==",
  "timestamp": "1711900000",
  "type": "text",
  "text": {
    "body": "Hello, I'd like to know the status of my order."
  }
}
FieldTypeDescription
text.bodystringThe text content of the message
Received when a user sends a photo. The image content must be downloaded via the Media API using image.id.
{
  "from": "905399876543",
  "id": "wamid.xxx",
  "timestamp": "1711900050",
  "type": "image",
  "image": {
    "caption": "Here is the damaged item",
    "mime_type": "image/jpeg",
    "sha256": "abc123...",
    "id": "MEDIA_ID_789"
  }
}
FieldTypeDescription
image.idstringMedia ID — use this to download the image via the Media API
image.mime_typestringimage/jpeg or image/png
image.sha256stringSHA-256 hash for integrity verification
image.captionstringCaption written by the user (optional)
See the Media page for how to download the file using image.id.
Received when a user sends an audio file or records a voice note.
{
  "from": "905399876543",
  "id": "wamid.xxx",
  "timestamp": "1711900100",
  "type": "audio",
  "audio": {
    "mime_type": "audio/ogg; codecs=opus",
    "sha256": "def456...",
    "id": "MEDIA_ID_456",
    "voice": true
  }
}
FieldTypeDescription
audio.idstringMedia ID for downloading the audio
audio.voicebooleantrue = user recorded a voice note; false = file upload
audio.mime_typestringaudio/ogg; codecs=opus, audio/mp4, audio/mpeg, etc.
audio.sha256stringSHA-256 hash for integrity verification
Received when a user sends a PDF, Word document, or other file.
{
  "from": "905399876543",
  "id": "wamid.xxx",
  "timestamp": "1711900150",
  "type": "document",
  "document": {
    "caption": "Invoice",
    "filename": "invoice_march_2025.pdf",
    "mime_type": "application/pdf",
    "sha256": "ghi789...",
    "id": "MEDIA_ID_321"
  }
}
FieldTypeDescription
document.idstringMedia ID for downloading the document
document.filenamestringOriginal filename as uploaded by the user
document.mime_typestringMIME type of the file
document.captionstringCaption written by the user (optional)
Received when a user sends a video file.
{
  "from": "905399876543",
  "id": "wamid.xxx",
  "timestamp": "1711900200",
  "type": "video",
  "video": {
    "caption": "Screen recording of the issue",
    "mime_type": "video/mp4",
    "sha256": "jkl012...",
    "id": "MEDIA_ID_654"
  }
}
FieldTypeDescription
video.idstringMedia ID for downloading the video
video.mime_typestringvideo/mp4 or video/3gp
video.captionstringCaption written by the user (optional)
Received when a user sends a WhatsApp sticker.
{
  "from": "905399876543",
  "id": "wamid.xxx",
  "timestamp": "1711900250",
  "type": "sticker",
  "sticker": {
    "mime_type": "image/webp",
    "sha256": "mno345...",
    "id": "MEDIA_ID_987",
    "animated": false
  }
}
FieldTypeDescription
sticker.idstringMedia ID for downloading the sticker
sticker.animatedbooleantrue = animated sticker
sticker.mime_typestringAlways image/webp
Received when a user shares their location.
{
  "from": "905399876543",
  "id": "wamid.xxx",
  "timestamp": "1711900300",
  "type": "location",
  "location": {
    "latitude": 41.0082376,
    "longitude": 28.9783589,
    "name": "Taksim Square",
    "address": "Taksim, Istanbul"
  }
}
FieldTypeDescription
location.latitudenumberLatitude coordinate
location.longitudenumberLongitude coordinate
location.namestringPlace name (optional, set by user)
location.addressstringFull address (optional)
Received when a user shares a contact card.
{
  "from": "905399876543",
  "id": "wamid.xxx",
  "timestamp": "1711900350",
  "type": "contacts",
  "contacts": [{
    "name": {
      "formatted_name": "Jane Doe",
      "first_name": "Jane",
      "last_name": "Doe"
    },
    "phones": [
      { "phone": "+905321234567", "type": "CELL" }
    ],
    "emails": [
      { "email": "jane@example.com", "type": "WORK" }
    ]
  }]
}
FieldTypeDescription
contacts[].name.formatted_namestringFull name of the shared contact
contacts[].phones[].phonestringPhone number
contacts[].emails[].emailstringEmail address
Received when a user taps one of the quick-reply buttons you sent.
{
  "from": "905399876543",
  "id": "wamid.xxx",
  "timestamp": "1711900400",
  "type": "interactive",
  "interactive": {
    "type": "button_reply",
    "button_reply": {
      "id": "home_delivery",
      "title": "Home Delivery"
    }
  }
}
FieldTypeDescription
interactive.button_reply.idstringThe reply.id you set when sending the button message
interactive.button_reply.titlestringThe button label shown to the user
Received when a user selects a row from the list message you sent.
{
  "from": "905399876543",
  "id": "wamid.xxx",
  "timestamp": "1711900450",
  "type": "interactive",
  "interactive": {
    "type": "list_reply",
    "list_reply": {
      "id": "track_order",
      "title": "Track Order",
      "description": "Find out where your order is"
    }
  }
}
FieldTypeDescription
list_reply.idstringThe row id you set in the list sections
list_reply.titlestringThe row title
list_reply.descriptionstringThe row description (if set)
Received when a user reacts to one of your messages with an emoji.
{
  "from": "905399876543",
  "id": "wamid.xxx",
  "timestamp": "1711900500",
  "type": "reaction",
  "reaction": {
    "message_id": "wamid.HBgNOTA1Mzk5ODc2NTQzFQIAERgSM0Y3RDg5NjREOUNBMkFFNEE3AA==",
    "emoji": "👍"
  }
}
FieldTypeDescription
reaction.message_idstringThe wamid of the message that was reacted to
reaction.emojistringThe emoji character (empty string = reaction removed)
Received when a user places an order through a WhatsApp catalog.
{
  "from": "905399876543",
  "id": "wamid.xxx",
  "timestamp": "1711900550",
  "type": "order",
  "order": {
    "catalog_id": "CATALOG_ID_123",
    "text": "Please deliver before 6pm",
    "product_items": [
      {
        "product_retailer_id": "SKU-001",
        "quantity": 2,
        "item_price": 19.99,
        "currency": "USD"
      }
    ]
  }
}
FieldTypeDescription
order.catalog_idstringMeta catalog ID
order.textstringNote from the user (optional)
order.product_items[].product_retailer_idstringYour product SKU/ID
order.product_items[].quantitynumberOrdered quantity
order.product_items[].item_pricenumberUnit price at time of order
order.product_items[].currencystringISO 4217 currency code

Parsing Incoming Messages

function processWebhook(body) {
  const changes = body?.entry?.[0]?.changes ?? [];

  for (const change of changes) {
    const value = change.value;
    const contact = value?.contacts?.[0];

    for (const msg of value?.messages ?? []) {
      const from = msg.from;
      const name = contact?.profile?.name ?? 'Unknown';

      switch (msg.type) {
        case 'text':
          console.log(`[TEXT] ${name} (${from}): ${msg.text.body}`);
          break;

        case 'image':
        case 'audio':
        case 'document':
        case 'video':
        case 'sticker':
          console.log(`[${msg.type.toUpperCase()}] ${name} sent media: ${msg[msg.type].id}`);
          // Download via Media API using msg[msg.type].id
          break;

        case 'location':
          console.log(`[LOCATION] ${name}: ${msg.location.latitude}, ${msg.location.longitude}`);
          break;

        case 'interactive':
          if (msg.interactive.type === 'button_reply') {
            console.log(`[BUTTON] ${name} tapped: ${msg.interactive.button_reply.id}`);
          } else if (msg.interactive.type === 'list_reply') {
            console.log(`[LIST] ${name} selected: ${msg.interactive.list_reply.id}`);
          }
          break;

        case 'reaction':
          console.log(`[REACTION] ${name} reacted ${msg.reaction.emoji} to ${msg.reaction.message_id}`);
          break;

        default:
          console.log(`[UNHANDLED] type: ${msg.type}`);
      }
    }
  }
}

Tips

Always handle the default / else case for unknown type values. Meta regularly introduces new message types (polls, payment events, etc.) and unhandled types will otherwise cause silent failures in your pipeline.
For media messages, image.id, audio.id, etc. are temporary Media IDs that expire after 30 days. Download and store the file on your own infrastructure promptly.
The same incoming message may be delivered more than once due to network retries. Use messages[0].id (the wamid) as an idempotency key in your database before processing.