1

I am using twilio conversations for chat. I did not find any information on this in the documentation.

My questions are:

  1. Can I get information about whether the users of the conversation are offline or online? If yes, then how to.
  2. Should I manually send the user online status in order for it to be available for other members of the conversation?

This https://stackoverflow.com/a/69429640/19023823 answer did not help me as it shows how to get the online status of the current users. I need to get the online status of the other members of the conversation.

Thanks.

Crafty
  • 25
  • 6

1 Answers1

5

PM for Conversations here. You need to enable reachability on the Service first, then online status will be automatically tracked for SDK users. This info is retrievable via REST API and also exists on a User object via the SDK (and is evented when the status changes).

Once you turn this on, it will be automatically updated for all users of the SDK. You can look at the Participants in a Conversation with await Conversation.getParticipants() and then check their User object's online status with Participant.getUser().isOnline. Alternatively, you can get timely updates about changes to any user's online status by listening for userUpdated events on the client object.

philnash
  • 70,667
  • 10
  • 60
  • 88
  • Thank you so much for the answer. I was struggling to get the user object from the participant. Your answer really helped. Thanks again! – Crafty May 06 '22 at 15:06
  • After spending 3 days I finally got solution thanks.... – Leena Aug 26 '22 at 08:22
  • @philnash I am trying to get a list of all users (for all conversations) and their online/offline status. However, when I invoke `client.getSubscribedUsers()` I only get back the current authenticated user. How do I retrieve all the other users too? Thank you! – comixninja Sep 15 '22 at 19:01
  • The answer to my question above is: You have to get each user first. Calling `client.getUser(sid)` will automatically subscribe you to that user. – comixninja Sep 24 '22 at 17:26