Skip to contentSkip to navigationSkip to topbar
On this page

twilio/text


Twilio/text type contains only plain text-based content. While text content may be sent to OTT channels without the use of content templates, the twilio/text type can be used as a fallback content type when sending to a mix of channels. Additionally, templates offer variables to create dynamic content.

(warning)

Warning

Twilio/text 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

SMS, WhatsApp, Facebook Messenger


Content API - Text sample.

body:

  • Type: string
  • Required: yes
  • Variable Support: yes
  • Description: The text of the message you want to send.

    • Maximum 1,600 characters
Create Text TemplateLink to code sample: Create Text Template
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/text
10
var twilioText = new TwilioText.Builder();
11
twilioText.WithBody("Hi {{1}}. Thanks for contacting Owl Air Support. How can we help?");
12
13
// define all the content types to be part of the template
14
var types = new Types.Builder();
15
types.WithTwilioText(twilioText.Build());
16
17
// build the create request object
18
var contentCreateRequest = new ContentCreateRequest.Builder();
19
contentCreateRequest.WithTypes(types.Build());
20
contentCreateRequest.WithLanguage("en");
21
contentCreateRequest.WithFriendlyName("text_template");
22
contentCreateRequest.WithVariables(new Dictionary<string, string>() { {"1", "John"} });
23
24
// create the twilio template
25
var contentTemplate = await CreateAsync(contentCreateRequest.Build());
26
27
Console.WriteLine($"Created Twilio Content Template SID: {contentTemplate.Sid}");

Output

1
{
2
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
3
"date_created": "2022-09-01T12:39:19Z",
4
"date_updated": "2022-09-01T12:39:19Z",
5
"friendly_name": "media_template",
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/text": {
14
"body": "Hi, {{1}}. \n Thanks for contacting Owl Air Support. How can I help?."
15
}
16
},
17
"url": "https://content.twilio.com/v1/Content/HXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
18
"variables": {
19
"1": "name"
20
}
21
}