0

I am building an application that will (1) create a conversation (chat), (2) create two users, then add the two users to the conversation. This part is working.

At a future time, given the Conversation SID (CHXXX...), I would like to remove the Users and the conversation. I can get a list of the conversation participants, but this includes a Member SID (MBXXX...) not the User SID (USXXX...). I believe I need the User SID to remove the user, not the Member SID.

I may be missing the obvious on how to cross-reference the conversation members to their respective users.

Thanks.

I just realized I was overthinking this issue. When creating the participant, I can create a participant with a unique "identity" and then use that identity to give the user a "friendly name." The friendly name is displayed in the conversation. Then, when I tear down the conversation, I can directly delete the users using their "identity," there is no need to get their actual UserSid.

tcbeaton
  • 85
  • 7

3 Answers3

0

Specific to, "At a future time" - could you leverage timers?

Conversation Timers

With Twilio Conversations' states and timers features, you can manage, store, and archive your application's Conversations.

By using these features, your Conversations participants can focus on active (ongoing) Conversations. You can also close out old or inactive Conversations to make sure you're not exceeding the Participants-per-Conversation limit.

Also:

List Conversation Participants Example and Delete Conversation Participants Example

Alan
  • 10,465
  • 2
  • 8
  • 9
  • See my addition to the original question. I used the "identity" attribute of the participant and user. – tcbeaton Aug 10 '22 at 21:12
0

When you add the participant to the conversation, you will receive the sid in the response, so you could save that to use when you delete the participant from the conversation later.

Alternatively, if you are stuck with just user and conversation SIDs, you can look up the participant SID using the two SIDs you have and the User Conversation resource.

philnash
  • 70,667
  • 10
  • 60
  • 88
0

I just realized I was overthinking this issue. When creating the participant, I can create a participant with a unique "identity" and then use that identity to give the user a "friendly name." The friendly name is displayed in the conversation. Then, when I tear down the conversation, I can directly delete the users using their "identity," there is no need to get their actual UserSid.

tcbeaton
  • 85
  • 7