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
SMS, WhatsApp, Facebook Messenger
Message Preview
Data Parameters
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
Java
curl
_36
// Install the Java helper library from twilio.com/docs/java/install
_36
import com.twilio.Twilio;
_36
import com.twilio.exception.ApiException;
_36
import com.twilio.rest.content.v1.Content;
_36
_36
import java.util.Map;
_36
_36
public class Example {
_36
// Find your Account SID and Auth Token at twilio.com/console
_36
// and set the environment variables. See http://twil.io/secure
_36
public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
_36
public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");
_36
_36
public static void main(String[] args) {
_36
// Initialize the SDK
_36
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
_36
_36
// Setup Content
_36
Content.TwilioText type = new Content.TwilioText();
_36
type.setBody("Hi, {{1}}. \n Thanks for contacting Owl Air Support. How can I help?.");
_36
_36
Content.Types types = new Content.Types();
_36
types.setTwilioText(type);
_36
_36
// Create Content
_36
Content.ContentCreateRequest createRequest = new Content.ContentCreateRequest("en", types);