Have you read the previous tutorials?

This tutorial is a follow up to our previous tutorial where we went over how to receive RCS Business Messages. If you haven't read that yet, I recommend starting there.

What are read receipts?

Read receipts are a feature that allows users to know when a message has been read by the recipient. This is a great way to know if your message has been read, and can be used for a variety of use cases, such as confirming that a message has been read, or triggering an action when a message is read.

Getting Started

In the previous tutorials, we went over how to sent RCS Business Messages and how to receive them. In this tutorial, we'll go over how to get read receipts for our messages.

First, we'll need to send a new message to a user:

python
from rcs import ( Action, Card, InboundActionMessage, InboundLocationMessage,

Adding our status callback url

However this doesn't yet have a webhook to listen for the status callback. We'll need to add that in next.

python
def main(): client.send.rcs(to="+16287261512", from_="test", text="Did you get this?", status_callback="https://ghost-related-humbly.ngrok-free.app") import uvicorn uvicorn.run(app, host="0.0.0.0", port=8000)

This is a basic ngrok tunnel that pipes to port 8000 on our local machine. You can learn more here if you don't know how to set up ngrok.

Handling the status callback

Now, we're provided a webhook but we need logic to handle the status callback request coming in. When we get a status callback request, we'll log it to the console.

python
@app.post("/") async def root(request: Request): # Parse the incoming JSON payload data = await request.json() print(data)

Now if we run the main function, we should see a message sent to the user and a status callback request come in. We should see something like this in the terminal:

bash
INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) {'messageId': 5451, 'status': 'sent'} Message 5451 status updated to: sent INFO: 98.80.99.156:0 - "POST / HTTP/1.1" 200 OK {'messageId': 5451, 'status': 'read'}

Notice, when I ran it here there is no pending status update received before the sent status update. That's because our server is starting after sending the messsage and doesn't boot up before the message is sent.

To fix this, we can move our send message logic into its own endpoint on the server:

python
# Visit localhost:8000/send to send a message @app.get("/send") async def send_message(): response = client.send.rcs( to="+16287261512",

Testing it out

Now, if we visit localhost:8000/send, we should see a message sent to the user and a status callback request come in.

bash
INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) INFO: 127.0.0.1:57588 - "GET /send HTTP/1.1" 200 OK {'messageId': 5452, 'status': 'pending'} Message 5452 status updated to: pending INFO: 18.234.111.164:0 - "POST / HTTP/1.1" 200 OK

Quick tip

If you don't see the 'read receipt' status update, it could be because you haven't read the message on your phone, but it could also be because your read receipts for the RBM agent are disabled on your phone. To enable read receipts on iOS if you turned them off, you can click on the company logo at the top of your conversation:

RBM read receipts
RBM read receipts

and then click enable read receipts:

RBM read receipts
RBM read receipts

Now you should see the read receipt status update.

Learning more

You can checkout the Github Repo for this tutorial here.

If you still have trouble, you can always reach me on X or email us.