How to Send an RCS message with Twilio and Python

January 24, 2025
Written by
Reviewed by

Rich Communication Services (RCS) is revolutionizing digital communication by bringing together the best of SMS and modern messaging apps. The recent addition of RCS support on iOS 18 has opened up exciting possibilities for reaching Apple users. As developers worldwide begin exploring this powerful channel, the potential for creating engaging messaging experiences has never been greater.

In this tutorial, we'll show you how to get started with RCS using Twilio and Python.

Twilio recently launched its public beta for RCS messaging. Join the public beta and start working with RCS today!

Visit Twilio’s RCS Business Messaging page and click Get started. Your request should be quickly approved.

Comparing RCS to SMS and WhatsApp

Think of RCS as the natural evolution of SMS, enhanced with features you'd typically find in modern messaging apps. Unlike WhatsApp or other messaging platforms, RCS works directly through your phone's default messaging app - no additional downloads required. You get all the powerful features: rich media sharing, typing indicators, read receipts, verified business profiles, and interactive buttons. For businesses, this means higher engagement rates and better analytics, while users enjoy a seamless, app-like experience without the friction of installing another messaging app.

What sets RCS apart is its ability to maintain the universal reach of SMS while delivering these enhanced capabilities. For a deeper dive into how RCS stacks up against other messaging channels, check out the Guide to Rich Communication Services: What Developers Need to Know.

Implementing RCS with Twilio and Python

Twilio makes it easy to explore and implement RCS. In this section, you’ll learn how to set up an RCS sender, create a messaging service, and send your first RCS message using Python. Follow these step-by-step instructions to get started.

Prerequisites

  1. A Twilio account (sign up here).
  2. A Twilio phone number for sending SMS, as a fallback to your RCS service.
  3. A device capable of receiving RCS business messages.
  4. Python installed on your machine.

Step 1: Create RCS Sender

  1. Log in to the Twilio Console.
  2. Navigate to the Explore Products section and click RCS.

    (If RCS isn’t available, you may need to request access.)
Screenshot of a web interface showing tabs for different messaging and network services.

3. In the side panel, navigate to the Senders section.

4. Click Create new sender.

Email sender management interface with Create new sender button highlighted on a computer screen.

5. Provide a name (for example: “My First RCS Sender”). Click the continue button.

Browser window showing the process of creating a new sender on an email management dashboard.

Step 2: Add Profile Information

Next, you’ll add profile information for your RCS sender. Use the following:

  • Sender display name: Choose a recognizable name for your sender. Usually, this is your brand name. For our example, we will use “My First RCS Sender”.
  • Description: Describe your brand. This description will be displayed just under your display name at the top of your user’s RCS interactions.
  • Border color: Keep in mind the minimum contrast ratio. For testing purposes, start with #000000 to keep it simple.
  • Logo: Your brand logo should meet the following requirements: • Dimensions: 224x224 pixels • File size: Max 50 KB • Image type: JPEG/JPG/PNG • For testing, you can use this example image: https://corn-lobster-7338.twil.io/assets/twiliodevs-logo-rcs.png
  • Banner: Your brand banner should meet the following requirements: • Dimensions: 1440x448 pixels • File size: Max 200KB • Image type: JPEG/JPG/PNG • For testing, you can use this example image: https://corn-lobster-7338.twil.io/assets/twiliodevs-banner-rcs.png
  • Contact Details - Phone number: A phone number associated with your RCS sender is required. Optionally, you can also add an email address.
  • Link to privacy policy and Link to terms of service: For testing purposes, you can enter links to arbitrary information here. When you begin building for production usage, make sure to create an RCS sender with real information about your business.
Screen with steps to complete Twilio sender profile information and click next button.

Step 3: Test your RCS Sender

1. On the optional Test tab, click Add device to test this sender.

Twilio interface to test sender and confirm brand information, plus option to add a test device.

2. Enter the phone number of your RCS-capable device and click Invite.

3. You should receive an opt-in message from Twilio’s RCS agent on your device.

4. Confirm the opt-in on your device by selecting Make me a tester.

5. Check the dialog box in the Twilio Console, and send a test message.

Instructions for confirming a test device and sending an RCS message with two connected devices.

6. Excellent! You’ve just sent your first RCS message!

Phone screen showing the first RCS message received from a Twilio sender.

7. Since this is just a test sender, click Save as draft and close.

Screenshot of Twilio's Create Sender interface with test device details and message preview.

Step 4: Create a Messaging Service

  1. In the Console, navigate to Messaging > Services.
  2. Click Create Messaging Service.
Web page showing messaging services dashboard with a search bar and Create Messaging Service button.

3. Give the new service a name (for example: “My RCS Service”) and click Create Messaging Service.

Web interface for setting up a messaging service with fields for the service name and its purpose.

4. Add your RCS sender.

5. Click Add Sender, select RCS Sender.

Web page interface showing steps to add a new RCS sender with directions and annotations.

6. Add the RCS sender you just created.

Screenshot of adding senders in an RCS messaging service tool.

7. Add an SMS fallback sender by repeating the Add Sender process and selecting a phone number (or other SMS-capable sender). Then, click Step 3: Set up integration.

Screenshot of a web interface displaying sender pool options and instructions to add a phone number or continue to integration.

Step 5: (Optional) Set Up Webhook Integration

  1. Webhooks allow you to handle incoming messages in the same way as SMS or WhatsApp. Learn more in Twilio's docs about Incoming Message Webhooks.
  2. Use the Set Up Integration option to register a webhook. Feel free to reuse an existing one if available.
Web application showing integration settings with options to receive incoming messages and add webhooks.

Step 6: Send Your First RCS Message with Python

  1. Finish the wizard flow by clicking the white Skip setup button.
Browser window showing a settings page for configuring message delivery options with a skip wizard button.

2. Copy the Messaging Service SID (e.g., MGe1fdfb207e9aa5b44f398b1094d88a8b) from the Console.

Dashboard showing messaging service SID under properties with instructions to copy it.

3. Retrieve your Account SID and Auth Token from the Twilio Console.

4. Create a new folder and within that folder create a file .env. Add the credentials from the previous steps, so that your file looks like this:

TWILIO_ACCOUNT_SID="ACxxxxxxxxxx"
TWILIO_AUTH_TOKEN="51fxxxxxxxxxx"
TWILIO_MESSAGING_SERVICE_SID="MGxxxxxx"
TO_PHONE_NUMBER="YOUR_RCS_ENABLED_NUMBER"

5. Create a virtual environment and install the required dependencies:

python -m venv .venv
source .venv/bin/activate
pip install twilio python-dotenv

6. Create a new file named send_rcs.py with the following code:

import os
from twilio.rest import Client

from dotenv import load_dotenv
load_dotenv()

#Your Account SID from twilio.com/console
account_sid = os.getenv("TWILIO_ACCOUNT_SID")
auth_token = os.getenv("TWILIO_AUTH_TOKEN")

# Initialize the Twilio client
client = Client(account_sid, auth_token)
message = client.messages.create(
	body="This RCS message contains an image",
	messaging_service_sid=os.getenv("TWILIO_MESSAGING_SERVICE_SID"),
	media_url="https://pbs.twimg.com/media/GZbs3vZWAAAwqVX?format=jpg&name=medium",
	to=os.getenv("TO_PHONE_NUMBER"),
)

# Print the message SID
print(f"Message sent! SID: {message.sid}")

7. Run the script using python send_rcs.py and see the result on your phone.

Smartphone screen showing a message about receiving the first RCS message from a Twilio sender.

As you transition from sandbox testing to production usage, you’ll need to pass the country-specific verification process we skipped above. This requirement ensures compliance with local regulations and protects users from potential messaging spam. While this might introduce initial friction, it guarantees that messages from reputable sources maintain their integrity, significantly reducing spam and increasing user trust. Twilio and other carriers around the world are committed to fighting spam and avoiding the problems that were caused by the permissionless nature of SMS. For further guidance, check out Twilio's RCS Documentation.

Explore Advanced RCS Features

Congratulations on sending your first RCS message with Twilio and Python! Now, let's explore some features that set RCS apart from traditional SMS:

RCS is transforming how businesses communicate with customers, blending the reliability of SMS with the interactivity of modern messaging apps. With Twilio, you can harness the power of RCS to create engaging and rich communication experiences from your applications.

We can’t wait to see what you build!