Twilio/call-to-action buttons let recipients tap to trigger actions such as launching a website or making a phone call.
(information)
Info
Call-to-action buttons can only be sent via WhatsApp as approved templates.
If you are using a URL button and want to submit the template for WhatsApp approval, the URL must resolve to a publicly accessible website. If there is a variable, a valid path sample should be included in the variables array. The combined URL should resolve to a publicly accessible website.
Example:
"url": ["https://www.twilio.com/{{1}}"] would include a path sample in the variables definition. "variables": {"1": "docs"}
(warning)
Warning
Twilio/call-to-action templates can be sent via WhatsApp for out of session messages with variables. If the template's body starts or ends with a variable or has two variables next to each other, the template will not be approved by WhatsApp without a sample variable. For additional information about variables see Using Variables with Content Templates.
Supported Channels
WhatsApp, Facebook Messenger
Message Preview
Data Parameters
body:
Type:
string
Required:
yes
Variable Support:
yes
Description: The text of the message you want to send. This is included as a regular text message.
Variable Support:
See Common Components:
Actions
definition
Description: Buttons that recipients can tap on to act on the message:
Up to 2 buttons for Call-to-Action button types: PHONE_NUMBER or URL. Please note only a single PHONE_NUMBER or URL button can be used at a time. If two buttons are used, one must be a URL and the other a PHONE_NUMBER.
Please use "type" and "title" actions to create call-to-action buttons within the actions array.
Create Call-To-Action Template
curl
_27
curl -X POST 'https://content.twilio.com/v1/Content' \
_27
-H 'Content-Type: application/json' \
_27
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN \
_27
-d '{
_27
"friendly_name": "flight_departure_update",
_27
"language": "en",
_27
"variables": {"1": "flight_number",
_27
"2": "arrival_city",
_27
"3": "departure_time",
_27
"4": "gate_number",
_27
"5": "url_suffix"},
_27
"types": {
_27
"twilio/call-to-action": {
_27
"body": "Owl Air: We will see you soon! Flight {{1}} to {{2}} departs at {{3}} from Gate {{4}}.",