List conversations
List existing conversations
Get a list of existing group chat and DM conversations in the local database.
By default, list returns only conversations with a consent state of allowed or unknown.
We recommend listing allowed conversations only. This ensures that spammy conversations with a consent state of unknown don't degrade the user experience.
To list all conversations regardless of consent state, use the consentStates option and pass all three consent states.
Conversations are listed in descending order by their lastMessage created at value. If a conversation has no messages, the conversation is ordered by its createdAt value.
const allConversations = await client.conversations.list({
consentStates: [ConsentState.Allowed],
});
const allGroups = await client.conversations.listGroups({
consentStates: [ConsentState.Allowed],
});
const allDms = await client.conversations.listDms({
consentStates: [ConsentState.Allowed],
});List a user's active conversations
The isActive() method determines whether the current user is still an active member of a group conversation. For example:
- When a user is added to a group,
isActive()returnstruefor that user - When a user is removed from a group,
isActive()returnsfalsefor that user
// Check if user is active in a specific conversation
const isUserActive = await conversation.isActive();
console.log('User is active:', isUserActive);
// Filter active conversations
const activeConversations = [];
for (const conversation of allConversations) {
if (await conversation.isActive()) {
activeConversations.push(conversation);
}
}You can use a user's active status to filter conversations and potentially have a separate section for "archived" or "inactive" conversations.

