Redis Message Aggregator icon

Redis Message Aggregator

Gom tin nhắn từ nhiều trigger riêng biệt với Redis + intelligent delay

Overview

This node aggregates messages from multiple independent triggers using Redis as a backend store combined with an intelligent delay strategy. It is designed to collect message fragments or related messages keyed by user ID, group ID, or a combination thereof, and then output the aggregated content either after a smart waiting period or immediately once a complete sentence is detected.

Common scenarios include:

  • Collecting chat messages sent in parts before processing them as a whole.
  • Grouping messages from a specific user or group for batch processing.
  • Waiting for a natural pause in conversation before triggering downstream workflows.

Practical examples:

  • A chatbot that waits until a user finishes typing a multi-part message before responding.
  • Aggregating customer support messages from a group chat to analyze the entire conversation context.
  • Combining fragmented sensor data messages identified by device keys before further analysis.

Properties

Name Meaning
Key Key to group messages by (can be a user ID, group ID, or a combination like "user123_group456").
Message Content The actual message text content to aggregate.
Wait Time (Seconds) Time in seconds to wait after the last message before outputting the aggregated result.
Strategy Aggregation strategy:
- Smart Wait: Wait intelligently and output only when sure no new messages will arrive.
- Immediate on Complete: Output immediately when a complete sentence is detected based on end words.
End Words Comma-separated list of words indicating the end of a message (e.g., "xong, rồi, nhé, ah, ạ"). Used only with the "Immediate on Complete" strategy to trigger immediate aggregation when a message ends with one of these words.

Output

The node outputs JSON objects representing the aggregation status and results. The structure varies depending on the strategy and state:

  • status: Indicates the current state, e.g., "messages_aggregated", "message_stored", "timeout", "no_messages", "superseded".
  • key: The aggregation key used.
  • aggregatedMessage: The concatenated string of all collected messages (present when messages are aggregated).
  • messageCount: Number of messages aggregated.
  • originalMessages: Array of original message objects with content and timestamp.
  • trigger: Reason for output, such as "immediate_complete" or "smart_timeout".
  • aggregatedAt: ISO timestamp when aggregation occurred.
  • Additional fields depending on status, e.g., reason, maxWaitTime, totalWaitTime.

If the node cannot find any messages or if messages expire, it outputs statuses like "no_messages" or "timeout" with explanatory reasons.

The node does not output binary data.

Dependencies

  • Requires a Redis server accessible via credentials configured in n8n.
  • Uses the Redis client library to connect and perform operations.
  • Needs an API key credential or connection details for Redis (host, port, password, TLS, etc.).
  • No other external services are required.

Troubleshooting

  • Missing Redis Credentials: The node throws an error if Redis credentials are not found. Ensure proper Redis credentials are configured in n8n.
  • Connection Issues: Errors related to connecting to Redis may occur if the host, port, or authentication details are incorrect or if the Redis server is unreachable.
  • Timeouts: If messages do not arrive within the specified wait time, the node outputs a timeout status. Adjust the wait time property accordingly.
  • Locking Conflicts: The node uses Redis locks to prevent concurrent aggregations on the same key. If multiple executions happen simultaneously, some may be superseded.
  • Invalid Input: Both "Key" and "Message Content" properties are mandatory; missing these will cause errors.
  • Parsing Errors: Stored messages are JSON-parsed; malformed stored data could cause parsing exceptions.

Links and References

Discussion