Orai Webhook
Introduction
This documentation provides details on implementing both inbound and outbound webhooks for handling messaging status updates and message types. It covers the structure of JSON payloads, explanations of different status and message responses, as well as API calls to manage media.
Webhook Endpoint URL : – https://yourdomain.com/path/to/API/webhookapi
Data Format : The data is sent in raw JSON format
You should ensure that the webhook endpoint URL is set up to capture responses effectively. This means that the URL should be configured to receive and process both incoming responses & status from the webhook.
Inbound Webhook
When a user sends a message, you will receive various types of responses. These responses help you identify the type of message and its corresponding structure.
Message Types and Structures
You can differentiate between different message types, such as text, document, image, voice, and video. Each type has a distinct structure in the response, allowing you to easily extract and process the message content. When will have the Raw-JSON format.
Text Message
For text messages, the structure includes a text field with the message body.
{
“object”: “whatsapp_business_account”, “entry”: [
{
“id”: “116935331269730”,
“changes”: [
{
“value”: {
“messaging_product”: “whatsapp”, “metadata”: {
“display_phone_number”: “9715668XXXXX”,
“phone_number_id”: “1077976555XXXXX”
},
“contacts”: [
{
“profile”: {
“name”: “Anish Bagwan ”
},
“wa_id”: “9199819XXXXX”
}
],
“messages”: [
{
“from”: “9199819XXXXX”,
“id”:
“wamid.HBgMOTE5OTgxOTQ2NDXXXXXAEhggMzQ5NzI0RXXXXXAyNTlEQjc4RTXXXzA3MDdBXXXXXXXX”, “timestamp”: “1710845XXX”,
“text”: {
“body”: “Hi”
},
“type”: “text”
}
]
},
“field”: “messages”
}
]
}
]
}
Document Message
Document messages contain details such as the filename, caption, and id.
{
“object”: “whatsapp_business_account”, “entry”: [
{
“id”: “1169353312XXXXX”,
“changes”: [
{
“value”: {
“messaging_product”: “whatsapp”, “metadata”: {
“display_phone_number”: “9715668XXXXX”,
“phone_number_id”: “1077976555XXXXX”
},
“contacts”: [
{
“profile”: {
“name”: “Anish Bagwan ”
},
“wa_id”: “9199819XXXXX”
}
],
“messages”: [
{
“from”: “9199819XXXXX”,
“id”:
“wamid.HBgMOTE5OTgxOTQ2NDkyFQIAEhggQTM4MUZEQjY0NjE5RDgXXXXXXXXXXXXXXXXXXXXXXXXX”,
“timestamp”: “17108XXXXX”, “type”: “document”, “document”: {
“filename”: “E-Auction-Terms-and-Condition-for-CFD.pdf”, “mime_type”: “application/pdf”,
“sha256”: “GFKBtgQbYcpaRIXmZNMInDr/M2DV2sOoiR0lBGQqAsI=”, “id”: “11553590422XXXXX”
}
}
]
},
“field”: “messages”
}
]
}
]
}
Voice Message
Voice messages include the Id of the voice recording
{
“object”: “whatsapp_business_account”, “entry”: [
{
“id”: “1169353312XXXXX”,
“changes”: [
{
“value”: {
“messaging_product”: “whatsapp”, “metadata”: {
“display_phone_number”: “9715668XXXXX”,
“phone_number_id”: “1077976555XXXXX”
},
“contacts”: [
{
“profile”: {
“name”: “Anish Bagwan ”
},
“wa_id”: “9199819XXXXX”
}
],
“messages”: [
{
“from”: “9199819XXXXX”,
“id”:
“wamid.HBgMOTE5OTgxOTQ2NDkyFQIAEhggMDEXXXXXQURCMzcyNz IzM0XXXXX2ODVBMEXXXXXXXXXX”,
“timestamp”: “17108XXXXX”, “type”: “audio”,
“audio”: {
“mime_type”: “audio/ogg;
codecs=opus”,
“sha256”:
“b1yZG9YqTlrbrVsGDxwm7joQ0inyOCsTFKetOcXXXXX=”,
“id”: “11762395466XXXXX”,
“voice”: true
}
}
]
},
“field”: “messages”
}
]
}
]
}
Video Message
Video messages include the Id of the video.
{
“object”: “whatsapp_business_account”, “entry”: [
{
“id”: “1169353312XXXXX”,
“changes”: [
{
“value”: {
“messaging_product”: “whatsapp”, “metadata”: {
“display_phone_number”: “9715668XXXXX”,
“phone_number_id”: “1077976555XXXXX”
},
“contacts”: [
{
“profile”: {
“name”: “Anish Bagwan ”
},
“wa_id”: “9199819XXXXX”
}
],
“messages”: [
{
“from”: “9199819XXXXX”,
“id”:
“wamid.HBgMOTE5OTgxOTQ2NDkyFQIAEhggQjUXXXXXMTlDNDXXXXXc3ODQXXXXXRDg0Rjg4XXXXX0QA”,
“timestamp”: “17108XXXXX”, “type”: “video”,
“video”: {
“mime_type”: “video/mp4”, “sha256”:
“5bqajUK2kqPE4gt3dLk54dw7SorDcqlr4hVU6DXXXXX=”,
“id”: “3729027455XXXXX”
}
}
]
},
“field”: “messages”
}
]
}
]
}
Image Message
Image messages include the Id of the image
{
“object”: “whatsapp_business_account”, “entry”: [
{
“id”: “1169353312XXXXX”,
“changes”: [
{
“value”: {
“messaging_product”: “whatsapp”, “metadata”: {
“display_phone_number”: “97156XXXXX31”,
“phone_number_id”: “1077976XXXXX720”
},
“contacts”: [
{
“profile”: {
“name”: “Anish Bagwan ”
},
“wa_id”: “919981XXXXX”
}
],
“messages”: [
{
“from”: “919981XXXXX2”,
“id”:
“wamid.HBgMOTE5OTgxOTQ2NDkyFQIAEhXXXXXCMDcxRERFNzXXXXXc4ODkyMXXXXXAwODY0RUJXXXXX”,
“timestamp”: “17108XXXXX”, “type”: “image”,
“image”: {
“mime_type”: “image/jpeg”, “sha256”:
“pV/lEF7GLBlFhWxT8TjobyBLJV4rs9G6gOZuE6XXXXX=”,
“id”: “2613562303XXXXX”
}
}
]
},
“field”: “messages”
}
]
}
]
}
Status Webhook
When you send a message, the message may be template or text, you will receive various types of responses for every single message. These responses help you identify the type of status and its corresponding structure.
Status Types and Structures
You can differentiate between different status types, such as send, delivered and read. Each type has a distinct structure in the response, allowing you to easily extract and process the message content.
Status Response
Message Sent
{
“object”: “whatsapp_business_account”, “entry”: [
{
“id”: “1169353312XXXXX”,
“changes”: [
{
“value”: {
“messaging_product”: “whatsapp”, “metadata”: {
“display_phone_number”: “9715668XXXXX”,
“phone_number_id”: “1077976555XXXXX”
},
“statuses”: [
{
“id”: “wamid.HBgMOTE5OTgxOTQ2NDkyFQIAERgSQXXXXXA5RTQ0QTFGQzA0OXXXXX==”,
“status”: “sent”, “timestamp”: “17108XXXXX”,
“recipient_id”: “9199819XXXXX”, “conversation”: {
“id”: “fafd300d83a7fXXXXX29da90382XXXXX”,
“expiration_timestamp”: “17109XXXXX”,
“origin”: {
“type”: “service”
}
},
“pricing”: { “billable”: true,
“pricing_model”: “CBP”, “category”: “service”
}
}
]
},
“field”: “messages”
}
]
}
]
}
Message Delivered
{
“object”: “whatsapp_business_account”, “entry”: [
{
“id”: “1169353312XXXXX”,
“changes”: [
{
“value”: {
“messaging_product”: “whatsapp”, “metadata”: {
“display_phone_number”: “9715668XXXXX”,
“phone_number_id”: “1077976555XXXXX”
},
“statuses”: [
{
“id”:
“wamid.HBgMOTE5OTgxOTQ2NDkyFQXXXXXSQTIyODA5RTQ0QTFGQzA0OXXXXX==”,
“status”: “delivered”, “timestamp”: “17108XXXXX”,
“recipient_id”: “9199819XXXXX”, “conversation”: {
“id”: “fafd300d83a7f4a66a29da90382XXXXX”, “origin”: {
“type”: “service”
}
},
“pricing”: { “billable”: true,
“pricing_model”: “CBP”, “category”: “service”
}
}
]
},
“field”: “messages”
}
]
}
]
}
Message Read
{
“object”: “whatsapp_business_account”, “entry”: [
{
“id”: “1169353312XXXXX”,
“changes”: [
{
“value”: {
“messaging_product”: “whatsapp”, “metadata”: {
“display_phone_number”: “9715668XXXXX”,
“phone_number_id”: “1077976555XXXXX”
},
“statuses”: [
{
“id”:
“wamid.HBgMOTE5OTgxOTQ2NDkyFXXXXXgSQTIyODA5XXXXXTFGQzA0OXXXXX==”,
“status”: “read”, “timestamp”: “17108XXXXX”,
“recipient_id”: “9199819XXXXX”
}
]
},
“field”: “messages”
}
]
}
]
}
Conclusion
This documentation provides a comprehensive guide to implementing both inbound webhook. It covers status responses, various message types, and including status and message responses, along with API calls for media management. Make sure to replace placeholders with actual values where necessary.
