When you set up a webhook to receive Mobile-Originated (MO) responses from WhatsApp users (e.g., replies to your messages), SMSGatewayCenter sends a default JSON response. Below is an explanation of the MO response format and how to use it:
Understanding the MO Response Format #
The MO response is a JSON payload that contains details about the incoming message from a customer. Here’s a sample structure and its key components:
- metadata: Contains details about the WhatsApp Business API number.
- phone_number_id: The ID of your WhatsApp Business API number (e.g., “1111111111”).
- display_phone_number: The phone number displayed to users (e.g., “919999999999”).
- messaging_product: Identifies the platform, which will be “whatsapp”.
- messages: An array containing details of the incoming message.
- from: The customer’s phone number (e.g., “919152349309”).
- id: A unique message ID (e.g., “wamid.HBgMOTE4NDQ3NTA5MTYxFQIAEhggRDREQ0M0RDI2NURFOTc2OUY0QTJFMjU0OEMxNTJEMjQA”).
- text: The message content.
- body: The text of the message (e.g., “24”).
- type: The message type (e.g., “text”).
- timestamp: The UNIX timestamp of when the message was sent (e.g., “1682397841”).
- contacts: Information about the customer.
- profile: The customer’s profile details.
- name: The customer’s name (e.g., “CustomerProfileName”).
- wa_id: The customer’s WhatsApp ID (e.g., “911234567890”).
Setting Up a Webhook with Custom Parameters #
Configure Your Webhook
- Log in to your SMSGatewayCenter account at https://www.smsgatewaycenter.com/.
- Navigate to the WhatsApp Business API section in your dashboard and go to the webhook settings.
- Enter your webhook URL where the MO responses will be sent.
Add Custom Parameters and Headers
- While setting up the webhook, you can add custom parameters (e.g., to identify the source) and custom headers (e.g., for authentication) to the webhook request.
- For example, you might add a header like
Authorization: Bearer your-token
or a parameter likesource=whatsapp
.
Handle the MO Response
- Once the webhook is set up, SMSGatewayCenter will send the MO response in the JSON format shown above to your specified URL whenever a customer sends a message.
- Use the data in the JSON (e.g., customer’s phone number, message content) to trigger actions in your system, such as replying to the customer or updating your CRM.
Sample MO Response #
Here’s an example of what the MO response JSON looks like:
{
"metadata": {
"phone_number_id": "1111111111",
"display_phone_number": "919999999999"
},
"messaging_product": "whatsapp",
"messages": [
{
"from": "919152349309",
"id": "wamid.HBgMOTE4NDQ3NTA5MTYxFQIAEhggRDREQ0M0RDI2NURFOTc2OUY0QTJFMjU0OEMxNTJEMjQA",
"text": {
"body": "24"
},
"type": "text",
"timestamp": "1682397841"
}
],
"contacts": [
{
"profile": {
"name": "CustomerProfileName"
},
"wa_id": "911234567890"
}
]
}
This feature helps you capture and act on customer replies efficiently. For further assistance with setting up webhooks or handling MO responses, contact our support team at contact @ smsgatewaycenter . com or call +912228657726.