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 capabilities with integrated Redis support for session management, rate limiting, message buffering, analytics, and more. Specifically, the Session - Get Session Data operation retrieves the current state and conversation history of a user session stored in Redis. This is useful for chatbots that need to maintain context over multiple interactions, enabling personalized and continuous conversations.

Typical use cases include:

  • Retrieving user session data to understand past interactions.
  • Accessing conversation context to provide relevant responses.
  • Monitoring session activity and message counts for analytics or debugging.

For example, a customer support chatbot can fetch the user's session data to recall previous issues discussed, improving response quality and user experience.

Properties

Name Meaning
Session Key Unique identifier for the user or session. Can be set dynamically using expressions.
Message Content The message content to process, typically the latest user input. Supports expressions.
Session Timeout (Minutes) Duration in minutes to keep sessions active without activity before expiring.
Enable Debug Mode Enables detailed logging and debug information during execution.
Redis Key Prefix Prefix string used for Redis keys to avoid collisions with other data in Redis.

Output

The output JSON structure for the Get Session Data operation includes:

  • message: The original message content processed.
  • sessionId: The session key identifying the user/session.
  • operationType: Fixed value "sessionManagement" indicating the operation performed.
  • sessionData: An object containing:
    • startTime: Timestamp when the session was created.
    • lastActivity: Timestamp of the last activity in the session.
    • messageCount: Number of messages recorded in the session.
    • context: The stored session context data (conversation state).

Additional outputs include:

  • A processed output with enrichment data such as:

    • originalMessage: The input message.
    • enrichmentData: Includes session context, user history (conversation history), and session age in milliseconds.
  • A metrics output providing operational metrics like:

    • Active session count (always 1 here).
    • Message count.
    • Session age.
    • Performance info including processing time and Redis health status.

If debug mode is enabled, detailed logs about session retrieval and updates are printed.

Dependencies

  • Requires a Redis server connection configured via an API key credential.
  • The node uses a RedisManager class to connect and interact with Redis.
  • Session data is managed through a SessionManager class that handles TTL, context storage, and cleanup.
  • No additional external services are required beyond Redis.

Troubleshooting

  • Redis Connection Issues: If the node cannot connect to Redis, ensure the Redis credentials are correct and the server is reachable. The node tests read/write access on connection.
  • Session Not Found: If no session exists for the given session key, the node will create a new session automatically.
  • Timeouts: Long session timeout values may cause stale data; adjust the "Session Timeout" property appropriately.
  • Debug Mode: Enable debug mode to get detailed console logs which help diagnose issues with session retrieval or updates.
  • Error Handling: Errors during item processing are captured and returned in the error output. Use "Continue On Fail" option to handle errors gracefully.

Links and References

Discussion