Prerequisites
- Make sure that you choose share chats when scan the QR code
- Make sure that your webhook endpoint is listening for
whatsapp.smb.historyevents. See also Configure Webhooks, Retrieve a webhook endpoint API.
Inbound Text message
In this case, your webhook endpoint received an inbound text message:
- Contains plain text that the user sent.
- Contains the mentioned message information in
context. - Other types of messages can refer to whatsappInboundMessage
Code sample
curl 'https://YOUR-WEBHOOK-ENDPOINT-URL' \
-H 'Content-Type: application/json' \
-d '{
"id": "evt_eEkn26qar3nOB8md",
"type": "whatsapp.smb.history",
"apiVersion": "v2",
"createTime": "2023-02-22T12:00:00.000Z",
"whatsappInboundMessage": {
"id": "63f872f6741c165b4342a751",
"wamid": "wamid.HBgNODi...",
"wabaId": "WABA-ID",
"from": "CUSTOMER-PHONE-NUMBER",
"customerProfile": {
"name": "Joe"
},
"to": "BUSINESS-PHONE-NUMBER",
"sendTime": "2023-02-22T12:00:00.000Z",
"type": "text",
"text": {
"body": "OK"
},
"context": {
"from": "447901614024",
"id": "wamid.HBgNODr..."
}
}
}'Note
- Inbound messages are those sent from customers to your business phone numbers.
- The
context(optional) contains the mentioned message information, typically used to reply to a previous message sent by the user or your business.context.fromis the WhatsApp ID (phone number without the '+' prefix) of the user who sent the mentioned message.context.idis the original ID of the mentioned message on WhatsApp’s platform, starting withwamid..
Outbound Text message
In this case, your webhook endpoint received an outbound text message sent by a business customer to a WhatsApp user with the WhatsApp Business app or supported companion device:
- Contains plain text sent before.
- Contains the mentioned message information in
context. - Other types of messages can refer to WhatsApp Business App Sent Message Sync Webhook Examples
Code sample
curl 'https://YOUR-WEBHOOK-ENDPOINT-URL' \
-H 'Content-Type: application/json' \
-d '{
"id": "evt_eEVCy8eNqD9EvcFI",
"type": "whatsapp.smb.history",
"apiVersion": "v2",
"createTime": "2023-02-22T12:00:00.000Z",
"whatsappMessage": {
"id": "63f5d602367ea403f8175a6c",
"wamid": "wamid.BgNODYxN...",
"status": "sent",
"from": "BUSINESS-PHONE-NUMBER",
"to": "CUSTOMER-PHONE-NUMBER",
"wabaId": "WABA-ID",
"createTime": "2022-03-01T12:00:00.000Z",
"sendTime": "2022-03-01T12:00:01.000Z",
"bizType": "whatsapp",
"type": "text",
"text": {
"body": "Hi there! How can we help?"
},
"context": {
"message_id": "wamid.BgNODYxN..."
}
}
}'