WhatsApp Interactive Message Templates
With the support of your TAM, you can configure structured objects to use WhatsApp interactive message templates, which allow you to deliver more information without being restricted by the 24-hour window.
The current list includes:
Messages containing quick reply buttons, where clicking the button sends into the room a reply that the bot is able to read in order to take further action if required.
Links only used on our side: we download the attachment and upload it on WhatsApp, the WhatsApp user does not see any difference if we use a link or an attachment.
Messages including in the body hyperlinks that redirect the user to an existing WhatsApp Connect chat room (given the customer provides the room information into the JSON structured object).
The Agent API (see https://developers.symphony.com/restapi/reference/create-message-v4) is used to send a message in an existing stream which accepts messageML and JSON data formats.
JSON data sent in a message can be interpreted in the aim to tell the Agent to display an interactive template on WhatsApp through the WhatsApp gateway.

Prerequisites
Interactive templates need to be created, then they must be approved by Facebook.
JSON data format used as an input of the Agent API call for interactive templates
A WhatsApp template payload comprises 6 elements:
A template_name corresponding to the template name defined in WhatsApp Manager
A language (optional) (since release 22.11) corresponding to the language to be used to send the template
A header _****_** (optional)** found at the top of the template
A body that comes after the header and contains the content of the template
A footer (optional) that is at the bottom of the template
Any button (optional)
These 4 parts correspond to the user interface that is used to define a template in WhatsApp Manager.

Format to send to the Agent to display the template
We can use the data object above to ask customers to provide all the information we need to send the template:
Template name
Parameters in the header (optional)
Parameters in the body (optional)
Buttons (optional)
Unlike the body and the header, the footer does not contain any parameters, only static data.
The type field allows to define the action targeted by the JSON message. In the ‘send_template’ case, the WhatsApp gateway interprets all the information from the payload object, and then sends the related template on WhatsApp.
Header format
The header property value is a JSON object which contains either the text value of a variable, or a link to a file.
Example 1: Text

Example 2: Redirection parameter

In the example above, if the streamId matches the right room, the template will be displayed as below (the wa.me URL is built from the streamId):
Click on the link to contact your advisor:`` ``https://wa.me/1XXXXXXXXXX
Example 3: Send a template with a PDF file in the header

Example 4: Send a template with a PDF file in the header (and a file sent in the request body)
The document parameters can be one of the following three types: IMAGE, VIDEO or DOCUMENT.
If the link of the document is present, the template will retrieve it, and then use a related PDF file found as an attachment field of the template message.
If both a link and an attachment are present (the link of the document in the payload, and the attachment in the request body), the link will be used.
If no link is present and there are multiple attachments in the request body, the first attachment in the template will be used.
In the example above, the backend checks if the parameters object contains the type DOCUMENT, and if the attachment field is pointing to a file link.
If the corresponding file is correctly retrieved, it will extract the data and the fileName in order to upload it directly on WhatsApp.
Body format
The body field is an array that can be either empty or contain a sub-object as JSON object.
Each sub-object represents the text value of a variable declared in the related template.
The order of the sub-objects follows the order of the variables declaration in the template.
The sub-object must have a type attribute which supports two possible values: TEXT or REDIRECT:
If the sub-object is TEXT, an additional attribute named
textmust be filled.If the sub-object is REDIRECT, the additional field named
textis optional, unlike the fieldstreamIdwhich is mandatory.
Example of a body object
For example, you can have the template below:

With the following JSON data:
Footer format
Nothing needs to be provided in the JSON data, as the footer is static.
Button format
The JSON data should only contain data for buttons using the dynamic URL type. For static URLs, the information is already present in the WhatsApp templates.
Dynamic URL

Static URL
Example 1: Dynamic URL in first place

Data needs to be provided for the first dynamic URL button ("index": 0):
Example 2: Dynamic URL in second place
Data needs to be provided for the second dynamic URL button ("index": 1)

Last updated