ChatBot Enhanced
Actions14
- Rate Limiting Actions
- Session Actions
- Message Actions
- Analytics Actions
Overview
The Buffer Messages operation of the ChatBot Enhanced node collects incoming messages for a user or session and buffers them before sending them out in batches. This buffering can be triggered either by time (waiting a specified number of seconds) or by reaching a maximum buffer size. The node supports different buffering patterns such as collecting all messages and sending them at once, throttling messages in controlled batches, or prioritizing high priority messages first.
Additionally, it includes advanced anti-spam detection features to protect chatbots from unwanted repetitive or flood messages. Spam detection modes include repeated text detection, flood protection, and custom pattern matching. When spam is detected, the node can block the message, delay processing, or mark it as spam while still processing.
This operation is useful in scenarios where you want to simulate more human-like chatbot responses by batching messages, reduce message noise, or prevent abuse through spam filtering. For example:
- Collecting multiple user inputs over 30 seconds and then responding with a combined answer.
- Throttling message bursts during peak usage to avoid overwhelming downstream systems.
- Blocking repeated "help help help" messages automatically to maintain conversation quality.
Properties
| Name | Meaning |
|---|---|
| Session Key | Unique identifier for the user or session. Can use expressions to dynamically assign based on input data (e.g., userId, sessionId). |
| Message Content | The content of the message to process. Supports expressions to extract message text from input JSON fields like message, text, or content. |
| Buffer Time (Seconds) | Time interval to wait before flushing buffered messages. After this period, collected messages are sent out together. Range: 1 to 3600 seconds. |
| Buffer Size | Maximum number of messages to collect before triggering an immediate flush. Range: 1 to 10,000 messages. |
| Buffer Pattern | How buffered messages are handled when flushed: • Collect & Send All: send all collected messages at once. • Throttle: send messages in controlled batches. • Priority Based: send high priority messages first. |
| Anti-Spam Detection | Method to detect spam messages: • Disabled: no spam protection. • Repeated Text Detection: catch very similar repeated messages. • Flood Protection: detect too many messages in short time. • Custom Pattern Match: block messages containing specific words, URLs, phone numbers, or emails. |
| Spam Action | Action to take when spam is detected: • Block Message: completely block spam messages. • Delay Extra Time: add extra waiting time before processing suspicious messages. • Mark as Spam: mark but still process messages. |
| Similarity Threshold (%) | For repeated text detection, how similar messages must be to count as spam. Higher values mean stricter detection. Range: 10% to 100%. |
| Max Messages in Window | For flood protection, maximum allowed messages within the time window before marking as spam. Range: 2 to 50. |
| Flood Time Window (Seconds) | Time window in seconds to count messages for flood detection. Range: 5 to 300 seconds. |
| Enable Debug Mode | Enables detailed logging and debug information during execution. |
| Redis Key Prefix | Prefix used for Redis keys to avoid collisions with other applications or nodes. Default is "chatbot". |
Output
The node outputs two main streams:
Main Output (index 0):
- Emits success and processed results.
- Success output includes details about the buffering status:
- If the message was blocked due to spam, it returns a status indicating blocking and spam detection details.
- If messages were flushed, it returns the batch of messages sent, total count, and flush trigger type.
- If still buffering, it returns pending status with message ID and spam detection info.
- Processed output enriches the original message with buffering metadata such as whether it was buffered, total messages collected, flush type, and spam detection flags.
Status Output (index 1):
- Emits error objects if any occur during processing.
- Emits metrics including counts of buffered messages, spam statistics, processing times, and Redis health status.
The json structure typically contains fields like:
type: e.g., "success", "processed", "metrics", or "error".data: detailed information depending on the type, such as message contents, spam detection results, buffer stats.timestamp: timestamp of the event.- Additional internal fields like
_outputTypeand_originalOutputfor routing within n8n.
The node does not output binary data.
Dependencies
- Requires a Redis server connection configured via credentials to store and manage buffered messages, spam detection state, and related metadata.
- Uses Redis for efficient message buffering, anti-spam checks, and flushing logic.
- No other external services are required.
- Node configuration requires setting up Redis API credentials with appropriate access.
- Optionally, enabling debug mode helps trace internal operations via console logs.
Troubleshooting
Common Issues:
- Redis connection failures: Ensure Redis credentials are correct and the server is reachable.
- Messages never flush: Check that buffer time and buffer size parameters are set correctly; if buffer size is large and messages are infrequent, flushing may only happen after timeout.
- Spam messages blocked unexpectedly: Adjust similarity threshold or flood limits to tune spam detection sensitivity.
- High latency or slow performance: Could be caused by Redis connectivity issues or large buffer sizes.
Error Messages:
"Enhanced message buffering failed: <error message>": Indicates internal failure during buffering or flushing. Check Redis availability and input message validity.- Redis connection errors will appear during credential testing or execution; verify network and credentials.
- Item processing errors include the item index and original input for easier debugging.
Resolution Tips:
- Verify Redis server is running and accessible.
- Use debug mode to get detailed logs.
- Tune anti-spam settings gradually to avoid false positives.
- Monitor Redis health and performance metrics emitted by the node.
Links and References
- Redis Official Documentation
- n8n Documentation - Creating Custom Nodes
- Concepts related to message buffering and rate limiting can be found in general software architecture resources on asynchronous messaging and spam prevention techniques.