Message Buffer
AI-generatedOverview
This node buffers incoming messages for a specified conversation key and consolidates them into a single message after a defined wait time. It is useful in scenarios where multiple messages need to be grouped together before processing, such as chat applications or message batching systems. For example, it can collect chat messages from a user over a few seconds and then output a single consolidated message containing all those messages.
Use Case Examples
- Buffering chat messages by user ID to consolidate them into one message after 5 seconds of inactivity.
- Collecting sensor data messages over a short period and then processing them as a batch.
Properties
| Name | Meaning |
|---|---|
| Conversation Key | A unique key to identify and separate different conversations (e.g., userId, chatId). This ensures messages are buffered per conversation. |
| Message Field | The field name in the incoming JSON that contains the message text to be buffered. |
| Output Field Name | The name of the new field in the output JSON that will hold the consolidated message. |
| Wait Time (seconds) | The time in seconds to wait after the last message before consolidating all buffered messages. This timer resets with each new message. |
Output
JSON
jsonconsolidatedMessage- The consolidated message string containing all buffered messages joined together.allMessages- An array of all individual messages that were buffered and consolidated.
Dependencies
- Redis server for message buffering and timing control.
Troubleshooting
- Ensure Redis credentials are correctly configured; otherwise, the node will throw an error indicating missing Redis credentials.
- If the 'Message Field' is empty or missing in the input, messages will be discarded and sent to the 'Discarded' output.
- The node uses a polling loop and Redis keys with expiration to manage timing; ensure Redis server is accessible and properly configured to avoid connection or timeout issues.