We're trying to implement Twilio's Chat into our application.
Our current task consist in showing all the conversations for the current user. Like in the image below:
As you can see, we display 4 things: the avatar, the username, the last message and the time of the last message (ignore for now the bolding. That's related to whether the user's read the last message or not)
With what I could gather from Twilio's API, this is done in the following steps:
- Get the list all channels for the current user
- From the response, for each channel, get the members of that channels (in our case, only 1 members, since all are private, 1-on-1 conversations)
- Get the
identity
of the other user + from our backend, get the name and the avatar. - Get the last message from the Twilio's api, using the link provided by the first operation
As you can see, this implies multiple calls (3-4) to the Twilio's API, just to get the latest information about a channel.
My question is: can we do something like in fewer calls to the Twilio's API? (ignoring the calls to our backend, those do not count here)
Also, could we store some more data on the twilio's server? Like the name of the user and the avatar