twilio/list-picker


The twilio/list-picker content type includes a menu of up to 10 options for users to make a selection.

(information)

Info

List-picker templates are only available once the end user is in a 24 hour session. They can't initiate a business initiated session.

List-picker templates aren't supported for approval on WhatsApp and can't be submitted for approval.


WhatsApp


Message Preview.

ParameterTypeRequiredVariable supportDescription
bodystringYesYesThe text of the message you want to send. This is included as a regular text message.
Maximum length: 1,024 characters
buttonstringYesYesDisplay value for the primary button.
itemsarrayYesSee items properties.Array of list item objects.
Minimum: 1 item
Maximum: 10 items
PropertyTypeRequiredVariable supportDescription
itemstringYesYesDisplay value for the item.
Maximum length: 24 characters
idstringYesYesUnique item identifier. Not visible to the recipient.
Maximum length: 200 characters
descriptionstringYesYesDescription of the item.
Maximum length: 72 characters

Code examples and responses

code-examples-and-responses page anchor
1
// Install the C# / .NET helper library from twilio.com/docs/csharp/install
2
3
using System;
4
using Twilio;
5
using Twilio.Rest.Content.V1;
6
7
TwilioClient.Init(accountSid, authToken);
8
9
// define the twilio/list-picker
10
var twilioListPicker = new TwilioListPicker.Builder();
11
twilioListPicker.WithBody("Owl Air Flash Sale! Hurry! Sale ends on {{1}}!");
12
var item1 = new ListPickerItems.Builder()
13
.WithItem("SFO to NYC for $299")
14
.WithDescription("Owl Air Flight 1337 to LGA")
15
.WithId("SFO1337")
16
.Build();
17
var item2 = new ListPickerItems.Builder()
18
.WithItem("OAK to Denver for $149")
19
.WithDescription("Owl Air Flight 5280 to DEN")
20
.WithId("OAK5280")
21
.Build();
22
var item3 = new ListPickerItems.Builder()
23
.WithItem("LAX to Chicago for $199")
24
.WithDescription("Owl Air Flight 96 to ORD")
25
.WithId("LAX96")
26
.Build();
27
twilioListPicker.WithItems(new List<ListPickerItems>() { item1, item2, item3 });
28
29
// define all the content types to be part of the template
30
var types = new Types.Builder();
31
types.WithTwilioListPicker(twilioListPicker.Build());
32
33
// build the create request object
34
var contentCreateRequest = new ContentCreateRequest.Builder();
35
contentCreateRequest.WithTypes(types.Build());
36
contentCreateRequest.WithLanguage("en");
37
contentCreateRequest.WithFriendlyName("owl_sale_list");
38
contentCreateRequest.WithVariables(new Dictionary<string, string>() { {"1", "end_date"} });
39
40
// create the twilio template
41
var contentTemplate = await CreateAsync(contentCreateRequest.Build());
42
43
Console.WriteLine($"Created Twilio Content Template SID: {contentTemplate.Sid}");

Output

1
{
2
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
3
"date_created": "2022-08-29T15:46:11Z",
4
"date_updated": "2022-08-29T15:46:11Z",
5
"friendly_name": "owl_air_list",
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
"twilio/list-picker": {
14
"body": "Owl Air Flash Sale! Hurry! Sale ends on {{1}}!",
15
"button": "Select a destination",
16
"items": [
17
{
18
"description": "Owl Air Flight 1337 to LGA",
19
"id": "SFO1337",
20
"item": "SFO to NYC for $299"
21
},
22
{
23
"description": "Owl Air Flight 5280 to DEN",
24
"id": "OAK5280",
25
"item": "OAK to Denver for $149"
26
},
27
{
28
"description": "Owl Air Flight 96 to ORD",
29
"id": "LAX96",
30
"item": "LAX to Chicago for $199"
31
}
32
]
33
},
34
"twilio/text": {
35
"body": "We have flights to the following destinations: (1) SFO, (2) OAK, (3) LAX. Hurry! Sale ends on {{1}}!"
36
}
37
},
38
"url": "https://content.twilio.com/v1/Content/HXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
39
"variables": {
40
"1": "end_date"
41
}
42
}