SendTemplateButtons#
Attention, please! The method is temporarily not working
The method is aimed for sending a message with template list interactive buttons to a personal or a group chat. The message will be added to the send queue. The message will be kept for 24 hours in the queue and will be sent immediately after phone authorization. The rate at which messages are sent from the queue is managed by Message sending delay parameter.
Request#
To send a message, you have to execute a request at:
{{apiUrl}}/waInstance{{idInstance}}/sendTemplateButtons/{{apiTokenInstance}}
For apiUrl
, idInstance
and apiTokenInstance
request parameters, refer to Before you start section.
Features when working with buttons#
- url buttons are compatible with telephone number buttons, but not with reply buttons;
- telephone number buttons кнопки are compatible with url buttons, but not with reply buttons;
- quick reply buttons are not compatible with telephone numbers buttons and url buttons.
Request parameters#
Parameter | Type | Mandatory | Description |
---|---|---|---|
chatId | string | Yes | Chat Id |
message | string | Yes | Message text. Emoji 😃 characters supported |
footer | string | No | Message footer. Useful for visually highlighting text related to buttons. |
templateButtons | array | Yes | Message template buttons |
quotedMessageId | string | No | Quoted message ID. If present, the message will be sent quoting the specified chat message |
templateButtons
array parameters
Parameter | Type | Description |
---|---|---|
index | integer | Button Id |
urlButton | object | Url button |
callButton | object | Call button |
quickReplyButton | object | Plain button |
urlButton
object parameters
Parameter | Type | Description |
---|---|---|
displayText | string | Link text |
url | string | Web link |
callButton
object parameters
Parameter | Type | Description |
---|---|---|
displayText | string | Link text |
phoneNumber | string | Telephone number |
quickReplyButton
object parameters
Parameter | Type | Description |
---|---|---|
displayText | string | Button text |
id | string | Button Id |
The maximum length of a text message is 4096 characters
Request body example#
Sending a message to a personal chat:
{
"chatId": "11001234567@c.us",
"message": "Hello",
"footer": "What kind of action will you choose?",
"templateButtons": [
{"index": 1, "urlButton": {"displayText": "⭐ Star us on GitHub!", "url": "https://github.com/green-api"}},
{"index": 2, "callButton": {"displayText": "Call us", "phoneNumber": "+1 (234) 5678-901"}},
{"index": 3, "quickReplyButton": {"displayText": "Plain button", "id": "plainButtonId"}}
]
}
Response#
Response parameters#
Parameter | Type | Description |
---|---|---|
idMessage | string | Sent message Id |
Response body example#
{
"idMessage": "3EB0C767D097B7C7C030"
}
Recipient display example#
Callback button
Url button
Quick reply button
SendMessage errors#
For a list of errors common to all methods, refer to Common errors section
Possible mistakes
When using the SendTemplateButtons method, messages may not be displayed on the web, desktop, and mobile versions of the application. The ability to send messages with buttons is implemented by us in a low-level way. The official WhatsApp-Web client does not provide the functionality of sending buttons. To a large extent, the stability of the SendTemplateButtons method does not depend on us, WhatsApp constantly makes changes to their work.
We recommend that you always duplicate buttons with regular messages.
For example, use numbers to define choices.
Choose an action:
1 - action 1
2 - action 2
3 - action 3
curl example#
```
curl --location --request POST '{{apiUrl}}/waInstance{{idInstance}}/sendTemplateButtons/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"chatId": "11001234567@c.us",
"message": "Hello",
"footer": "What kind of action will you choose?",
"templateButtons": [
{"index": 1, "urlButton": {"displayText": "⭐ Star us on GitHub!", "url": "https://github.com/green-api"}},
{"index": 2, "callButton": {"displayText": "Call us", "phoneNumber": "+1 (234) 5678-901"}},
{"index": 3, "quickReplyButton": {"displayText": "Plain button", "id": "plainButtonId"}}
]
}'
```