Redis Chat Memory (Isolated) icon

Redis Chat Memory (Isolated)

Stores chat history in Redis with user isolation for queue mode

Redis Chat Memory (Isolated)

AI-generated

Summary

Stores chat history in Redis with user isolation for queue mode, using n8n's AI Node SDK. It creates isolated sessions per workflow ID and session ID by prefixing the session key with a SHA-256 hash of the workflow ID, separated by a colon from the provided session ID.

Inputs

  • useQueueRedis (required) — Whether to use the queue mode Redis configuration via QUEUE_BULL_REDIS_* environment variables (if enabled, overrides any credentials provided). When enabled, chat memory is stored in the database (QUEUE_BULL_REDIS_DB + 1) to avoid conflicts with queue data.
  • sessionId (required) — Session identifier for the conversation. If not provided, the operation throws an error.
  • contextWindowLength — Number of previous messages to keep in memory. Defaults to 10.
  • sessionTTL — How long the session should be stored in seconds. Defaults to 86400 (24 hours).

Output shape

an AI Memory object (n8n AI Node SDK WindowedChatMemory)

Returns an AI Memory object from n8n's AI Node SDK that keeps a windowed context of chat history stored in Redis. The session key is prefixed with a SHA-256 hash of the workflow ID and joined with the provided sessionId to ensure user isolation between workflows and sessions.

Examples

Example 1: Use queue mode Redis configuration to store chat history in a separate database from the job queue.

Enable 'Use Queue Mode Redis', set 'Session ID' to 'user_session_123', and accept defaults for 'Context Window Length' and 'Session Time To Live'.

Example 2: Connect to a specific Redis instance with custom credentials.

Disable 'Use Queue Mode Redis' and configure 'Session ID' to 'chat_history'. Set 'Session Time To Live' to 3600 for 1-hour expiration.

Links

Discussion