Filter conversations in real-time
Building customer support portals, team chat apps, or marketplaces often means working with large numbers of conversations. You can now easily surface exactly those conversations you need by adding powerful filtering when subscribing to conversations.
Looking for all support tickets from last week? Conversations about the upcoming launch? Or filter only conversations involving the design team? A filtered conversation list subscription gets you those directly.
You can subscribe to filtered conversation lists based on custom fields, activity dates, and more.
Conversation list filtering is available on the JavaScript Data API (1.10.0), Components SDKs (0.1.11), and the Classic SDKs (0.46.0).
Subscribe to filtered conversations with the JavaScript Data API
To filter conversations when building with the JavaScript Data API (@talkjs/core), you can use the new filter option. Filters work on standard conversation fields such as lastActivityAt, as well as on custom attributes you've set on conversations.
Example: Show only support conversations
To subscribe to conversations with a custom category field ‘support’, you could do the following:
// Subscribe to support conversations
session.subscribeConversations({
filter: { custom: { category: ["==", "support"] } }
}, onSnapshot);Example: Hide inactive conversations
Or to subscribe to conversations with activity in the last seven days:
// Subscribe to conversations with recent
const sevenDaysAgo = Date.now() - 7 * 24 * 60 * 60 * 1000;
session.subscribeConversations({
filter: { lastActivityAt: [">", sevenDaysAgo] }
}, onSnapshot);Updates to conversation subscription filters are real-time: when a conversation matches your filter, it appears immediately. When it no longer matches, for example after a support ticket has been resolved, it disappears from the list.
For more details on what filtering options you can use, also see ConversationFilter.
Update to @talkjs/core 1.10.0 to start using conversation list filtering.
Filtered conversation lists with the Components SDKs
If you’re using the Components SDKs, you can filter conversations using the new conversationListFilter prop in both the ConversationList and Inbox components. When using this prop, you can display only those conversations matching the given filter.
Updating the conversationListFilter prop re-subscribes to the conversation list with the new filter.
Example: Filter conversations by team
For example, to show only conversations of the design team:
// Show only support conversations
<ConversationList
appId="<APP_ID>"
userId="<USER_ID>"
conversationFilter={{ custom: { team: ["==", "design"] } }}
/>Example: Hide empty conversations
To show only conversations that contain messages (in other words, hide empty conversations), you can do the following:
// Show only conversations with messages
<ConversationList
appId="<APP_ID>"
userId="<USER_ID>"
conversationFilter={{ hasMessages: true }}
/>Upgrade to Components SDKs 0.1.11 to start using conversation list filtering.
How it works
When you subscribe to a conversation with a filter, you initially receive up to 20 matching conversations.
Conversations appear in reverse chronological order, with the most recent activity at the top of the list. The most recent activity of a conversation is either when the last message was sent or when the user joined that conversation, whichever is later.
As new messages arrive or new conversations are joined, the filtered list updates automatically. You can also call loadMore to fetch additional older conversations that match your filter.
This makes it easy to build conversation list UIs that always show the most active conversations.
Use cases
When might filtered conversation lists be helpful? You could benefit from using conversation list filtering with a wide range of application types:
- Support platforms: Filter conversations by ticket status, priority, or assigned team.
- Marketplace apps: Show active buyer-seller conversations.
- Team collaboration: Filter by channel, project, or conversation type.
- Multi-tenant apps: Display only their own conversations to each user.
- Community platforms: Filter conversations by category, moderation status, or activity level.
Get started
To get started with filtered conversation list subscriptions, explore the full documentation: