Whatsapp/card
is a structured template which can be used to send a series of related information. It must include a body and at least one additional field.
WhatsApp card cannot have both a Text Header and Media Header
On WhatsApp, a card must be approved as a template before it can be sent. If you use variables with whatsapp/card
, then additional approval steps are required.
If a whatsapp/card
template is created with media and with variables and you plan to submit this template to WhatsApp for approval, a valid media sample is required. Static media urls should resolve to publicly hosted media files. Variable media urls should include a valid media URL suffix in the variable declaration.
Only one type of media can be sent per approved variable WhatsApp card template. WhatsApp classifies approved templates into 1 of 3 types of media headers (Image, Video, Document) based on the sample that was submitted. Once the template has been approved another type of media header cannot be sent using the template.
Ex. If a template is approved with an image then a video cannot be sent using the same template.
In the Media field of the template you create, provide the URL of the publicly hosted file.
If you are using a media in the card with a variable. Please submit a sample path of a publicly hosted image URL in the variable array. The combined URL must contain the file type. The combined URL must resolve to a publicly hosted file.
Example:
"media": ["https://twilio-cms-prod.s3.amazonaws.com/{{1}}"]
would include a path sample in the variables
definition. "variables": {"1": "images/library-logo-resource2x.width-1000.png"}
If you are using a call-to-action URL button in your card, 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"}
body:
Type: string
Required: yes
Variable Support: yes
Description: body of card.
footer:
Type: string
Required: no
Variable Support: no
Description: footer of card.
media:
Type: string[]
Required: no
Variable Support: yes
Description: The URL of the media to send with the message.
header_text:
Type: string
Required: no
Variable Support: yes
Description: Bolded header text of card.
actions:
Limitations -
QUICK_REPLY:
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 whatsapp/card10var whatsappCard = new WhatsappCard.Builder();11whatsappCard.WithBody("Congratulations, you have reached Elite status! Add code {{1}} for 10% off.");12whatsappCard.WithHeaderText("This is a {{1}} card");13whatsappCard.WithFooter("To unsubscribe, reply Stop");14var cardAction1 = new CardAction.Builder()15.WithType(CardActionType.Url)16.WithUrl("https://www.twilio.com")17.WithTitle("Order Online")18.Build();19var cardAction2 = new CardAction.Builder()20.WithType(CardActionType.PhoneNumber)21.WithPhone("+15551234567")22.WithTitle("Call Us")23.Build();24whatsappCard.WithActions(new List<CardAction>() { cardAction1, cardAction2 });2526// define all the content types to be part of the template27var types = new Types.Builder();28types.WithWhatsappCard(whatsappCard.Build());2930// build the create request object31var contentCreateRequest = new ContentCreateRequest.Builder();32contentCreateRequest.WithTypes(types.Build());33contentCreateRequest.WithLanguage("en");34contentCreateRequest.WithFriendlyName("owl_coupon_code");35contentCreateRequest.WithVariables(new Dictionary<string, string>() { {"1", "coupon_code"} });3637// create the twilio template38var contentTemplate = await CreateAsync(contentCreateRequest.Build());3940Console.WriteLine($"Created Twilio Content Template SID: {contentTemplate.Sid}");
1{2"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",3"date_created": "2023-08-03T14:54:47Z",4"date_updated": "2023-08-03T14:54:47Z",5"friendly_name": "owl_coupon_code",6"language": "en",7"links": {8"approval_create": "https://content.twilio.com/v1/Content/HXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ApprovalRequests/whatsapp",9"approval_fetch": "https://content.twilio.com/v1/Content/HXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ApprovalRequests"10},11"sid": "HXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",12"types": {13"whatsapp/card": {14"actions": [15{16"title": "Order Online",17"type": "URL",18"url": "https://owlair.example.com/"19},20{21"phone": "+1555554567",22"title": "Call Us",23"type": "PHONE_NUMBER"24}25],26"body": "Congratulations, you have reached Elite status! Add code {{1}} for 10% off.",27"footer": "To unsubscribe, reply Stop",28"header_text": "This is a {{1}} card",29"media": null30}31},32"url": "https://content.twilio.com/v1/Content/HXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",33"variables": {34"1": "coupon_code"35}36}