Message Aggregator icon

Message Aggregator

Intelligently aggregate messages with smart waiting strategies

Message Aggregator

AI-generated

Overview

The Message Aggregator node intelligently aggregates messages based on configurable strategies such as waiting for a period with no new messages (Smart Wait), processing immediately upon detecting completion words (Immediate on Complete), or processing when a maximum message count is reached (Max Count). It supports grouping messages by a specified field, aggregating them with customizable separators, and optionally storing messages persistently in a Supabase database. This node is useful in scenarios where messages from multiple sources or sessions need to be combined and processed efficiently, such as chat message aggregation, session data consolidation, or batch processing of event logs.

Use Case Examples

  1. Aggregating chat messages by thread ID and processing them after a period of inactivity.
  2. Combining user session messages and triggering processing immediately when a completion word like 'done' is detected.
  3. Storing messages in a database and processing them once a maximum count is reached, ensuring batch processing.

Properties

Name Meaning
Processing Strategy Strategy for determining when to process messages, options include Smart Wait, Immediate on Complete, and Max Count.
Wait Time (seconds) Time to wait with no new messages before processing, applicable only for Smart Wait strategy.
Completion Words Comma-separated words that trigger immediate processing, applicable only for Immediate on Complete strategy.
Max Messages Maximum number of messages before processing, applicable for Max Count and Smart Wait strategies.
Group By Field Field to group messages by, such as user_id, thread_id, or session_id.
Message Field Field containing the message content to be aggregated.
Aggregation Method How to combine multiple messages, with options for New Line, Space, Comma, or Custom separator.
Custom Separator Custom separator string used when Aggregation Method is set to Custom.
Use Database Whether to use a Supabase database for persistent message storage.
Auto Create Tables Automatically create required database tables in Supabase if enabled.
Table Prefix Prefix for database table names used in Supabase.

Output

JSON

  • status - Status of the message processing, e.g., 'messages_aggregated' or 'message_stored'.
  • groupKey - The key used to group messages, based on the Group By Field.
  • aggregatedMessage - The combined message string after aggregation.
  • messageCount - Number of messages aggregated in the current batch.
  • messages - Array of individual messages included in the aggregation.
  • metadata - Array of metadata objects corresponding to each message.
  • trigger - Reason for processing the messages, e.g., 'completion_word', 'max_messages', or 'wait_timeout'.
  • strategy - The processing strategy used for aggregation.
  • processedAt - Timestamp when the messages were processed.

Dependencies

  • Supabase database for persistent message storage (optional)
  • Supabase API credentials if database usage is enabled

Troubleshooting

  • Ensure Supabase credentials are correctly configured if using database storage; missing credentials will cause errors.
  • If automatic table creation is disabled or fails, manually create the required tables in Supabase as per the provided SQL schema.
  • Errors related to message storage or retrieval from the database indicate connectivity or permission issues with Supabase.
  • Check that the Group By Field and Message Field exist in the input data to avoid missing or incorrect aggregation.

Links

  • Supabase Documentation - Official documentation for Supabase, useful for setting up and managing the database used by this node.

Discussion