Sending Templates

Guide to Sending a Template Message with Waabot API

Introduction

Templates are used to initiate messages to customers who haven't sent a message to the business within the last 24 hours. Regular text messages won't deliver to users who haven't contacted your business within this timeframe. To start a conversation with such users, you need to use templates.

Sending a Template Message

Endpoint

The endpoint for sending a template message is:

/send-message

Request Body Example for a Template Message

{
    "platform": "whatsapp",
    "recipient": "2349048988056",
    "message": {
        "messaging_product": "whatsapp",
        "recipient_type": "individual",
        "to": "2349048988056",
        "type": "template",
        "template": {
            "name": "otp",
            "language": {
                "code": "en_US"
            },
            "components": [
                {
                    "type": "body",
                    "parameters": [
                        {
                            "type": "text",
                            "text": "1234"
                        }
                    ]
                },
                {
                    "type": "button",
                    "sub_type": "url",
                    "index": "0",
                    "parameters": [
                        {
                            "type": "text",
                            "text": "2234"
                        }
                    ]
                }
            ]
        }
    }
}

Example Request to Send a Template Message

Here is an example request to send a template message:

POST https://client.waabot.com/api/v2/send-message
Content-Type: application/json

{
    "platform": "whatsapp",
    "recipient": "2349048988056",
    "message": {
        "messaging_product": "whatsapp",
        "recipient_type": "individual",
        "to": "2349048988056",
        "type": "template",
        "template": {
            "name": "otp",
            "language": {
                "code": "en_US"
            },
            "components": [
                {
                    "type": "body",
                    "parameters": [
                        {
                            "type": "text",
                            "text": "1234"
                        }
                    ]
                },
                {
                    "type": "button",
                    "sub_type": "url",
                    "index": "0",
                    "parameters": [
                        {
                            "type": "text",
                            "text": "2234"
                        }
                    ]
                }
            ]
        }
    }
}

Explanation of the Request Body

  • platform: Specifies the platform (in this case, "whatsapp").

  • recipient: The phone number of the recipient.

  • message: Contains the details of the message to be sent.

    • messaging_product: Specifies the messaging product (in this case, "whatsapp").

    • recipient_type: The type of recipient (in this case, "individual").

    • to: The phone number of the recipient.

    • type: The type of message (in this case, "template").

    • template: Contains the template details.

      • name: The name of the template.

      • language: The language code for the template.

      • components: Contains the components of the template.

        • type: The type of component (in this case, "body" and "button").

        • parameters: The parameters for the component.

          • type: The type of parameter (in this case, "text").

          • text: The text of the parameter.

Summary

By following these steps, you can send template messages using the Waabot API to ensure your messages reach users who haven't interacted with your business in the last 24 hours. This is especially useful for sending OTPs, service notifications, and other critical messages.

Last updated