ChatBot Enhanced icon

ChatBot Enhanced

Enhanced chatbot node with Redis/Valkey integration for rate limiting, session management, and advanced features

Overview

The node "ChatBot Enhanced" provides advanced chatbot functionalities with integration to Redis for stateful operations. Specifically, the Rate Limiting - Reset User Limits operation allows clearing or resetting the rate limiting counters for a specific user or session. This is useful in scenarios where you want to manually reset a user's request quota, for example:

  • After an admin intervention to lift restrictions on a user.
  • When implementing custom logic to refresh user limits based on external events.
  • To recover from accidental rate limit blocks without waiting for automatic expiry.

This operation helps maintain smooth user experience by controlling how many requests a user can make per minute and enabling manual resets of those limits.

Properties

Name Meaning
Session Key Unique identifier for the user or session; used to track rate limits per user/session.
Message Content The message content to process; can be used for logging or context but not directly for reset.
Rate Limit (Requests per Minute) Maximum number of allowed requests per minute; defines the rate limit threshold.
Enable Debug Mode Enables detailed logging and debug information during execution.
Redis Key Prefix Prefix string for Redis keys to avoid collisions with other data stored in Redis.

Output

The node outputs two main streams:

  1. Main output: Contains success or processed results with details such as:

    • message: The original message content.
    • sessionId: The session key identifying the user.
    • operationType: Indicates this is a rate limiting operation.
    • allowed: Boolean indicating if the user is currently allowed to proceed (for check operations).
    • rateLimitData: Object containing current request count, remaining requests, reset time, and retry-after duration.
    • For reset operation specifically, it returns confirmation that limits were reset.
  2. Status output: Contains error messages or metrics related to the operation, including:

    • Error type and message if something failed.
    • Metrics about processing time and Redis health status.

The output JSON structure includes timestamps and metadata to help track processing performance and operational status.

Dependencies

  • Requires a connection to a Redis server for storing and managing rate limit counters.
  • Needs an API key credential configured in n8n to authenticate and connect to Redis.
  • The node uses a sliding window algorithm with burst protection and penalty times implemented via Redis.
  • Proper Redis configuration and network access are necessary for reliable operation.

Troubleshooting

  • Redis Connection Failures: If the node cannot connect to Redis, it will throw connection errors. Ensure Redis credentials are correct and the server is reachable.
  • Rate Limit Not Resetting: If limits do not reset as expected, verify the Session Key matches the one used when limits were applied.
  • Exceeding Rate Limits Despite Reset: There may be a delay due to Redis replication or caching; wait a few seconds and try again.
  • Debug Mode: Enable debug mode to get detailed logs which can help identify issues with key prefixes or parameter values.
  • Error Messages:
    • "Redis connection failed": Check Redis server status and credentials.
    • "Unknown operation type": Ensure the operation selected is valid and supported.
    • "ITEM_PROCESSING_ERROR": Indicates failure processing a specific input item; check input data validity.

Links and References


This summary focuses on the Rate Limiting > Reset User Limits operation of the ChatBot Enhanced node, describing its purpose, inputs, outputs, dependencies, and common troubleshooting tips.

Discussion