ChatBot Enhanced icon

ChatBot Enhanced

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

Overview

The ChatBot Enhanced node provides advanced chatbot functionalities integrated with Redis for stateful operations such as message routing, buffering, session management, rate limiting, and analytics tracking. Specifically, the Route Messages operation under the Message resource directs incoming messages to appropriate channels or queues based on configurable routing rules and patterns.

This node is beneficial in scenarios where chatbots need to intelligently distribute user messages to different support teams, sales departments, or general inquiry queues automatically. For example, a customer support chatbot can route messages containing keywords like "support" to a dedicated support queue, while sales-related queries are sent to the sales team queue.

Practical use cases include:

  • Automatically directing customer inquiries to specialized teams.
  • Load balancing messages across multiple processing queues.
  • Enabling topic-based routing for multi-channel chatbot systems.

Properties

Name Meaning
Session Key Unique identifier for the user or session; can be dynamically set using expressions.
Message Content The actual text content of the message to be routed; supports expressions to extract from input.
Enable Debug Mode Enables detailed logging and debug information during execution.
Redis Key Prefix Prefix used for Redis keys to avoid collisions when storing routing data and metadata.

Output

The node outputs two main streams:

  1. Main Output (Index 0) - Contains success and processed results:

    • success: Includes details about the routed message such as the original message content, session ID, operation type (messageRouting), the channels the message was routed to, and the routing rule that triggered the routing.
    • processed: Provides enriched data including the original message, routing decision summary, routing rule used, processing time, and count of delivered channels.
  2. Status Output (Index 1) - Contains error and metrics information:

    • error: If any error occurs during processing, it is output here with error type, message, code, and timestamp.
    • metrics: Performance and operational metrics such as number of routing decisions made, count of successfully delivered and failed channels, processing time, and Redis health status.

The json structure typically looks like this (simplified):

{
  "type": "success",
  "data": {
    "message": "User's message content",
    "sessionId": "user-session-key",
    "operationType": "messageRouting",
    "routedTo": "support-queue, sales-queue",
    "routingReason": "support-rule"
  },
  "timestamp": 1680000000000
}

If binary data were involved (not in this operation), it would represent attachments or media related to messages, but this operation focuses on JSON message routing metadata only.

Dependencies

  • Redis: The node requires a Redis server connection for managing routing state, caching, and metadata storage.
  • Redis API Credential: A valid API key or authentication token for connecting to Redis must be configured in n8n credentials.
  • Routing Manager: Internally uses a message routing manager that supports topic-based routing with priority and pattern matching.
  • Node Configuration: Requires setting up Redis connection parameters and optionally configuring routing rules and channels within the node or its dependencies.

Troubleshooting

  • Common Issues:

    • Redis Connection Failures: Ensure Redis credentials are correct and the Redis server is reachable.
    • No Messages Routed: Check that routing rules and channel names are correctly configured and that the message content matches routing conditions.
    • Performance Delays: High latency in Redis or large routing rules may slow down message processing.
  • Error Messages:

    • "Redis connection failed": Indicates inability to connect to Redis; verify network and credentials.
    • "Unknown operation type": Occurs if an unsupported operation is selected; ensure "Route Messages" is chosen under "Message" resource.
    • "ITEM_PROCESSING_ERROR": Error processing a specific input item; check the input data format and node parameters.
  • Resolution Tips:

    • Enable debug mode to get detailed logs for troubleshooting.
    • Validate all input expressions and parameters.
    • Test Redis connectivity separately using the credential test feature.
    • Review routing rules syntax and priorities.

Links and References


This summary covers the static analysis of the ChatBot Enhanced node focusing on the Message resource's Route Messages operation, detailing its inputs, outputs, dependencies, and common troubleshooting points.

Discussion