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
}
- 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. - You must supply a value
rcsor forwa. - If you supply a value for
smsand the fallback feature is activated for your account, an SMS will be sent when the recipient does not have RCS enabled.
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"
}
}
}
]
}
}