{
  1. Introduction
  2. Receiving messages
    1. Contents format
    2. Media messages
    3. Channel feature support
    4. Whitelisting
  3. SMS
  4. WhatsApp
    1. Media message
    2. Location message
    3. Contact message
    4. Replies
    5. Interactive replies
  5. Apple Business Chat
  6. Facebook Messenger
    1. Media message
    2. Suggestions
  7. Instagram Messaging
    1. Media message
    2. Suggestions
    3. Story reply
  8. Viber
  9. Twitter Direct messages
    1. Media message
    2. Suggestions
  10. Google Business Messages
    1. Media message
    2. Suggestions
    3. Message Context
  11. RCS

MO Webhooks

Introduction

You can receive your incoming messages (Mobile Originating aka MO) for channels supported by the CM.com Business Messaging API in your own systems, by registering a webhook in the Channels-app. After registering an HTTPS web address you will start receiving the incoming messages.

Receiving messages

In order to receive the incoming messages, you need to build a webservice where our systems can deliver the messages. This is called a webhook. Via the webhook you will be notified by CM.com of the new message content and metadata using a POST call to your registered web service in the JSON content format. To indicate you have received the message you need to reply with an HTTP 200 OK statuscode. You do not need to send any content back in the reply. You can receive incoming messages from SMS channels, WhatsApp, Apple Business Chat, Viber and RCS. using these webhooks.

If your web service returns anything else other than response code 200 OK, we will consider the message as not having been delivered. Our services will temporarily hold the information and retry delivery every 5 minutes (for a maximum of one month).

Contents format

Webhook calls are made using HTTP POST with the Content-Type application/json and are in the UTF-8 character set. You will receive a JSON object like this on the registered URLs:

Field Description
from Information about the sender. (See below)
to Information about the recipient of the message. (See below)
message The content of the message. (See below)
reference A reference to an outgoing message that this message is a response to. (See below)
groupings Array of exactly three strings with the grouping information. (See below)
timeUtc The time (yyyy-MM-ddTHH:mm:ss) of the message in UTC.
channel The channel that the message was sent with. (e.g. "WhatsApp", "SMS", "Apple Business Chat", "RCS", "Viber", "Twitter")
messageContext Field to indicate which MT or MO the consumer has replied to

Note: For replies, both 'reference' and 'groupings' return information sent with the original message that was responded on. This value is only supplied when the message was received as a reply and not when it was received as a message on a distinct keyword or phone-number match. This is currently only supported on SMS.

Note: The field time will be removed early 2020. Please use timeUtc going forward.

From:

Field Description
name For some channels, such as WhatsApp, this will contain the profile name of the user (if set)
number Phone number or identifier of the device from where the message originated.

To:

Field Description
number Phone number or identifier (MSISDN/shortcode/Twitter snowflake ID) to which the message was sent.

Message:

Field Description
text The text content of the message, when the message contains text.
media A media item can be an image, audio, movie or document file. If no media item was sent all fields will be empty
custom Custom object, can be anything a specific channel supports such as a location or a list of contact items.

Example text message

{
    "from": {
        "number": "+316012345678",
        "name": ""
    },
    "to": {
        "number": "3669"
    },
    "message": {
        "text": "This is an example message",
        "media": {
            "mediaUri": "",
            "contentType": "",
            "title": ""
        },
        "custom": {}
    },
    "reference": "2f2d42ac-3809-40fb-bce5-dc720e400000",
    "groupings": [
        "39373ce0-f4aa-4918-8ff1-3cef7f77b112",
        "messagesApi",
        ""
    ],
    "timeUtc": "2019-11-05T08:32:33",
    "channel": "WhatsApp"
}

Media messages

Most channels support some sort of media capability for receiving images, audio, video and/or attachments. Please see channel specific information for details on capabilities.

Media:

Field Description
mediaUri A unique download URL for the file
contentType The mime type of the file as indicated by the channel
title A caption or title belonging to the media file

You should expect to receive media files of almost any type that the channel you are using supports. Images, videos and documents are all possible. You need to download the specific media item from the unique link specified in the mediaUri attribute. All files are deleted after a maximum of 30 days, downloaded or not.

We are not a media host for your audience. If you want to expose the media file you receive to a user, you are responsible for 'republishing' the file within your system and disclosing this file to the correct audience. You should never pass the mediaUri directly to your own audience.

Example message with media item

{
    "reference": "2f2d42ac-3809-40fb-bce5-dc720e400000",
    "from": {
        "number": "+316012345678",
        "name": "Demo"
    },
    "to": {
        "number": "00316012345678"
    },
    "message": {
        "text": "",
        "media": {
            "mediaUri": "https://temp.com/adsadsa",
            "contentType": "image/png",
            "title": "Media items can be empty"
        },
        "custom": {}
    },
    "groupings": [
        "39373ce0-f4aa-4918-8ff1-3cef7f77b112",
        "messagesApi",
        ""
    ],
    "timeUtc": "2019-11-05T08:32:33",
    "channel": "WhatsApp"
}

Channel feature support

Not all channels support the same (combinations of) item types. For details and documentation on a conversation item type, we ask you to refer to documentation of the specific channel.

Conversation item type WhatsApp SMS Twitter FBM GBM Instagram Messaging
Text
Media x
- Image x
- Video x x x
- Audio x x x x
Location x x x x x
Contact x x x x x
Suggestions √ * x
- Reply √ * x
- OpenUrl x x x x x
- Dial x x x x x

* WhatsApp interactive replies work somewhat differently from suggestion replies in Twitter, FBM, GBM and Instagram Messaging. Please refer to the documentation for details.

Whitelisting

If you want your systems to be certain that requests are sent from CM.com's systems and are not intiated by a spoofing third party, you can limit reception of MO messages to those originating from our IP ranges.

The IP ranges of the services that send MO messages and could be used for our outbound traffic are:

  • 31.169.56.0/21
  • 85.119.48.0/21
  • 188.94.184.0/22

Note You should whitelist all these IP ranges. We cannot guarantee an exact IP addresses of specific services within these ranges as the servers can change IP within this range at any time.

SMS messages

Replies are defined as messages that are returned on an outgoing message, within a certain period. This period can vary; it is at least 5 days. To receive replies to SMS messages, you are required to send out the original message with a SenderID that is reply-enabled. Messages to that number need to be delivered at CM's messaging platform and the number must have been configured to process reply messages.

CM has a set of shared numbers available that are free to use to receive your replies on. The downside of using one of these numbers, is that traffic from other customers using the same number could interfere with your traffic, making replies unreliable. For reliant and confidential communication, we advise you to obtain a dedicated phone number. Contact support for more information about choosing and acquiring a suitable SenderID.

This feature is free of charge, and can be configured via the CM-Gateway app. (For the reception of inbound messages, costs may apply, depending on contract and country of destination.) Click the 'Reply settings' button in the top right to set up your incoming messages. Enable replies for your account using the checkmark at the top and at the bottom, add your URL to send your message to. The default 'Json' format is the preferred choice, as the other formats (Xml and Get) are subject to change and might be deprecated in the near future.

WhatsApp

WhatsApp media message

See also receiving media messages

The support and restrictions for media files is identical to sending.

  • WhatsApp GIFs will be received as MP4 videos
  • WhatsApp Stickers are received as media messages of the type image/webp

WhatsApp location message

It is possible to receive a location from a user. Live location updates are not supported.

Field Description Required
latitude Latitude of the location (can be negative) Yes
longtitude Longitude of the location (can be negative) Yes
label Name of the location No
searchQuery Address or search query of the location No

Example message

{
    "reference": "2f2d42ac-3809-40fb-bce5-dc720e400000",
    "from": {
        "number": "+316012345678",
        "name": "Demo"
    },
    "to": {
        "number": "+316012345678"
    },
    "message": {
        "text": "",
        "media": {
            "mediaUri": "",
            "contentType": "",
            "title": ""
        },
        "custom": {
            "location": {
                "latitude": 51.603802,
                "longitude": 4.770821,
                "label": "CM HQ",
                "searchQuery": "Konijnenberg 30"
            }
        }
    },
    "groupings": [
        "39373ce0-f4aa-4918-8ff1-3cef7f77b112",
        "messagesApi",
        ""
    ],
    "timeUtc": "2019-11-05T08:32:33",
    "channel": "WhatsApp"
}

WhatsApp contact message

It is possible to receive a message with contact information. You can receive 1 or more contacts cards at once and they will be an array in the custom.contacts attribute.

The format of the keys and values are specific to WhatsApp. The overall design of this should look familiar if have experience with the VCF contact card format, or the address book formats of Android and/or iOS.

An expansive example of the keys and values can be found in the documentation of WhatsApp.

Example message

{
    "reference": "2f2d42ac-3809-40fb-bce5-dc720e400000",
    "from": {
        "number": "+316012345678",
        "name": "Demo"
    },
    "to": {
        "number": "+316012345678"
    },
    "message": {
        "text": "",
        "media": {
            "mediaUri": "",
            "contentType": "",
            "title": ""
        },
        "custom": {
            "contacts": [
                {
                    "addresses": [
                        {
                            "city": "Breda",
                            "country": "Netherlands",
                            "country_code": "NL",
                            "street": "Konijnenberg 30",
                            "type": "WORK",
                            "zip": "4825 BD"
                        }
                    ],
                    "name": {
                        "formatted_name": "CM Developer",
                        "last_name": "Your last name"
                    }
                }
            ]
        }
    },
    "groupings": [
        "39373ce0-f4aa-4918-8ff1-3cef7f77b112",
        "messagesApi",
        ""
    ],
    "timeUtc": "2019-11-05T08:32:33",
    "channel": "WhatsApp"
}

WhatsApp replies

In WhatsApp it is possible to refer to a specific message. This is also known as a reply an can be done on both MT as MO messages.

Please note that you need include the message context field in your MOWebhook. If you currently do not receive MO with a message context, you are unable to see which message was replied to. Please contact support if you don't have the message context field included.

Replies for MT

To be able to see to which MT message the consumer is replying to, you will have to include a reference to the MT message you are sending:

{
    "messages": {
        "msg": [{
            "body": {
                "TYPE": "AUTO",
                "content": "Reply to this message if you want to receive an invitation to our next webinar"
            },
            "allowedChannels": ["WhatsApp"],
            "reference": "referencereplytest",
            "to": [{
                "number": "0031612345678"
            }],
            "from": "CM.com"
        }],
        "authentication": {
            "productToken": "YourProductToken"
        }
    }
}

If the consumer replies you will receive the following MO:

{
    "reference": "ABGGMWNhcIFfAhBa1rc5B-fkdkERREvkk",
    "messageContext": "referencereplytest",
    "name": "John Doe",
    "to": {
        "number": "003197008101015"
    },
    "message": {
        "text": "I would like an invite to the Webinar",
        "media": {
            "mediaUri": "",
            "contentType": "",
            "title": ""
        },
        "custom": {}
    },
    "groupings": ["", "", ""],
    "timeUtc": "2019-11-05T08:32:33"
}

As you can see, the messageContext field will have the same value as the reference you have passed through in the MT.

Replies for MO

To be able to see to which MO message the consumer is replying to, you will have to keep track of references received in the MO payload. For example:

{
    "reference": "ADFGDFHNhcIcksdfSDFVSF0oEzwYDFDFClksdDF",
    "messageContext": "",
    "name": "John Doe",
    "to": {
        "number": "0031612345678"
    },
    "message": {
        "text": "I would like to reserve a table for four please.",
        "media": {
            "mediaUri": "",
            "contentType": "",
            "title": ""
        },
        "custom": {}
    },
    "groupings": ["", "", ""],
    "timeUtc": "2019-11-05T08:32:33"
}

5 minutes later, the consumer has replied to his own MO, you will receive following MO :

{
    "reference": "SDFSDFNhcDFlcsdUSbGTGKTaLKokdVw0GVL",
    "messageContext": "ADFGDFHNhcIcksdfSDFVSF0oEzwYDFDFClksdDF",
    "name": "John Doe",
    "to": {
        "number": "0031612345678"
    },
    "message": {
        "text": "Scratch that, a friend can't make it, can you make it a table for three please.",
        "media": {
            "mediaUri": "",
            "contentType": "",
            "title": ""
        },
        "custom": {}
    },
    "groupings": ["", "", ""],
    "timeUtc": "2019-11-05T08:32:33"
}

You can check to which MO was replied to by using the messageContext field, this field will have the same value as the reference of the original MO.

WhatsApp interactive replies

When an end-user interacts with a button of an interactive template, there is also extra button-information available. This will make it possible to identify which button has been interacted with by the end-user. The text of the button will also be available in the regular text field if the button was a quick_reply.

payload is the value that can be provided when you send the template. A payload can be assigned to each button when sending the template to the end-user. When the user clicks the button, the payload of that specific button will be available in the body.

{
    "reference": "my-reference",
    "messageContext": "",
    "name": "John Doe",
    "to": {
        "number": "0031612345678"
    },
    "message": {
        "text": "Yes, this is OK",
        "media": {
            "mediaUri": "",
            "contentType": "",
            "referenceTicket": ""
        },
        "custom": {
            "button": {
                "label": "Yes, this is OK",
                // Business Developer-defined payload
                "payload": "aGlzIHRoaXMgaXMgY29vZHNhc2phZHdpcXdlMGZoIGFTIEZISUQgV1FEV0RT"
            }
        }
    },
    "groupings": ["", "", ""],
    "timeUtc": "2019-11-05T08:32:33"
}

Apple Business Chat (ABC)

For service requests, users initiate a conversation and will reach out to you. To link incoming messages to your outbound messages, the from/to field is used with an ABC-identifier value.

An ABC-identifier or the 'Opaque user identifier' as Apple calls it, is a string of alpha numerical characters that you have received as the from address in an incoming message. This is the only information you have about a user on the Apple platform. You do not receive the name, profile image, location or anything else the user has not shared themselves within conversation. It is possible, but not necessary, that you will receive a UUID as an end-user identifier. This identifier is mapped in the CM.com platform.

Apple Business Chat supports receiving text messages and receiving media messages.

Apple Business Chat intent and group values identifiers

It is possible to define intent, group and body parameters in the link that is presented to end-users to start the conversation. These values will be forwarded to your webhook. Intent and group can be used to route traffic directly to the appropriate actions or persons. read more

Do note that the intent and group will only be sent in the first message of the conversation.

{
    "reference": "515836577",
    "messageContext": "",
    "from": {
        "number": "6f2de4d4cc6aa17da2e11c3bff5843aa",
        "name": ""
    },
    "to": {
        "number": "00iMsg20241c26-f863-4faf-8bb2-ad4213641caa"
    },
    "message": {
        "text": "Hi",
        "media": {
            "mediaUri": "",
            "contentType": "",
            "title": ""
        },
        "custom": {
            "MESSAGETYPE": "Text",
            "INTENT": "apidocs",
            "GROUP": "techsupport"
        }
    },
    "groupings": [
        "",
        "",
        ""
    ],
    "time": "2021-05-19 15:42:28",
    "timeUtc": "2021-05-19T13:42:28",
    "channel": "Apple Business Chat"
}

Apple Business Chat List picker or time picker response

When using a list or time picker, the label of the selected element will be sent as text in the response.

{
    "reference": "515836578",
    "messageContext": "",
    "from": {
        "number": "6f2de4d4cc6aa17da2e11c3bff5843aa",
        "name": ""
    },
    "to": {
        "number": "00iMsg20241c26-f863-4faf-8bb2-ad4213641caa"
    },
    "message": {
        "text": "Ace of Spades",
        "media": {
            "mediaUri": "",
            "contentType": "",
            "title": ""
        },
        "custom": {
            "MESSAGETYPE": "Text"
        }
    },
    "groupings": [
        "",
        "",
        ""
    ],
    "time": "2021-05-19 16:04:45",
    "timeUtc": "2021-05-19T14:04:45",
    "channel": "Apple Business Chat"
}

Apple Business Chat Closing the conversation

Conversations in Apple Business Chat remain active for use as long as the end user does not close the conversation. When that does happen you will receive a 'Close' message and are no longer allowed or able to send messages to this user.

{
    "reference": "515836576",
    "messageContext": "",
    "from": {
        "number": "6f2de4d4cc6aa17da2e11c3bff5843aa",
        "name": ""
    },
    "to": {
        "number": "00iMsg20241c26-f863-4faf-8bb2-ad4213641caa"
    },
    "message": {
        "text": "CLOSE_CONVERSATION",
        "media": {
            "mediaUri": "",
            "contentType": "",
            "title": ""
        },
        "custom": {
            "MESSAGETYPE": "Close"
        }
    },
    "groupings": [
        "",
        "",
        ""
    ],
    "time": "2021-05-19 17:04:45",
    "timeUtc": "2021-05-19T15:04:45",
    "channel": "Apple Business Chat"
}

Apple Business Chat Other

It is also possible to make a payment using Apple Pay. Setting this up requires some custom work and we therefor ask you to contact our support team.

If you have your own app and want to have your own Apple Business Chat integrations than this is possible as well. Again, please contact our support team.

Facebook Messenger (FBM)

The main difference to other channels is the fact that Facebook Messenger uses numeric identifier for a sender and recipient. So called "Page Scoped User ID (PSID)" for the sender and a "Page ID" for the recipient of the MO message. A person is assigned a unique PSID for each Facebook Page they start a conversation with.

These identifiers are visible in the CM.com platform as the userid below channels...Facebook Messenger.

Media message

See also receiving media messages

The support and restrictions for media files are the same as for sending Facebook Messenger messages.

Media files send by Facebook users will be hosted behind CM authentication as it may contain sensitive information of the user.

In order to download these media files, your request towards the provided media url should contain the X-CM-PRODUCTTOKEN header with your product token as its value. As a registered user, you can find your product token on our platform in the Channels app or for older SMS accounts in the Gateway app.

NOTE: Your product token is private information and should never be incorporated into webpages and/or mobile applications where it can be exposed to 3rd parties.

Suggestions

When the customer clicks on an item in a quick reply suggestion list, the reply will have the original action, and the original postbackData in the custom/suggestions item:

"custom: "{
  "suggestions": [
    {
      "action": "Reply",
      "postbackData": "EDIT_APPOINTMENT"
    }
  ]
}
Example message
{
  "reference": "my-reference",
  "messageContext": "",
  "from": {
    "number": "87654321",
    "name": "John Doe"
  },
  "to": {
    "number": "12345678"
  },
  "message": {
    "text": "Edit appointment",
    "media": {
      "mediaUri": "",
      "contentType": "",
      "title": ""
    },
    "custom": {
      "suggestions": [
        {
          "action": "Reply",
          "postbackData": "EDIT_APPOINTMENT"
        }
      ]
    }
  },
  "groupings": ["", "", ""],
  "time": "2021-05-27 15:47:52",
  "timeUtc": "2021-05-27T13:47:52",
  "channel": "Facebook Messenger"
}

Instagram Messaging

The main difference to other channels is the fact that Instagram uses numeric identifier for a sender and recipient. So called "Instagram Scoped User ID (IGSID)" for the sender and a "Instagram account ID" for the recipient of the MO message. A person is assigned a unique IGSID for each Instagram Business account they start a conversation with.

These identifiers are visible in the CM.com platform as the userid below channels...Instagram.

Media message

See also receiving media messages

Instagram leverages CDN URLs which allow you to retrieve rich media content shared by users. It is not allowed by Instagram to download, retain, or otherwise store the media content sent or made accessible by any user (or enable any third party to do so) and you, or any third party, must not do anything to circumvent expiration and/or removal of any link to such media content.

CM only provides the CDN URL so Instagram has full control of the content. This means, the CDN URL will not return the media when the content is deleted or expired at Instagram. If you want to make use of the media content, you are only allowed to store the privacy aware CDN URL in your system and use this link to render the media made accessible.

Example message
{
  "reference": "my-reference",
  "messageContext": "",
  "from": {
    "number": "87654321",
    "name": "John Doe"
  },
  "to": {
    "number": "12345678"
  },
  "message": {
    "text": "",
    "media": {
      "mediaUri": "https://lookaside.fbsbx.com/ig_messaging_cdn/?asset_id=1234&signature=AAAA",
      "contentType": "",
      "title": ""
    },
    "custom": {}
  },
  "groupings": ["", "", ""],
  "time": "2021-05-27 15:47:52",
  "timeUtc": "2021-05-27T13:47:52",
  "channel": "Instagram"
}

Suggestions

When the customer clicks on an item in a quick reply suggestion list, the reply will have the original action, and the original postbackData in the custom/suggestions item:

"custom: "{
  "suggestions": [
    {
      "action": "Reply",
      "postbackData": "EDIT_APPOINTMENT"
    }
  ]
}
Example message
{
  "reference": "my-reference",
  "messageContext": "",
  "from": {
    "number": "87654321",
    "name": "John Doe"
  },
  "to": {
    "number": "12345678"
  },
  "message": {
    "text": "Edit appointment",
    "media": {
      "mediaUri": "",
      "contentType": "",
      "title": ""
    },
    "custom": {
      "suggestions": [
        {
          "action": "Reply",
          "postbackData": "EDIT_APPOINTMENT"
        }
      ]
    }
  },
  "groupings": ["", "", ""],
  "time": "2021-05-27 15:47:52",
  "timeUtc": "2021-05-27T13:47:52",
  "channel": "Instagram"
}

Story reply

When an end-user replies to one of your Instagram stories, Instagram returns metadata in a "reply_to" item containing a reference of the story the user replied to. This metadata contains information such as the id and the media url of your Instagram story. This is Instagram specific data, and we return it in a "custom/rawPayload" item.

Keep in mind: the media url of the Instagram story follows the same CDN rules of a media message. In addition, its only available for 24 hours before Instagram will expire the media url.

Below is an example of the rawPayload containing "reply_to" data.

"custom": {
  "rawPayload": {
    "reply_to": {
      "story": {
        "id": string,
        "url": string
      }
    }
  }
}
Message Example
{  
  "reference": "my-reference",
  "messageContext": "",
  "from": {
    "number": "87654321",
    "name": "John Doe"
  },
  "to": {
    "number": "12345678"
  },
  "message": {
    "text": "Nice Instagram story",
    "media": {
      "mediaUri": "",
      "contentType": "",
      "title": ""
    },
    "custom": {
      "rawPayload": {
        "reply_to": {
          "story": {
            "id": "1234",
            "url": "https://lookaside.fbsbx.com/ig_messaging_cdn/?asset_id=1234&signature=AAAA"
          }
        }
      }
    }
  },
  "groupings": ["", "", ""],
  "time": "2021-05-27 15:47:52",
  "timeUtc": "2021-05-27T13:47:52",
  "channel": "Instagram"
}

Viber

Viber supports receiving text messages and receiving media messages.

Twitter direct messages

The main difference to other channels is the fact that Twitter uses the so-called Twitter snowflake as an identifier for a sender and a recipient.

Media message

See also receiving media messages

The support and restrictions for media files are the same as for sending Twitter direct messages.

  • Twitter GIFs will be received as MP4 videos

Media files send by Twitter users will be hosted behind CM authentication as it may contain sensitive information of the user.

In order to download these media files, your request towards the provided media url should contain the X-CM-PRODUCTTOKEN header with your product token as its value. As a registered user, you can find your product token on our platform in the Channels app or for older SMS accounts in the Gateway app.

NOTE: Your product token is private information and should never be incorporated into webpages and/or mobile applications where it can be exposed to 3rd parties.

Suggestions

When the customer clicks on an item in a quick reply suggestion list, the reply will have the original action, and the original postbackData in the custom/suggestions item:

"custom: "{
  "suggestions": [
    {
      "action": "Reply",
      "postbackData": "EDIT_APPOINTMENT"
    }
  ]
}
Example message
{
  "reference": "my-reference",
  "messageContext": "",
  "from": {
    "number": "87654321",
    "name": "@JohnDoe"
  },
  "to": {
    "number": "12345678"
  },
  "message": {
    "text": "I want to edit my appointment",
    "media": {
      "mediaUri": "",
      "contentType": "",
      "title": ""
    },
    "custom": {
      "suggestions": [
        {
          "action": "Reply",
          "postbackData": "EDIT_APPOINTMENT"
        }
      ]
    }
  },
  "groupings": ["", "", ""],
  "time": "2021-05-27 13:01:27",
  "timeUtc": "2021-05-27T11:01:27",
  "channel": "Twitter"
}

Google Business Messages (GBM)

Please note that Google Business Messages uses id's (more technically GUIDs) as a sender and recipient. In the from: field, you will find the GUID of the sender. Due to technical limitations, when you receive an MO message, the id in the to: field will be formatted without the dashes (-).

Media message

See also receiving media messages

Media files send by Google users will be hosted behind CM authentication as it may contain sensitive information of the user.

In order to download these media files, your request towards the provided media url should contain the X-CM-PRODUCTTOKEN header with your product token as its value. As a registered user, you can find your product token on our platform in the Channels app or for older SMS accounts in the Gateway app.

NOTE: Your product token is private information and should never be incorporated into webpages and/or mobile applications where it can be exposed to 3rd parties.

Suggestions

When the customer clicks on an item in a quick reply suggestion list, the reply will have the original action, and the original postbackData that was added to the suggestion when sending the message in the custom/suggestions item:

"custom: "{
  "suggestions": [
    {
      "action": "Reply",
      "postbackData": "EDIT_APPOINTMENT"
    }
  ]
}

Other types of suggestions return the same basic structure, but with a different "action". For example, a "dial" action, will look like this:

"custom": {
  "suggestions": [
    {
      "action": "Dial",
      "postbackData": "HQ_NUMBER"
    }
  ]
}

An "OpenUrl" action, will look like this:

"custom": {
  "suggestions": [
    {
      "action": "OpenUrl",
      "postbackData": "HQ_WEBSITE"
    }
  ]
}
Message Example
{
  "reference": "my-reference",
  "messageContext": "",
  "from": {
    "number": "00000000-0000-0000-0000-000000000000",
    "name": "John Doe"
  },
  "to": {
    "number": "11111111111111111111111111111111"
  },
  "message": {
    "text": "Edit appointment",
    "media": {
      "mediaUri": "",
      "contentType": "",
      "title": ""
    },
    "custom": {
      "suggestions": [
        {
          "action": "Reply",
          "postbackData": "EDIT_APPOINTMENT"
        }
      ]
    }
  },
  "groupings": ["", "", ""],
  "time": "2021-05-27 15:47:52",
  "timeUtc": "2021-05-27T13:47:52",
  "channel": "Google Business Messages"
}

Message Context

In addition, Google also returns metadata in a "context" item in messages from end-users. This metadata contains information such as the end-users locale, the entry point of the conversation and a Google specific place id. This is GBM specific data, and we return it in a "custom/rawPayload" item.

The contents of the "context" metadata can vary. An overview of possible data can be found here: https://developers.google.com/business-communications/business-messages/reference/rest/v1/Context Below is an example of the rawPayload containing "context" data.

"custom": {
  "rawPayload": {
    "context": {
      "entryPoint": string,
      "userInfo": {
        "displayName": string,
        "userDeviceLocale": string
      },
      "widget": {
        "url": string,
        "widgetContext": string
      },
      "resolvedLocale": string,
      "customContext": string,
      "placeId": string,
      "nearPlaceId": string
    }
  }
}
Message Example
{  
  "reference": "my-reference",
  "messageContext": "",
  "from": {
    "number": "00000000-0000-0000-0000-000000000000",
    "name": "John Doe"
  },
  "to": {
    "number": "11111111111111111111111111111111"
  },
  "message": {
    "text": "Where is your company located",
    "media": {
      "mediaUri": "",
      "contentType": "",
      "title": ""
    },
    "custom": {
      "rawPayload": {
        "context": {
          "entryPoint": "MAPS",
          "userInfo": {
            "displayName": "John Doe",
            "userDeviceLocale": "en-NL"
          },
          "resolvedLocale": "en"
        }
      }
    }
  },
  "groupings": ["", "", ""],
  "time": "2021-05-27 15:47:52",
  "timeUtc": "2021-05-27T13:47:52",
  "channel": "Google Business Messages"
}

Rich Communication Services (RCS)

RCS supports receiving text messages and receiving media messages.