Message and event format in AWS End User Messaging Social - AWS End User Messaging Social

Message and event format in AWS End User Messaging Social

The JSON object for an event contains the AWS event header and WhatsApp JSON payload. For a list of the JSON WhatsApp notification payload and values, see Webhooks Notification Payload Reference and Message Status in the WhatsApp Business Platform Cloud API Reference.

AWS End User Messaging Social event header

The JSON object for an event contains the AWS event header and WhatsApp JSON. The header contains the AWS identifiers and ARNs of your WhatsApp Business Account (WABA) and phone number.

{ "MetaWabaIds": [ { "wabaId": "1234567890abcde", "arn": "arn:aws:social-messaging:us-east-1:123456789012:waba/fb2594b8a7974770b128a409e2example" } ], "MetaPhoneNumberIds": [ { "metaPhoneNumberId": "abcde1234567890", "arn": "arn:aws:social-messaging:us-east-1:123456789012:phone-number-id/976c72a700aac43eaf573ae050example" } ] } { //WhatsApp notification payload }

In the preceding example event:

  • 1234567890abcde is the WABA id from Meta.

  • abcde1234567890 is the phone number id from Meta.

  • fb2594b8a7974770b128a409e2example is the ID of the WhatsApp Business Account (WABA).

  • 976c72a700aac43eaf573ae050example is the ID of the phone number.

Example WhatsApp JSON for receiving a text message

The following shows the event record for an incoming text message from WhatsApp. The JSON is generated by WhatsApp. For a list of fields and their meaning, see Webhooks Notification Payload Reference in the WhatsApp Business Platform Cloud API Reference.

{ //AWS End User Messaging Social header } { "id": "365731266123456", "changes": [ { "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": "12065550100", "phone_number_id": "321010217760100" }, "contacts": [ { "profile": { "name": "Diego" }, "wa_id": "12065550102" } ], "messages": [ { "from": "14255550150", "id": "wamid.HBgLMTQyNTY5ODgzMDIVAgASGCBDNzBDRjM5MDU2ODEwMDkwREY4ODBDRDE0RjVGRkexample", "timestamp": "1723506035", "text": { "body": "Hi" }, "type": "text" } ] }, "field": "messages" } ] }

Example WhatsApp JSON for receiving a media message

The following shows the event record for an incoming media message. To retrieve the media file, use the GetWhatsAppMessageMedia API command. For a list of fields and their meaning, see Webhooks Notification Payload Reference

{ //AWS End User Messaging Social header } { "id": "365731266123456", "changes": [ { "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": "12065550100", "phone_number_id": "321010217760100" }, "contacts": [ { "profile": { "name": "Diego" }, "wa_id": "12065550102" } ], "messages": [ { "from": "14255550150", "id": "wamid.HBgLMTQyNTY5ODgzMDIVAgASGCBDNzBDRjM5MDU2ODEwMDkwREY4ODBDRDE0RjVGRkexample", "timestamp": "1723506230", "type": "image", "image": { "mime_type": "image/jpeg", "sha256": "BTD0xlqSZ7l02o+/upusiNStlEZhA/urkvKf143Uqjk=", "id": "530339869524171" } } ] }, "field": "messages" } ] }