See llms.txt for all machine-readable content.

Back to Templates

Build a permission-aware knowledge base chat agent with OpenAI and Redis

Quick overview

This workflow loads a document knowledge base into a Redis vector index with metadata, then runs an OpenAI-powered chat agent that answers questions by retrieving only documents the user is permitted to read using Redis metadata filters.

How it works

  1. Runs manually to generate a sample set of knowledge base documents with access, type, title, and publication-date metadata.
  2. Creates embeddings with OpenAI and stores the documents in a Redis Vector Store index with a typed metadata schema for filtering.
  3. Triggers when a chat message is received through the public n8n Chat interface.
  4. Resolves the requester’s allowed groups (for example, everyone and engineering) and attaches them to the chat session.
  5. Uses an OpenAI chat agent with Redis chat memory to answer the question by calling a Redis Vector Store search tool.
  6. Searches Redis with a mandatory access filter plus optional agent-supplied filters (document type, title keywords, and published-after date) and returns only matching passages for the agent to cite in its response.

Setup

  1. Add Redis credentials and ensure you have Redis 8.x (or Redis with the Redis Query Engine module) available for vector search.
  2. Add OpenAI credentials for both the embeddings model and the chat model, and optionally adjust the chat model selection.
  3. Run the manual “load documents” path once to populate the Redis index (or replace the sample documents with your own source content).
  4. Update the Redis index name, key prefix, and metadata schema consistently in both the insert and search steps if you change them.
  5. Copy the Chat trigger URL from n8n and send messages there, and replace the hardcoded group list with your own user/group lookup logic for production.