Twilio/call-to-action
buttons let recipients tap to trigger actions such as launching a website, copying a coupon code, or making a phone call.
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"}
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.
WhatsApp, Facebook Messenger
body:
actions:
Limitations -
URL:
PHONE:
VOICE_CALL:
COPY_CODE:
1// Install the C# / .NET helper library from twilio.com/docs/csharp/install23using System;4using Twilio;5using Twilio.Rest.Content.V1;67TwilioClient.Init(accountSid, authToken);89// define the twilio/call-to-action type10var twilioCallToAction = new TwilioCallToAction.Builder();11twilioCallToAction.WithBody("Owl Air: We will see you soon! Flight {{1}} to {{2}} departs at {{3}} from Gate {{4}}.");12var cta1 = new CallToAction.Builder()13.WithType(CallToActionActionType.Url)14.WithUrl("https://owlair.com/{{5}}")15.WithTitle("Check Flight Status")16.Build();17var cta2 = new CallToAction.Builder()18.WithType(CallToActionActionType.PhoneNumber)19.WithPhone("+15555551234")20.WithTitle("Call Support")21.Build();22twilioCallToAction.WithActions(new List<CallToAction>() { cta1, cta2 });2324// define all the content types to be part of the template25var types = new Types.Builder();26types.WithTwilioCallToAction(twilioCallToAction.Build());2728// build the create request object29var contentCreateRequest = new ContentCreateRequest.Builder();30contentCreateRequest.WithTypes(types.Build());31contentCreateRequest.WithLanguage("en");32contentCreateRequest.WithFriendlyName("owl_air_cta");33contentCreateRequest.WithVariables(new Dictionary<string, string>() { {"1", "flight_number"}, {"2", "arrival_city"}, {"3", "departure_time"}, {"4", "gate_number"}, {"5", "url_suffix"} });3435// create the twilio template36var contentTemplate = await CreateAsync(contentCreateRequest.Build());3738Console.WriteLine($"Created Twilio Content Template SID: {contentTemplate.Sid}");
1{2"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",3"date_created": "2022-01-15T17:09:58Z",4"date_updated": "2022-01-15T17:09:58Z",5"friendly_name": "owl_air_cta",6"language": "en",7"links": {8"approval_fetch": "https://content.twilio.com/v1/Content/HXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ApprovalRequests",9"approval_create": "https://content.twilio.com/v1/Content/HXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ApprovalRequests/whatsapp"10},11"sid": "HXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",12"types": {13"twilio/call-to-action": {14"actions": [15{16"url": "https://owlair.com/{{5}}",17"type": "URL",18"title": "Check Flight Status"19},20{21"phone_number": "+15555551234",22"type": "PHONE_NUMBER",23"title": "Call Support"24}25],26"body": "Owl Air: We will see you soon! Flight {{1}} to {{2}} departs at {{3}} from Gate {{4}}."27}28},29"url": "https://content.twilio.com/v1/Content/HXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",30"variables": {31"1": "flight_number",32"3": "departure_time",33"2": "arrival_city",34"5": "url_suffix",35"4": "gate_number"36}37}