
How to Send RCS Image Messages With Python
Rich Communication Services (RCS) enhances traditional SMS & MMS by enabling features like high-resolution images, videos, and interactive elements. An RCS image message allows businesses to send images directly to users' default messaging apps, providing a richer communication experience.
In this tutorial, you’ll learn how to quickly send images using RCS messaging with Vonage’s Messages API in Python.
TL;DR: Find the complete working code on GitHub.
RCS message showcasing an image sent via the Vonage Messages API, featuring the Vonage Developer Relations team at a conference booth.
Why Use RCS For Image Delivery?
For the most reliable experience with larger media (like high-res images or videos), RCS is the preferred option if your user base supports it. RCS allows for much bigger and higher-resolution images compared to traditional MMS.
The maximum file size for MMS is 600 KB. For RCS, the limit is 100 MB. That’s a 17,000% increase!
> Note: MMS Limits vary by Carrier, Country, and more.
Prerequisites
Before you begin, ensure you have the following:
Python 3.6 or higher is installed on your machine.
A Vonage API account.
A registered RCS Business Messaging (RBM) Agent.
A phone with incoming RCS capabilities for testing.
Vonage API Account
To complete this tutorial, you will need a Vonage API account. If you don’t have one already, you can sign up today and start building with free credit. Once you have an account, you can find your API Key and API Secret at the top of the Vonage API Dashboard.
How to Contact Your Vonage Account Manager
In order to send and receive RCS capabilities in your Vonage application, you will need to have a registered Rich Business Messaging (RBM) agent and a phone with RCS capabilities.
Currently, RCS Messaging through Vonage is only available for managed accounts. You will need to contact your account manager to request Developer Mode activation for your RBM agent. Developer Mode allows you to test RCS messaging to allow-listed numbers before completing the Agent Verification process and launching in production.
Please contact our sales team if you do not have a managed account.
>> Understand the difference between RCS and RBM.
Step 1: Create Your Project and Install Dependencies
Create your project folder and files.
mkdir python_send_rcs_image
cd python_send_rcs_image
touch .env send_rcs_image.py
Set up a virtual environment.
This ensures your dependencies stay isolated from your system Python.
python3 -m venv venv
source venv/bin/activate
Install the required packages.
In addition to the Vonage SDK, we’ll use dotenv to securely store and access our Vonage credentials.
pip install vonage python-dotenv
Step 2: Set Up Your Vonage Application
Your Python script will use the Vonage Messages API. In order to do that, create a Vonage application in the Vonage Dashboard with the Messages API capability enabled.
In your Vonage application settings:
Set the Inbound URL to https://example.com/inbound_rcs.
Set the Status URL to https://example.com/rcs_status.** Inbound messages and message statuses will be covered in a future article. For now we can just use placeholders.
Generate a public and private key by clicking the button. Ensure to move your private.key file to the project root directory (/python_send_rcs_image).
Save the changes.
Vonage Developer Dashboard interface for creating a new application with RCS messaging capabilities, including webhook configuration and key authentication setup.
Then link your RCS Agent by clicking the “Link external accounts” tab:
Dashboard view of the Vonage Python RCS application showing linked external account details, application metadata, and configuration for Voice and Messages APIs.
And now you can add your credentials to your .env
file.
VONAGE_APPLICATION_ID=your_application_id
VONAGE_PRIVATE_KEY_PATH=./private.key
RCS_SENDER_ID=your_rbm_agent_id
Step 3: Write the Python Script to Send an RCS Image Message
Create a Python file (send_rcs_image.py
) with the following content:
import os
from dotenv import load_dotenv
from vonage import Auth, Vonage
from vonage_messages import RcsImage, RcsResource
# Load environment variables
load_dotenv()
# Initialize Vonage Auth and client
auth = Auth(
application_id=os.getenv("VONAGE_APPLICATION_ID"),
private_key=os.getenv("VONAGE_PRIVATE_KEY_PATH"),
)
vonage_client = Vonage(auth)
# Define the recipient's phone number and image URL
to_number = "###########" # Your recipient's phone number
image_url = "https://www.vonage.com/content/dam/vonage/us-en/api/imagery/RCS_iPhoneScreen_V2-scaled.png" # Replace with your image_url
# Construct the RCS Image message
message = RcsImage(
from_=os.getenv("RCS_SENDER_ID"),
to=to_number,
image=RcsResource(url=image_url),
)
# Send the message
response = vonage_client.messages.send(message)
print(response)
Ensure that the to_number is a phone number with RCS capabilities and that the image_url is a publicly accessible URL pointing to your image. Notice that the from field is your RBM SenderID (the Name of the Brand). The SenderID requires special formatting, such as not having any spaces. Check with your account manager if you’re unsure.
Step 4: Run the Script
Execute the script using the following command:
python send_rcs_image.py
If successful, the response will contain a message_uuid, indicating that the message has been accepted for delivery.
Conclusion
You've now learned how to send RCS image messages using Python and the Vonage Messages API. What RCS capability will you explore next? You can see the full list of RCS message capabilities in the developer documentation.
Be sure to let us know what you are working on or reach out for help on our Community Slack, or X, formerly Twitter.
Share:
)
Benjamin Aronov is a developer advocate at Vonage. He is a proven community builder with a background in Ruby on Rails. Benjamin enjoys the beaches of Tel Aviv which he calls home. His Tel Aviv base allows him to meet and learn from some of the world's best startup founders. Outside of tech, Benjamin loves traveling the world in search of the perfect pain au chocolat.