Text Message Template

Create and send a simple text template. This type of template allows you to predefine the configuration of text message and personalized fields (placeholders).

The body of a message template should only contain text, personalized fields and emojis. There is no limit to the number of parameters allowed in the body but when sending the message template, the total number of characters may not exceed 1024. If using parameters in the body, they may contain many characters as long as the total body length does not exceed the aforementioned 1024 characters.

The requirements before sending the Text Message Template to the recipients via WhatsApp Business API are the following:

  • Create the Text Message Template from the Digital Engagement Platform, in the Templates section or by the Templates API.

  • Once you have created the text message template, you'll need to submit it for WhatsApp approval. This can be done directly from the Digital Engagement Platform where the message template is created.

  • It takes WhatsApp up to 48 hours to review a message template.

  • After a text message template is created and approved, you can send it to recipients via API by copying each value of the template message to the request body.

🚧

WARNING

You must carefully copy each value according to its corresponding parameter you set when creating the text template via UI (Digital Engagement Platform) to the request body.

Sending Text Message Template

Once the text message template has been created via UI or API and approved, the next step is sending the template to the end users through the Messaging API.

🚧

WARNING

You can not edit the template content in the request body because the values of each parameter have been approved by WhatsApp. You are only able to edit the value for placeholders in the body (text message).

Personalized Fields (placeholders)

This section will guide you on how to include the placeholders in the request body for sending the WhatsApp text message template that you set up during the template creation.

Text Message Body

If the created template includes a "Text Message" component with placeholder(s), the example payload JSON will be as follows:

"placeholders": {  
    "name": "Elizabeth",  
    "lastName": "Smith"  
}

From the "placeholders" object, set as parameter the placeholder you configured that is inside double curly braces {{...}} when creating the template. Then set the value of the placeholder parameter.

For instance, according to the previous example, the text message body of the created template is as follows:

{  
   "type":"BODY",  
   "text":"Welcome {{name}} {{lastName}} we have a new offer for you!",  
   "example":{  
      "body_text": [  
         [  
            "John",  
            "Doe"  
         ]  
      ]  
   }  
}

The placeholders must be correctly formatted in the order in which the template was created.

🚧

WARNING

The personalized fields (placeholders) you set when creating the WhatsApp Text Message Template for each component are editable when you send the template.

Make sure these are examples and do not include any confidential or personal information.

Once the template is approved and ready to be sent, replace the placeholders with the actual (real) placeholder values.

We are going to send a text message template that includes a text body with a personalized field (placeholder) by entering the following parameters in the request body:

HTTP Request : POST / notification

{
  "channel": "WHATSAPP",
  "request": {
    "from":"1000000001",
    "to":"+1000000002",
    "templateName":"code_shipping",
    "templateLanguage":"en",
    "message": "Hi! your discount code is {{code}}",
    "placeholders":{
       "code":"34871"
    }
  }
}

The parameters presented in the request body example when sending a Text Message Template are the following:

Parameter Required Description
channel Yes

Specifies the type of delivery channel which the notification message will be sent: "SMS", "EMAIL", "PUSH", "RCS", "WHATSAPP".

In this case, we enter the "WHATSAPP" value to send the WhatsApp message.

request Yes Message content.
request.from Yes

Phone number of the sender.

Phone number provided during the WABA account setup will be used as the sender of the notification message.

Only accepts numeric characters. Do not include the "+" sign.

request.to Yes Determines the destination phone number for your template message. Numbers are specified in E.164 format → (‘+’ and a country code).
request.templateName Yes Name of the template created in your WhatsApp Business Account.
request.templateLanguage Yes

Template Language you set when creating the template.

Currently the API supports 3 Languages: English, Spanish and Portuguese. Required if you want to send templates in languages other than English.

English: "en"

Spanish: "es"

Portuguese: "pt_BR", "pt_PT"

request.message Yes

Content of the text template message that will be sent to the end user.

Emojis and markdown are supported. Maximum length: 1024 characters.

request.placeholders No

Only applies if the "message" parameter contains personalized fields (placeholders).

Object of personalized fields (placeholders) containing the text message body.

From the "placeholders" object, set as parameter the placeholder you configured that is inside double curly braces {{...}} when creating the template. Then set the value of the placeholder parameter.

The placeholders must be correctly formatted in order of how the template was created.

For example, for a text message body like “Here is your {{code}}”, you would set the placeholder as "code": "34871".

request.externalId No Alphanumeric identifier used for reporting purposes.
request.clientId No Unique user identifier that can be used for reporting purposes. This is an identifier you can use to uniquely identify the destination address in your systems. This is similar to the externalId and will be sent back to you if you are requesting callbacks that contain status changes of the messages you send.
callbacks No

Indicate one or more (separated by comma) webhook URLs to notify about the status of the message delivery.That is, If you want to receive the status of the message you've sent to your subscribers, you need to specify your endpoint.

Your endpoint must have a HTTP POST access method and receive a JSON body.

The URL is the external callback where the events of the Email will be registered and published. Once an email is processed, its status will be posted to your callback URL.

To view the full list and meaning of each status, please refer to the WhatsApp Status section.

When you send a Text Message Template, the response body contains the following data:

{
  "meta": {
    "timestamp": 1642531254980,
    "transactionId": "077da1d0-e089-487e-aed0-59534ba2d9f5",
    "explain": "Send Notification"
  }
}

Parameters presented in the response body example when sending a Text Message Template are the following:

Parameter Description
meta "meta" segment is dedicated to metadata regarding the call itself.
meta.timestamp

Call’s time mark.

Sequence of characters identifying when the message has been sent.

meta.transactionId Call’s transaction ID, this will help our teams to locate issues faster if arose.
meta.explain Useful message regarding the operation or the call.