Chat Buffer icon

Chat Buffer

Acumula mensajes y los envía concatenados después de un timeout de inactividad

Overview

This node acts as a temporary chat message buffer that accumulates incoming messages for a given session and outputs them concatenated after a specified period of inactivity. It is useful in scenarios where multiple short messages need to be combined into a single, coherent message before further processing or sending. For example, it can be used to gather fragmented user inputs in a chatbot conversation and send them as one complete message once the user pauses typing.

Properties

Name Meaning
Session ID Unique identifier for the chat session. Messages with the same Session ID are buffered together.
Message The text content of the message to add to the buffer.
Timeout (Ms) Time in milliseconds to wait after the last received message before processing the buffer.
Separator String used to join the buffered messages when concatenating (default is ". ").

Output

The node outputs an array with one item per processed session buffer. Each output item contains a json object with the following fields:

  • jid: The session ID corresponding to the buffered messages.
  • textMessageContent: The concatenated string of all buffered messages joined by the separator.
  • messageCount: Number of messages that were concatenated.
  • processedAt: ISO timestamp indicating when the buffer was processed.

No binary data is produced by this node.

Dependencies

  • No external services or API keys are required.
  • The node relies on internal state management to accumulate messages per session.
  • No special environment variables or n8n configurations are needed.

Troubleshooting

  • Issue: Messages never get output.

    • Cause: If new messages keep arriving within the timeout window, the buffer will not process.
    • Solution: Increase the timeout or ensure there is a pause in incoming messages.
  • Issue: Output contains fewer messages than expected.

    • Cause: Messages might have different session IDs, causing separate buffers.
    • Solution: Verify that the Session ID property correctly identifies related messages.
  • Error: Node throws exceptions during execution.

    • Cause: Possibly due to missing required parameters or invalid input types.
    • Solution: Ensure all required properties (Session ID, Message, Timeout) are provided and valid.

Links and References

Discussion