Actions60
- User Actions
- Channel Actions
- Accept Invite
- Add Members
- Add Moderators
- Archive
- Ban User
- Create
- Delete
- Delete File
- Delete Image
- Demote Moderators
- Disable Slow Mode
- Enable Slow Mode
- Get Config
- Hide
- Invite Members
- Mark Read
- Mark Unread
- Mute
- Mute Status
- Pin
- Query Channels
- Query Members
- Reject Invite
- Remove Members
- Send Action
- Send File
- Send Image
- Show
- Stop Watching
- Truncate
- Unarchive
- Unban User
- Unmute
- Unpin
- Update
- Watch
- Message Actions
- Moderation Actions
Overview
The "Query Channels" operation in the Stream Chat node allows users to retrieve a list of chat channels from the Stream Chat service based on specified filter criteria, sorting options, and result limits. This operation is useful for scenarios where you want to display or process multiple channels that meet certain conditions, such as all messaging channels, channels containing specific members, or channels created after a certain date.
Practical examples include:
- Fetching all group channels ("team" type) that a particular user belongs to.
- Retrieving the most recently active livestream channels sorted by last message time.
- Listing channels with a member count above a threshold, sorted ascendingly.
This operation supports MongoDB-style query filters and sorting, providing flexible querying capabilities.
Properties
| Name | Meaning |
|---|---|
| Channel Type | The type of channel to query. Common types include: "messaging" (1-on-1 chats), "team" (group channels), and "livestream" (broadcast channels). |
| Query Filter | A JSON object specifying filter criteria using MongoDB syntax. Examples: {"type": "messaging"}, {"members": {"$in": ["user1"]}}, {"created_at": {"$gte": "2023-01-01"}}. Filters which channels are returned. |
| Query Sort | A JSON object specifying sort order using MongoDB syntax. Use 1 for ascending and -1 for descending. Examples: {"created_at": -1}, {"member_count": 1}, {"last_message_at": -1}. Determines the order of results. |
| Limit | Maximum number of channels to return. Must be at least 1. Defaults to 50. |
Output
The output is an array of JSON objects, each representing a channel matching the query criteria. Each channel object contains detailed information about the channel, such as its ID, type, members, creation date, last message timestamp, and other metadata provided by the Stream Chat API.
If the operation encounters errors, the output may contain error messages associated with the respective input item.
No binary data is output by this operation.
Dependencies
- Requires a valid API key credential for the Stream Chat service configured in n8n.
- The node uses the Stream Chat server-side client library to perform queries.
- Proper permissions must be granted to the API credentials to allow querying channels.
Troubleshooting
- Empty Results: If no channels are returned, verify that your
Query Filtermatches existing channels. An empty filter{}returns all channels up to the limit. - Invalid JSON: Ensure that the
Query FilterandQuery Sortfields contain valid JSON. Malformed JSON will cause errors. - Permission Errors: If the API key lacks permissions, operations will fail. Check your Stream Chat API credentials and their scopes.
- Limit Too High: Setting an excessively high
Limitmay cause performance issues or API rate limiting. - Unsupported Fields: Using unsupported fields in filters or sorts may lead to unexpected results or errors.
Common error messages:
"Unsupported operation: channel.queryChannels"— indicates the operation is not recognized; ensure correct resource and operation selection.- JSON parsing errors for filter/sort inputs — fix JSON syntax.