Receiving RCS Messages
Receiving your first RCS message with Pinnacle's Python SDK
Prerequisites
Before proceeding, ensure you have obtained an RCS sandbox agent and API key as described in the prerequisites.
Installation
Create a Python virtual environment:
python3 -m venv venvActivate the virtual environment:
source venv/bin/activateInstall the Pinnacle Python SDK, FastAPI, and python-dotenv:
pip install rcs==2.0.28 "fastapi[standard]" python-dotenvThis guide uses version rcs==2.0.28. Use Python 3.10 or later for this FastAPI example (the SDK itself supports Python 3.8+)
Configuration
Create an .env file in your project root and add your Pinnacle API key and signing secret:
PINNACLE_API_KEY="your_api_key" # pnclk_
AGENT_ID="your_agent_id" # agent_
PINNACLE_SIGNING_SECRET="your_signing_secret" # pss_Setting Up a Webhook
To receive inbound RCS messages, you need to configure a webhook in the Pinnacle dashboard:
- Navigate to Development > Webhooks in the Pinnacle dashboard
- Click Create new webhook
- Give your webhook a descriptive name
- Enter your webhook endpoint URL
- For local development, use an ngrok tunnel pointing to
localhost:8000/inbound-rcs - For production, use your deployed server URL
- For local development, use an ngrok tunnel pointing to
- After creation, copy the signing secret and add it to your
.envfile - Add your RCS sandbox agent to your webhook for it to receive messages. You must also whitelist the devices you want to test with by navigating to your sandbox agent and adding test device phone numbers.
Optionally, you can configure custom HTTP headers (e.g. X-API-KEY) to be
sent on every webhook delivery. Add them in the dashboard or via the
headers field on POST /webhooks/attach.
The PINNACLE-SIGNING-SECRET header is reserved.
Creating Your Webhook Endpoint
Create a new Python file (e.g., main.py) and use the complete example.
The complete example creates a FastAPI endpoint that:
- Receives webhook POST requests at
/inbound-rcs - Verifies the webhook signature using your signing secret
- Processes received messages, message status updates, typing status updates, and data attached to a button clicked by the recipient.
Running Your Server
Start the FastAPI server:
fastapi dev main.pyYour server will start on http://localhost:8000. If you're using ngrok for local development, start it in a separate terminal:
ngrok http 8000Use the ngrok URL (e.g., https://abc123.ngrok.io/inbound-rcs) as your webhook endpoint in the Pinnacle dashboard.
Testing Your Webhook
Send a POST request using your whitelisted test number. This unauthenticated demo endpoint is for local testing only.
curl -X POST "http://localhost:8000/send-rcs/+14155550123"If there are no errors, you should see something like
{
"message_ids": null,
"segments": 1,
"total_cost": 0.03,
"sender": "agent_exampleId",
"recipient": "+12345678910",
"status": "queued",
"messageId": 6828
}and receive a message on your whitelisted device like this:

If you're not receiving any messages, make sure you have
- Your RCS sandbox agent associated with your webhook
- Your test device is whitelisted
If you tap "Say hello back", your whitelisted device should receive a text saying "Hello! Button clicked successfully."
With that, your webhook should now be successfully receiving inbound RCS messages as well message status updates for outbound messages! You can monitor these statuses by filtering events by their message direction set to outbound:
if message_event.direction == "OUTBOUND":
print(message_event)For more detail about processing the message payload received, please view the process method.