Skip to contentSkip to navigationSkip to topbar
Rate this page:
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 make it easy to utilize 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 Template

create-text-template page anchor
C#
Java
curl

_27
// Install the C# / .NET helper library from twilio.com/docs/csharp/install
_27
_27
using System;
_27
using Twilio;
_27
using Twilio.Rest.Content.V1;
_27
_27
TwilioClient.Init(accountSid, authToken);
_27
_27
// define the twilio/text
_27
var twilioText = new TwilioText.Builder();
_27
twilioText.WithBody("Hi {{1}}. Thanks for contacting Owl Air Support. How can we help?");
_27
_27
// define all the content types to be part of the template
_27
var types = new Types.Builder();
_27
types.WithTwilioText(twilioText.Build());
_27
_27
// build the create request object
_27
var contentCreateRequest = new ContentCreateRequest.Builder();
_27
contentCreateRequest.WithTypes(types.Build());
_27
contentCreateRequest.WithLanguage("en");
_27
contentCreateRequest.WithFriendlyName("text_template");
_27
contentCreateRequest.WithVariables(new Dictionary<string, string>() { {"1", "John"} });
_27
_27
// create the twilio template
_27
var contentTemplate = await CreateAsync(contentCreateRequest.Build());
_27
_27
Console.WriteLine($"Created Twilio Content Template SID: {contentTemplate.Sid}");

Output

_21
{
_21
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_21
"date_created": "2022-09-01T12:39:19Z",
_21
"date_updated": "2022-09-01T12:39:19Z",
_21
"friendly_name": "media_template",
_21
"language": "en",
_21
"links": {
_21
"approval_create": "https://content.twilio.com/v1/Content/HXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ApprovalRequests/whatsapp",
_21
"approval_fetch": "https://content.twilio.com/v1/Content/HXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ApprovalRequests"
_21
},
_21
"sid": "HXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_21
"types": {
_21
"twilio/text": {
_21
"body": "Hi, {{1}}. \n Thanks for contacting Owl Air Support. How can I help?."
_21
}
_21
},
_21
"url": "https://content.twilio.com/v1/Content/HXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_21
"variables": {
_21
"1": "name"
_21
}
_21
}


Rate this page: