Skip to contentSkip to navigationSkip to topbar
Rate this Page:

twilio/call-to-action


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

supported-channels page anchor

WhatsApp, Facebook Messenger


Content Api - CTA preview.

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.

    • Maximum 640 characters

actions:

  • Type: array[ actions ]
  • Required: yes
  • 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

create-call-to-action-template page anchor
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}}.",
_27
"actions": [{
_27
"type": "URL",
_27
"title": "Check Flight Status",
_27
"url": "https://owlair.com/{{5}}"
_27
},
_27
{
_27
"type": "PHONE_NUMBER",
_27
"title": "Call Support",
_27
"phone": "+18005551234"
_27
}]
_27
}
_27
}
_27
}'

Output

_37
{
_37
"language": "en",
_37
"date_updated": "2022-01-15T17:09:58Z",
_37
"variables": {
_37
"1": "flight_number",
_37
"3": "departure_time",
_37
"2": "arrival_city",
_37
"5": "url_suffix",
_37
"4": "gate_number"
_37
},
_37
"friendly_name": "flight_departure_update",
_37
"account_sid": "ACXXXXXXXXXXXXXXXXXXX",
_37
"url": "https://content.twilio.com/v1/Content/HXXXXXXXXXXXXXXXXXXXX",
_37
"sid": "HXXXXXXXXXXXXXXXXXXX",
_37
"date_created": "2022-01-15T17:09:58Z",
_37
"types": {
_37
"twilio/call-to-action": {
_37
"body": "Owl Air: We will see you soon! Flight {{1}} to {{2}} departs at {{3}} from Gate {{4}}.",
_37
"actions": [
_37
{
_37
"url": "https://owlair.com/{{5}}",
_37
"type": "URL",
_37
"title": "Check Flight Status"
_37
},
_37
{
_37
"phone_number": "+18005551234",
_37
"type": "PHONE_NUMBER",
_37
"title": "Call Support"
_37
}
_37
]
_37
}
_37
},
_37
"links": {
_37
"approval_fetch": "https://content.twilio.com/v1/Content/HXXXXXXXXXXXXXXXXXXX/ApprovalRequests",
_37
"approval_create": "https://content.twilio.com/v1/Content/HXXXXXXXXXXXXXXXXXXX/ApprovalRequests/whatsapp"
_37
}
_37
}


Rate this Page: