Skip to contentSkip to navigationSkip to topbar
On this page

title: twilio/text seo_description: "Learn about the twilio/text content type for plain text-based content and how to use it with content templates, variables, and supported channels." show_breadcrumbs: false

title-twiliotextseo_description-learn-about-the-twiliotext-content-type-for-plain-text-based-content-and-how-to-use-it-with-content-templates-variables-and-supported-channelsshow_breadcrumbs-false page anchor

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

(warning)

Warning

You can send twilio/text templates via WhatsApp for out-of-session messages with variables. When the template's body starts or ends with a variable or has two variables next to each other, WhatsApp won't approve the template without a sample variable. For additional information about variables, see Using Variables with Content Templates.


  • SMS
  • WhatsApp
  • Facebook Messenger

An example of a text message sent using the Content API.

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
}