Semi-Distinct Group Chat

Our app consists of users and teams. Each user can be a part of multiple teams.

We’d like users on a team to be able to start distinct chats with each other. So, each time a user on a team contacts an existing chat with a user, the same chat loads.

However, we don’t want group chats to be distinct across teams. For example, User A and User B on Team 1 start chatting, we would like that to be distinct for that team. If the same two users start a chat on Team 2, we would want it to start a new chat (despite being the same two users).

Is this scenario possible? If so, how can we accomplish this? Would setting the “custom_type” to be the Team ID be sufficient?

1 Like

Yes, if you set the custom_type to the team id, it will include that as part of the distinct logic. So if you Specify User A, User B and the Team, it will only return a channel with the same team in custom_type. If it doesn’t exist, it will create it.

You do need to know not to request a distinct channel if you don’t want one. (e.g. in the example for Team 2.) There is no way to change the default setting for distinct for a custom_type - it is always false unless you specify otherwise on create.

Perfect, thank you! That helps.

@Doug_Exner after diving deeper, I can’t tell if this is fully working.

For example, I’m creating a channel with

distinct = true
custom_type = "APPNAME:CHANNEL:COURSEID:12345"

I am able to filter the channel list by APPNAME:CHANNEL:COURSEID:12345 correctly.

However, if I select the same users from the previous chat, but use a different custom_type, it returns the previous chat. My understanding is that “distinct” factors in, not just the userIds within a chat, but also the custom_type. That doesn’t appear to be the case.

I’m not sure if it matters, but the channel being created right now only includes 1 user. Is there a limitation/bug regarding the distinct property when only having 1 user?

After further research, there is a backend setting that needs to be enabled in your application to allow custom_type to be part of the grouping for is_distinct.

If you DM me your application id, I’ll see if I can get it turned on for you.

1 Like

Sorry for the necro, but I’ve got the exact same issue. Which backend setting can I change to allow custom_type to be part of the grouping for is_distinct?