Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

twilio/text


The twilio/text content type contains only plain text-based content. While you can send text to OTT channels without using 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 content templates to create dynamic content.

(warning)

Warning

You can send twilio/text content templates 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 won't be approved without a sample variable. For additional information about variables, see using variables with content templates.


Supported channels

supported-channels page anchor
  • SMS
  • RCS
  • WhatsApp
  • Facebook Messenger

Text message saying 'Hi, name. Thanks for contacting Owl Air Support. How can I help?'.

ParameterTypeRequiredVariable supportDescription
bodystringYesYesThe text of the message you want to send.
Maximum length: 1,600 characters

Code examples and responses

code-examples-and-responses page anchor
Create a text templateLink to code sample: Create a text template
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function createContent() {
11
const content = await client.content.v1.contents.create({
12
friendly_name: "media_template",
13
variables: {
14
1: "name",
15
},
16
language: "en",
17
types: {
18
"twilio/text": {
19
body: "Hi, {{1}}. \n Thanks for contacting Owl Air Support. How can I help?.",
20
},
21
},
22
});
23
24
console.log(content.dateCreated);
25
}
26
27
createContent();

Response

Note about this response
1
{
2
"sid": "HXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"friendly_name": "media_template",
5
"language": "en",
6
"variables": {
7
"1": "name"
8
},
9
"types": {
10
"twilio/text": {
11
"body": "Hi, {{1}}. \n Thanks for contacting Owl Air Support. How can I help?."
12
}
13
},
14
"url": "https://content.twilio.com/v1/Content/HXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
15
"date_created": "2015-07-30T19:00:00Z",
16
"date_updated": "2015-07-30T19:00:00Z",
17
"links": {
18
"approval_create": "https://content.twilio.com/v1/Content/HXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ApprovalRequests/whatsapp",
19
"approval_fetch": "https://content.twilio.com/v1/Content/HXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ApprovalRequests"
20
}
21
}