Skip to content

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
}
  1. The rcs property is a flexible data structure that specifies the RCS message.
  2. The wa property is a JSON object that specifies a valid WhatsApp message structure.
  3. You must supply a value rcs or for wa.
  4. If you supply a value for sms and 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
}
  1. The id object must identify an existing template.
  2. If the template does not have any parameters, the model does not have to be supplied.
  3. If the template has parameters the model contains the name-value pairs to fill in the template.
  4. 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"
               }
            }
         }
      ]
   }
}