Object schemas
Introduction
This page describes some JSON objects used by the API.
Message Content
The MessageContent object specifies the body of a message to send.
{
rcs: RCSMessage | null,
wa: WhatsAppMessage | null,
sms: string | null,
fallbackChain: string[] | null,
}
- The
rcsproperty is a flexible data structure that specifies the RCS message. - The
waproperty is a JSON object that specifies a valid WhatsApp message structure. - The
smsproperty is valid SMS text. - You must supply a value for one of the properties; the mandatory property depends on the provider you are sending to.
- You may supply values for more than one property. For instance, providing a value for
smsis required to fall back to SMS. - The
fallbackChainis an array of Brand Agent IDs. If a message fails for a reason that triggers fallback then the next item in the chain will be tried. The fallback processing can continue until the last item in the chain has been tried. - For every agent identified in the
fallbackChainthere must content for the assocciated provider type. For example if the chain contains an SMS agent then thesmsproperty must be supplied. - Each string in the
fallbackChainmust identify an existing agent. These values are not verified during submit, but they are verified during processing. An invalid entry will terminate fallback processing. - The
fallbackChaincannot contain any duplicates, and it cannot contain theagentIdassociated with the send request.
Template Content
The TemplateContent object specifies how you want to use a template.
See the template create endpoint if you want to add templates to your account.
{
id: string,
model: object|null
}
- The
idobject must identify an existing template. - If the template does not have any parameters, the
modeldoes not have to be supplied. - If the template has parameters the model contains the name-value pairs to fill in the template.
- Every template parameter must have an entry in the model.
For example, consider a template identified by welcome-message and parameter names: firstName and lastName.
An object that uses this template looks like this:
{
"id": "welcome-message",
"model": {
"firstName": "Bobby",
"lastName": "McCarthy"
}
}
RCS Message
RCS messages are sent in JSON format. The structure of this object determines the type of message the recipient will see on her device.
This section introduces a few possibilities by giving you examples, but these messages are very flexible, see the Google specifications for many more ideas.
Text message
Probably the simplest schema.
{
"contentMessage":{
"text":"Hello world"
}
}
URL actions
Here we ask the recipient a question, and open a web page with a URL that depends on the answer.
{
"contentMessage":{
"text":"What is your favourite colour?",
"suggestions":[
{
"action":{
"text":"Blue",
"postbackData": "fav-color-blue",
"openUrlAction":{
"url":"https://www.example.com?fav=blue"
}
}
},
{
"action":{
"text":"Red",
"postbackData": "fav-colour-red",
"openUrlAction":{
"url":"https://www.example.com?fav=red"
}
}
}
]
}
}