Send and receive branded RCS messages (public beta)
Public Beta
Programmable Messaging Rich Communication Services (RCS) is currently available as a Public Beta product, and the information contained in this document is subject to change.
Some features aren't yet implemented, and others may change before the product becomes Generally Available (GA). Public Beta products aren't covered by a Service Level Agreement (SLA).
On this page, you'll learn to use Twilio Programmable Messaging to programmatically send branded RCS messages using your web application or cURL.
To learn the advantages of RCS, see RCS Business Messaging.
Before you send an RCS message, complete the RCS setup.
You can send RCS messages using code that makes HTTP POST
requests to the Message resource in the Twilio REST API. Programmable Messaging proactively checks if the recipient's device can support RCS and sends the message using SMS as a fallback if needed.
To send an RCS message, follow the steps to send an SMS message, replacing the From
field with the MessagingServiceSid
field as shown in the following example. Set the MessagingServiceSid
field to the Messaging Service SID assigned to your RCS Sender. To find your Messaging Service's SID, check the Sid column on the Messaging Services page in the Twilio Console.
Don't set the From
parameter in the API request to the RCS Sender Messaging Service SID because it prevents fallback to SMS or MMS if the RCS fails.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createMessage() {11const message = await client.messages.create({12body: "My first RCS message. Hello, world!",13messagingServiceSid: "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",14to: "+155XXXXXXXX",15});1617console.log(message.body);18}1920createMessage();
To send messages containing RCS-supported media formats and sizes, add the media URL to the send an RCS message code as shown in the following example. The media URL tells Twilio where to get the media you want to include.
The media URL must be a publicly accessible URL. Twilio can't reach any hidden URLs or URLs that require authentication.
Twilio automatically attempts delivery over RCS. Unsupported media formats may fall back to MMS. Devices that aren't RCS-capable receive the message by MMS in MMS-supported regions, and Picture SMS elsewhere. Twilio supports combining text and media over RCS only for image and video files.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createMessage() {11const message = await client.messages.create({12mediaUrl: [13"https://c1.staticflickr.com/3/2899/14341091933_1e92e62d12_b.jpg",14],15messagingServiceSid: "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",16to: "+155XXXXXXXX",17});1819console.log(message.body);20}2122createMessage();
You can create rich content using Content Templates and send that content through RCS. RCS supports the following rich content types:
Rich content support | |
---|---|
RCS Feature | Content Type |
Rich Card | twilio/card |
Chip List | twilio/card |
Basic Text | twilio/text |
Media | twilio/media |
Rich Card Carousel | twilio/carousel |
For devices that aren't RCS-capable, you can define customized fallback to SMS and MMS in applicable regions by defining multiple types in a Content Template.
To send rich content through RCS:
-
Define your rich content in the API or the Twilio Console.
-
In the API response or in the Twilio Console, find the unique Content SID starting with
HX
that identifies your rich content. -
Add the
ContentSid
and content variables to the send an RCS message code as shown in the following example.To learn more about content variables, see Using Variables.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createMessage() {11const message = await client.messages.create({12contentSid: "HXXXXXXXXXXXXX",13contentVariables: JSON.stringify({ 1: "Name" }),14messagingServiceSid: "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",15to: "+155XXXXXXXX",16});1718console.log(message.body);19}2021createMessage();
When users send messages to your RCS Sender, you can see those messages on your Programmable Messaging Logs page in the Twilio Console. You can also configure your Messaging Service to send a webhook when it receives an incoming message.
Your customers can start a chat with your RCS Sender from a deep link URL. You can embed the URL as a button, link, or QR code in an email, app or website depending on your use case.
Format the deep link URL like this: "sms:" + "{{RCS Sender ID}}" + "@rbm.goog"
To find your RCS Sender ID, click the RCS sender in the RCS Senders page in the Twilio Console and view the Profile Information.
You can use the Google SMS link creator to generate the deep link and QR code.
After you send RCS messages, you can monitor and analyze your RCS traffic by using Programmable Messaging Logs in the Twilio Console and Messaging Insights. If you don't see a log for your message, you can view errors on the Error Logs page in the Twilio Console.
If Twilio successfully sent the message with RCS, the From
field contains rcs:<SenderId>
. You can view this field in the Programmable Messaging Logs in the Twilio Console, outbound message status callbacks, and Fetch a Message resource request results.
In many regions, RCS tracks delivered
and read
statuses more reliably than SMS does. If you need to A/B test the two channels, we recommend using other metrics, such as clicks or conversions.