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 - Get Limit Status operation retrieves detailed statistics about a user's rate limit usage. This helps control how many requests a user or session can make within a given time frame, protecting backend services from overload and abuse.

Typical use cases include:

  • Preventing users from sending too many messages in a short period.
  • Monitoring API usage quotas per user/session.
  • Implementing burst protection and penalties for excessive requests.
  • Providing feedback to users on their remaining quota and when limits reset.

For example, a chatbot could check if a user has exceeded 10 requests per minute before processing further input, or display a warning message with the number of remaining allowed requests.

Properties

Name Meaning
Session Key Unique identifier for the user or session; can be set dynamically using expressions.
Message Content The content of the message to process; supports expressions to extract from incoming data.
Rate Limit (Requests per Minute) Maximum allowed requests per minute for the user/session; integer between 1 and 1000.
Enable Debug Mode Boolean flag to enable detailed logging and debug output during execution.
Redis Key Prefix String prefix used for Redis keys to avoid collisions with other applications or nodes.

Output

The node outputs two main streams:

  1. Main Output (index 0) — Success and processed results:

    • type: Always "success" for successful calls.
    • data object includes:
      • message: The original message content.
      • sessionId: The session key used.
      • operationType: "smartRateLimit" indicating this operation.
      • allowed: Boolean indicating if the request is allowed under the rate limit.
      • rateLimitData: Detailed stats including:
        • requestCount: Total requests made in the current window.
        • remainingRequests: How many requests remain before hitting the limit.
        • resetTime: Timestamp when the rate limit window resets.
        • retryAfter: Time in seconds to wait before retrying if limit exceeded.
    • timestamp: Execution timestamp.
    • Additional fields like processingTime (ms) and itemIndex are included for diagnostics.
  2. Status Output (index 1) — Metrics and health info:

    • type: "metrics"
    • data contains:
      • operationType: "smartRateLimit"
      • metrics: Includes request counts, remaining quota, and window utilization percentage.
      • performance: Processing time and Redis connection health status.
    • timestamp: Execution timestamp.

No binary data is produced by this operation.

Dependencies

  • Requires a Redis server accessible via credentials configured in n8n.
  • The node uses Redis to store and track rate limiting counters with a sliding window algorithm.
  • The Redis connection must be healthy and responsive for accurate rate limiting.
  • No other external APIs are required for this operation.

Troubleshooting

  • Common issues:

    • Redis connection failures due to incorrect credentials, network issues, or Redis downtime.
    • Exceeding Redis command timeouts or max retries causing errors.
    • Misconfiguration of rate limit values leading to unexpected blocking or allowing of requests.
  • Error messages:

    • "Redis connection failed: <error message>" indicates inability to connect or authenticate with Redis. Verify credentials and network access.
    • "Redis read/write test failed" means Redis is reachable but commands fail; check permissions and Redis health.
    • "Unknown operation type: ..." would indicate an internal misconfiguration; ensure correct resource and operation selection.
    • Item processing errors will include the item index and error details; enabling debug mode can provide more logs.
  • Resolutions:

    • Confirm Redis credentials and connectivity.
    • Ensure Redis server is running and accessible.
    • Adjust rate limit parameters to reasonable values.
    • Use debug mode to get detailed logs for troubleshooting.

Links and References


This summary focuses on the Rate Limiting > Get Limit Status operation of the ChatBot Enhanced node as requested.

Discussion