Sending Template Messages

Use this api to send template messages.

To send a template message, make a POST call to /messages and attach a message object with type=template .

Parameters

This is the main parameter used in send template message requests:

NameDescription

to

Required

WhatsApp ID or phone number for the person you want to send a message to.

The phone numbers in this requests can be provided in any dialable format, as long as they include their country code. It's recommended that you explicitly prefix the country code with a plus sign (+).

Here are some examples of supported phone number formats:

  • +1-000-000-0000
  • +1 (000) 000-0000
  • +1 000 000 0000
  • +1 (000) 000 0000

reply_message_id

Optional
You can send any message as a reply to a previous message in a conversation by including the previous message's ID. The recipient will receive the new message along with a contextual bubble that displays the previous message's content.

type

Required
The type of message you want to send. Set this as individual

template

.

template

Required
A template object.

template.name

Required

Name of the template.

template.language

Required

Contains a language object. Specifies the language the template may be rendered in.

template.param

Optional
A template param object.

template.param.header

Optional
A template param header object.

template.param.header.type

Optional
Describes the parameter header type.

Supported values:

  • text
  • image
  • video
  • document

template.param.header.text

Optional

Required

when type=text.

The message`s text.

template.param.header.image

Optional

Required

when type=image.

A media object of type image.

template.param.header.image.id

Optional

Required

when you are not using a link.

The media object ID.

template.param.header.image.link

Optional

Required

when you are not using an uploaded media ID.

The protocol and URL of the media to be sent. Use only with HTTP/HTTPS URLs.

template.param.header.video

Optional

Required

when type=video.

A media object of type video.

template.param.header.video.id

Optional

Required

when you are not using a link.

The media object ID.

template.param.header.video.link

Optional

Required

when you are not using an uploaded media ID.

The protocol and URL of the media to be sent. Use only with HTTP/HTTPS URLs.

template.param.header.document

Optional

Required

when type=document.

A media object of type document.

template.param.header.document.link

Optional

Required

when you are not using an uploaded media ID.

The protocol and URL of the media to be sent. Use only with HTTP/HTTPS URLs.

template.param.header.document.caption

Optional

Describes the specified document.

template.param.header.document.filename

Optional

Describes the filename for the specific document.

template.param.body

Optional
Array of body objects containing the parameters of the message.

template.param.button

Optional
Array of button objects containing the parameters of the message.

template.param.button.*.type

Optional
Indicates the type of parameter for the button.

Supported values:

  • payload
  • url
  • copy_code

template.param.button.*.index

Optional
Position index of the button. You can have up to 10 buttons using index values of 0 to 9.

template.param.button.*.value

Optional

Payload: Developer-defined payload that is returned when the button is clicked in addition to the display text on the button.

Url: Developer-provided suffix that is appended to the predefined prefix URL in the template.

copy_code: Developer-defined code to be copied to the device's clipboard when tapped by the app user

template.param.limited_time_offer

Optional

A limited time offer object

Required

when limited time offer expiration time is set true

template.param.limited_time_offer.expiration_time_ms

Optional

Offer code expiration time as a UNIX timestamp in milliseconds.

Required

when limited time offer expiration time is set true

Example

Sample request:

curl -X POST 'https://waofficial.botika.online/api/whatsapp/v1/messages' \
-H 'Authorization: Bearer {{ API_TOKEN }}' \
-H 'Content-Type: application/json' \
-d '{
    "to": "+62821xxxxxx",
    "reply_message_id": "{{ MESSAGE_ID }}",
    "type": "template",
    "template": {
        "name": "TEMPLATE_NAME",
        "language": "LANGUAGE_AND_LOCALE_CODE",
        "param": {
            "header": {
                "type": "text" | "image" | "video" | "document",
                "text": "your text",
                # OR
                "document": {
                    "id": "your-media-id",
                    # OR
                    "link": "http(s)://document-url"
                    "filename": "some-file-name"
                }
                # OR
                "video": {
                    "id": "your-media-id",
                    # OR
                    "link": "http(s)://video-url"
                }
                # OR
                "image": {
                    "id": "your-media-id",
                    # OR
                    "link": "http(s)://image-url",
                }
            },
            "body": [
                "PARAM_BODY_1",
                "PARAM_BODY_2",
                ...
            ],
            "button": [
                {
                    "type": "payload" | "url" | "copy_code",
                    "index": 0,
                    "value": "PAYLOAD",
                },
                {
                    "type": "payload" | "url" | "copy_code",
                    "index": 2,
                    "value": "PAYLOAD",
                },
                {
                    "type": "payload" | "url" | "copy_code",
                    "index": 3,
                    "value": "PAYLOAD",
                }
                ...
            ],
            # if limited time offer expiration time is set true
            "limited_time_offer": {
                "expiration_time_ms": "<unix_timestamp_in_miliseconds>"
            }
        }
    }
}'

A successful response includes an object with an identifier for the message:

{
    "data": {
        "id": "{{ MESSAGE_ID }}"
    }
}

Copyright © 2023 Botika Teknologi Indonesia