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.
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.
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:
from rcs import (
Action,
However this doesn't yet have a webhook to listen for the status callback. We'll need to add that in next.
def main():
client.send.rcs(to="+16287261512", from_="test", text="Did you get this?", status_callback="https://ghost-related-humbly.ngrok-free.app")
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.
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.
@app.post("/")
async def root(request: Request):
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:
INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
{'messageId': 5451, 'status': 'sent'}
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:
# Visit localhost:8000/send to send a message
@app.get("/send")
Now, if we visit localhost:8000/send
, we should see a message sent to the user and a status callback request come in.
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
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:
and then click enable read receipts:
Now you should see the read receipt status update.
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.