Text template blocks

A text template can contain a header, body, footer and buttons.

Headers are optional elements found at the top of template messages. They can include text, media (such as images, videos, and documents), or locations.

Example:

{
   "type":"text",
   "role":"header",
   "text":{
      "text":"My header"
   }
}

Body

Body components are mandatory for all templates and consist solely of text. Each template is limited to a single body component.

Example

{
   "type":"text",
   "role":"body",
   "text":{
      "text":"This is the body"
   }
}

Footers are optional components made up of text that appear directly below the body component. Each template can include only one footer component.

Example

{
   "type":"text",
   "role":"footer",
   "text":{
      "text":"My footer"
   }
}

Basic text template example

"blocks":[
   {
      "type":"text",
      "role":"header",
      "text":{
         "text":"My header"
      }
   },
   {
      "type":"text",
      "role":"body",
      "text":{
         "text":"This is the body"
      }
   },
   {
      "type":"text",
      "role":"footer",
      "text":{
         "text":"My footer"
      }
   }
]

Buttons

Buttons are optional interactive elements that trigger specific actions when tapped. Templates can include a maximum of 10 button components, but there are restrictions on the number of individual button types and combinations.

Action buttons

Buttons that perform an action when tapped by the app user such as opening a URL or calling a phone number

Copy code button

Each template is restricted to a single copy code button.

{
   "defaultLocale":"en",
   "deployments":[
      {
         "key":"whatsappTemplateName",
         "platform":"whatsapp",
         "value":"ui_test_1_text_bt"
      },
      {
         "key":"whatsappCategory",
         "platform":"whatsapp",
         "value":"MARKETING"
      },
      {
         "key":"whatsappAllowCategoryChange",
         "platform":"whatsapp",
         "value":"false"
      }
   ],
   "variables":[
      {
         "key":"code",
         "description":"This is a variable that contains the code",
         "type":"string",
         "format":"none",
         "examplesLocale":{
            "en":{
               "exampleValueStrings":[
                  "Code"
               ]
            }
         }
      }
   ],
   "platformContent":[
      {
         "locale":"en",
         "type":"text",
         "platform":"whatsapp",
         "channelGroupIds":[
            "3f979241-dea3-4f55-b7bb-d769eec27e51"
         ],
         "blocks":[
            {
               "type":"text",
               "text":{
                  "text":"My header"
               },
               "role":"header"
            },
            {
               "type":"text",
               "role":"body",
               "text":{
                  "text":"Here is your code {{code}}"
               }
            },
            {
               "type":"text",
               "role":"footer",
               "text":{
                  "text":"My footer"
               }
            },
            {
               "type":"copy-code-action",
               "copyCodeAction":{
                  "code":"{{code}}"
               }
            }
         ]
      }
   ],
   "supportedPlatforms":[
      "whatsapp"
   ],
   "shortLinks":{
      "enabled":true,
      "domain":"brd1.us"
   },
}
  • When the copy code action is added, the Body block must also contain the same variable: {{code}}

exampleValueStrings : Examples are required by Meta for the approval of the teamplate.

Phone number button

When tapped by the end user, phone number buttons dial the designated business phone number. Each template is restricted to a single phone number button.

"platformContent": [
        {
            "locale": "en",
            "type": "text",
            "platform": "whatsapp",
            "channelGroupIds": [
                "3f979241-dea3-4f55-b7bb-d769eec27e51"
            ],
            "blocks": [
                {
                    "type": "text",
                    "role": "body",
                    "text": {
                        "text": "Message body"
                    }
                },
                {
                    "type": "text",
                    "role": "footer",
                    "text": {
                        "text": "Footer"
                    }
                },
                {
                    "type": "call-phone-number-action",
                    "callPhoneNumberAction": {
                        "text": "my number",
                        "phoneNumber": "+436566899343"
                    }
                }
            ]
        }
    ]

When tapped by the end user, URL buttons open the specified URL in the device's default web browser. Each template is limited to two URL buttons.

"platformContent": [
        {
            "locale": "en",
            "type": "text",
            "platform": "whatsapp",
            "channelGroupIds": [
                "3f979241-dea3-4f55-b7bb-d769eec27e51"
            ],
            "blocks": [
                {
                    "type": "text",
                    "role": "body",
                    "text": {
                        "text": "Message body"
                    }
                },
                {
                    "type": "text",
                    "role": "footer",
                    "text": {
                        "text": "Footer"
                    }
                },
                {
                    "type": "link-action",
                    "linkAction": {
                        "text": "newsletter",
                        "url": "https://example.newsletter.com/"
                    }
                },
                {
                    "type": "link-action",
                    "linkAction": {
                        "text": "change log",
                        "url": "https://example.change.com/"
                    }
                }
            ]
        }
    ]

Quick reply buttons

Quick reply buttons are customisable, text-based options that send an immediate response to you with the predefined message when tapped by a user.

Each template can include up to 10 quick reply buttons.

"platformContent": [
        {
            "locale": "en",
            "type": "text",
            "platform": "whatsapp",
            "channelGroupIds": [
                "3f979241-dea3-4f55-b7bb-d769eec27e51"
            ],
            "blocks": [
                {
                    "type": "text",
                    "role": "body",
                    "text": {
                        "text": "Message body"
                    }
                },
                {
                    "type": "text",
                    "role": "footer",
                    "text": {
                        "text": "Footer"
                    }
                },
                {
                    "type": "reply-action",
                    "replyAction": {
                        "text": "quick reply 1",
                        "payload": "quick reply 1 payload"
                    }
                },
                {
                   "type": "reply-action",
                    "replyAction": {
                        "text": "quick reply 2",
                        "payload": "quick reply 2 payload"
                    }
                }
            ]
        }
    ]

Payload contains the text that is being returned when the user taps on it.

Combining buttons and ordering

When combining quick reply buttons with other types of buttons, they must be separated into two distinct groups: quick reply buttons and non-quick reply buttons. If they are not properly grouped, the API will return an error due to an invalid button combination.

Valid groupings include:

  • Quick Reply, Quick Reply

  • Quick Reply, Quick Reply, URL, Phone

  • URL, Phone, Quick Reply, Quick Reply

Invalid groupings include:

  • Quick Reply, URL, Quick Reply

  • URL, Quick Reply, URL

Ordering

The order of the button types must be followed correctly for successful block object creation and submission; otherwise, the API will return a validation error. Here is the correct order when combining various buttons type.

  1. "type":"copy-code-action"

  2. "type": "link-action"

  3. "type": "call-phone-number-action"

  4. "type": "reply-action"

Limitations

Button type
Limitation

copy-code-action

One per template

link-action

Up to two per template

call-phone-number-action

One per template

reply-action

Up to ten per template

Last updated