Message Counts

Retrieve unread message counts

If you store the timestamp of the last message that a user read, you can use the messageCounts method to fetch how many messages have been sent since that last message for a given channel.

chat.messageCounts([
    { channelId: "alpha", timestamp: 1617883692337 },
    { channelId: "bravo", timestamp: 1617883692337 }
]).then((res) => {
    const { channels } = res;
    channels.forEach(channel => {
        const { id, count } = channel;
        // Use `id` and `count` to update the unread counts for each channel.
    });
});

.messageCounts(channelTimestampPairs: array)

Name

Type

Required

Description

channelTimestampPairs

array[{channelId: string, timestamp: integer }]

yes

The method takes an array of objects that each must specify the keys channelId and timestamp.

Last updated