Read receipt error

I have created a brand new channel with 2 members SENDER and RECIPIENT and have sent a message from SENDER to RECIPIENT through the Platform API.

When I call https://api-token.sendbird.com/v3/group_channels/channel_url?show_member=true&show_read_receipt=true just after sending the message, the response is

{
...
 "read_receipt": {
        "RECIPIENT_USER_ID": 1612443879592,
        "SENDER_USER_ID": 1612443879403
    },
...
}

I’m sure the RECIPIENT hasn’t logged in to the application or seen the message. Can someone explain how are read receipts calculated or whether there is a better way to get the read receipts on the channel?

@SafiyyaBabio,

Thank you for reaching out to us about this. What is the created_at for the channel time of the channel on the same API call?

On creation, all users are given a read receipt of the time they were joined to the channel. So they’ll always have a value for read receipt. In my example, I added three people just to show that the two people not logged in have the same value:

    "read_receipt": {
        "e0a9230d-acc6-406d-b80f-d201ded4c909": 1612446151668,
        "cd77896e-a6c7-4ca6-854a-3db4dfbbef2c": 1612445972229,
        "f37c86ff-ea8c-4a30-83bb-7d844840f783": 1612445972229
    },

Thanks,
Tyler

Thanks Tyler, that’s helpful.

In this case, what is the best way to assess if the RECIPIENT has read the first ever message in the channel?
The created_at is "created_at": 1612443879,

Great question. Just to put everything into perspective, here are the dates of the times provided:

Created At: Thursday, February 4, 2021 1:04:39 PM
Recipient Read Receipt: Thursday, February 4, 2021 1:04:39.592 PM
Sender Read Receipt: Thursday, February 4, 2021 1:04:39.403 PM

In order to determine if recipient has read the first ever message, you’d need to compare their read receipt time with the last message created at time.

Not sure I understand how this would work given that channel.created_at < recipient.received_at and sender.received_at < recipient.received_at will always be true.

In the example I gave above & timings, the recipient still hasn’t seen the message yet.

Can you give me an example?

You need to look at the last message created at, not the channel created at. If you’re sending a message in the channel after the user joins, then the created time of the last message would be greater than the read receipt time of the user who has joined but not read any messages.

Once you’ve made your API Call, you’d compare the value of read_receipt.recipient_user to the value of last_message.created_at.
If read_receipt.recipient_user > last_message.created_at then you know they’ve read it.

Thanks Tyler, I’ll try that. I think I saw a few cases where read_receipt.sender_user > read_receipt.recipient_user and I got confused. Will pop them in here if I see this happening again.

Thanks for your help!

I should note, that I would expect the read_receipt of the sender should always be greater than that of the recipient. Since the sender is actively reading the message they are sending.