8

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:

enter image description here

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:

  1. Get the list all channels for the current user
  2. 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)
  3. Get the identity of the other user + from our backend, get the name and the avatar.
  4. 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

SnuKies
  • 1,578
  • 1
  • 16
  • 37
  • Did you ever solve #4 of this? – David Mar 28 '20 at 07:11
  • No really. I can't remember properly, but we ended up loading the last message when a channel's been fully loaded. We used coroutines which simplified our work really. I will look this evening more into the solution and return with a complete answer – SnuKies Mar 30 '20 at 07:52
  • Thank you very much! At this point, I'm just loading the last 30 messages during my initialization, so at least navigating to the chat will be quicker with preloaded data. – David Mar 30 '20 at 08:20

0 Answers0