Buttons
Integration summary
- Endpoint:
POST https://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging- Token: messaging token, in the
Authorization: Bearer {{wa-msg-api-token}}header (how to generate it)- Common fields:
from,to(phone number or BSUID) andtype(details)typevalues on this page:"template"- Response: the same for every message (see response)
Templates with buttons: quick reply, one-time password, call and open URL. All are sent with POST /v1/messaging; headers, common fields and the response are in HTTP connection. The general template structure (template and components objects) is in Template messages.
Quick reply
Quick reply button: a button component with subtype "quick_reply". In the parameter object, type must be "payload".
Body
Button component fields:
| Name | Description | Type | Requirements |
|---|---|---|---|
| type | The value is "button". | String | Required |
| subtype | The value is "quick_reply". | String | Required |
| index | Button index (0, 1, 2). | Integer | Optional |
Fields for the Quick reply parameter:
| Name | Description | Type | Requirements |
|---|---|---|---|
| type | The value is "payload". | String | Required |
| payload | Description of the quick reply button. | String |
|
Example
Complete Quick reply example (HTTP request and JSON body):
Quick reply HTTP request
curl -X POST 'https://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "calificacion_servicio","components": [{"type": "body","parameters": [{"text": "Juan","type": "text"}]},{"type": "button","subtype": "quick_reply","index": 0,"parameters": [{"type": "payload","payload": "12345765"}]},{"type": "button","subtype": "quick_reply","index": 1,"parameters": [{"type": "payload","payload": "12345765"}]},{"type": "button","subtype": "quick_reply","index": 2,"parameters": [{"type": "payload","payload": "12345765"}]}]}}'
Quick reply body
{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "calificacion_servicio","components": [{"type": "body","parameters": [{"text": "Juan","type": "text"}]},{"type": "button","subtype": "quick_reply","index": 0,"parameters": [{"type": "payload","payload": "12345765"}]},{"type": "button","subtype": "quick_reply","index": 1,"parameters": [{"type": "payload","payload": "12345765"}]},{"type": "button","subtype": "quick_reply","index": 2,"parameters": [{"type": "payload","payload": "12345765"}]}]}}
One-time password
One-time password template: the code is sent as a text parameter in the body component and in a button with subtype "url".
Example
Complete One-time password example (HTTP request and JSON body):
One-time password HTTP request
curl -X POST 'https://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "confirmacion_codigo_02","components": [{"type": "body","parameters": [{"type": "text","text": "54321"}]},{"type": "button","subtype": "url","index": 0,"parameters":[{"type": "text","text": "54321"}]}]}}'
One-time password body
{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "confirmacion_codigo_02","components": [{"type": "body","parameters": [{"type": "text","text": "54321"}]},{"type": "button","subtype": "url","index": 0,"parameters":[{"type": "text","text": "54321"}]}]}}
Call action
Template with an action button to place a call. The button is defined in the approved template, so only the body component parameters are sent.
Example
Complete Call action example (HTTP request and JSON body):
Call action HTTP request
curl -X POST 'https://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "test_call_to_action_04","components": [{"type": "body","parameters":[{"type": "text","text": "now"}]}]}}'
Call action body
{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "test_call_to_action_04","components": [{"type": "body","parameters":[{"type": "text","text": "now"}]}]}}
Open URL action
Template with an action button to open a URL. With a static URL no parameters are sent; with a dynamic URL you send a button with subtype "url" whose text parameter is appended to the URL prefix defined in the template.
Example
Complete Open URL action example (HTTP request and JSON body):
Static URL HTTP request
curl -X POST 'https://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "template_call_to_action"}}'
Static URL body
{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "template_call_to_action"}}
Dynamic URL HTTP request
curl -X POST 'https://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "template_example_account_button_call_to_action_url","components": [{"type": "button","subtype": "url","index": 0,"parameters":[{"type": "text","text": "producto_api.html"}]}]}}'
Dynamic URL body
{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "template_example_account_button_call_to_action_url","components": [{"type": "button","subtype": "url","index": 0,"parameters":[{"type": "text","text": "producto_api.html"}]}]}}
