Stream Chat icon

Stream Chat

Server-side Stream Chat operations

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 Filter matches existing channels. An empty filter {} returns all channels up to the limit.
  • Invalid JSON: Ensure that the Query Filter and Query Sort fields 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 Limit may 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.

Links and References

Discussion