ChatBot Enhanced icon

ChatBot Enhanced

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

Overview

The Update Session operation of the ChatBot Enhanced node manages user or session data by updating an existing session with new message content and extending its timeout. It interacts with a Redis-backed session manager to maintain session state, including conversation context, activity timestamps, and message counts.

This operation is useful in chatbot workflows where maintaining conversational context over time is critical. For example, it can be used to track ongoing user interactions, store session-specific data, and keep sessions alive as users continue messaging. This helps create more personalized and coherent chatbot experiences by preserving state between messages.

Practical examples:

  • Updating a user's chat session with their latest message to maintain context.
  • Extending session expiration time when the user sends a new message.
  • Retrieving updated session metadata such as last activity time and message count for analytics or decision-making.

Properties

Name Meaning
Session Key Unique identifier for the user or session. Can use expressions to dynamically set this value (e.g., userId or sessionId).
Message Content The message text to add to the session. Supports expressions to extract from input data.
Session Timeout (Minutes) Duration in minutes to keep the session active without new activity before expiring. Defaults to 30 minutes.
Enable Debug Mode Enables detailed logging and debug information during execution. Useful for troubleshooting.
Redis Key Prefix Prefix string for Redis keys to avoid collisions with other data stored in Redis. Defaults to "chatbot".

Output

The output JSON contains multiple fields grouped under different output types:

  • success: Contains updated session details after the message is added.

    • message: The input message content.
    • sessionId: The session key used.
    • operationType: Always "sessionManagement" for this operation.
    • sessionData: 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: Current session context object storing conversation state.
  • processed: Provides enrichment data derived from the session update.

    • originalMessage: The original input message.
    • enrichmentData: Includes:
      • sessionContext: The current session context.
      • userHistory: Array of past conversation messages (if available).
      • sessionAge: Duration since session creation in milliseconds.
  • metrics: Performance and usage metrics related to the session update.

    • operationType: "sessionManagement".
    • metrics: Includes:
      • activeSession: Always 1 indicating an active session.
      • messageCount: Total messages in the session.
      • sessionAge: Age of the session in milliseconds.
    • performance: Includes processing time and Redis health status.

The node outputs two streams:

  • Main output: success and processed results.
  • Status output: error and metrics information.

No binary data is produced by this operation.

Dependencies

  • Requires a Redis server connection configured via an API key credential.
  • Uses Redis for session storage and management.
  • The node expects proper Redis credentials configured in n8n.
  • No additional external services are required beyond Redis.

Troubleshooting

  • Common issues:

    • Redis connection failures due to incorrect credentials or network issues.
    • Session not found if the session key is incorrect or expired.
    • Exceeding Redis memory limits if too many sessions or large contexts are stored.
  • Error messages:

    • "Redis connection failed: <error message>" indicates connectivity or authentication problems with Redis.
    • "Unknown operation type: ..." if the operation parameter is misconfigured.
    • Item processing errors include the original input and are retryable unless the node is configured otherwise.
  • Resolutions:

    • Verify Redis credentials and network accessibility.
    • Ensure session keys are correctly generated and consistent.
    • Monitor Redis memory usage and configure appropriate TTLs and cleanup intervals.

Links and References


This summary focuses exclusively on the Update Session operation within the Session resource of the ChatBot Enhanced node, based on static analysis of the provided source code and property definitions.

Discussion