Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Twilio Chat User Channels sorted by last activity or unread count?

We are developing a chat system where users can be in many chat rooms, and I'd like to be able to show the most recent channels first.

This could be either by the time the last message was sent, or even by the number of unread messages, as long as there is some order and I don't need to go through all the pages of channels and get additional metadata to sort it manually.

I can't see any options in the docs and even though the response metadata has a "key" set to "channels", I haven't been able to figure out a query parameter that can change that.

It seems like channels will always be returned ordered by the random unique channel ID, so for pretty much every use case you'd need to get all channels and sort manually. Is that the case or am I missing something?

like image 651
Bonnici Avatar asked Nov 14 '17 23:11

Bonnici


People also ask

What can you do with Twilio chat?

Add chat functionality to your app or browser using Twilio’s API and trusted platform that power any conversational workflow. Create engaging chat experiences for apps and the web with one flexible API. Easily extend engagement to all your customers’ preferred channels.

How to get the last consumed message index for a channel?

Each client SDK provides a method allowing the User to send a Consumption Report which supplies the User's last consumed Message index for the Channel. Besides that, there are two helper methods for most common operations used in Consumption Horizon feature: marking all messages as read and marking them back unread.

What can Twilio do for your business?

Create engaging chat experiences for apps and the web with one flexible API. Easily extend engagement to all your customers’ preferred channels. All while Twilio’s trusted platform protects your relationships with best-in-class reliability. Drive two-way engagement with cross-channel messaging for in-app chat and more using a single API.

What is the user channel resource of programmable chat?

The User Channel resource of Programmable Chat is a read-only resource that describes a Channel that the User is a Member of. Each User Channel resource contains these properties. The SID of the Account that created the User Channel resource. The SID of the Service the User Channel resource is associated with.


1 Answers

Twilio developer evangelist here.

I'm afraid you cannot order the channels within the API right now. This feature is on the roadmap though, however I can't give any time estimates for it.

The solution for now is sorting manually. I will update once that changes though.

like image 107
philnash Avatar answered Nov 08 '22 04:11

philnash