Run a RAG support copilot with Claude Sonnet and OpenAI embeddings

Go to Workflow
1 views
Built by Swapnil Mandloi Swapnil Mandloi
Created on July 28, 2026

Description

Quick overview
This template ingests internal docs into an in-memory vector knowledge base using OpenAI embeddings, then runs a public support chat powered by Anthropic Claude that answers only from that knowledge and escalates unanswered requests to a Gmail inbox while logging all Q&A to an n8n Data Table.

How it works
Receives knowledge-base entries from an n8n Form trigger with a source title and free-text content.
Splits the submitted content into chunks, generates OpenAI embeddings, and stores the vectors in an in-memory vector store keyed as company_kb.
Exposes a public chat endpoint where customers submit support questions.
Uses an Anthropic Claude agent with short-term conversation memory to first search the company_kb vector store and respond only using retrieved passages.
If the knowledge base does not contain the answer or the user requests a human, the agent sends an escalation email via Gmail with the question and context.
Logs each question, the agent’s answer, the session ID, and a timestamp to an n8n Data Table.

Setup
Add credentials for OpenAI (Embeddings) and Anthropic (Claude) and select the correct model in the Claude node.
Connect a Gmail OAuth2 credential and set the destination support email address in the escalation email tool.
Create or select an n8n Data Table named support_chat_log (or update the workflow to use your table).
Publish the Form and Chat triggers and share their URLs as needed (use the form internally for ingestion and the chat URL for customers).

Requirements
n8n instance with the Data Table feature enabled
Anthropic API key (Claude) — the agent's reasoning
OpenAI API key — embeddings for the vector store
Gmail account connected via OAuth2 — human escalation

Customization
Swap the in-memory vector store for Pinecone / Qdrant / Supabase to persist the knowledge base across restarts (production-grade)
Replace the paste-text form with a file-upload field to ingest PDFs and DOCX
Add more agent tools: create a ticket in your helpdesk, look up an order, book a call
Change the escalation channel to Slack, WhatsApp, or a helpdesk instead of email
Embed the hosted chat on your website, or expose it as a webhook for your own UI

Additional info
Grounded, not generative-guessing: the agent answers only from your documents and escalates instead of hallucinating — the #1 trust issue buyers have with AI support.
Both flows share the company_kb key, so ingestion and answering stay in sync.
Universal fit: SaaS, e-commerce, clinics, agencies, education, real estate anyone with an FAQ and an inbox.

Categories

AI Langchain

Nodes Used (7)

AI Agent
@n8n/n8n-nodes-langchain.agent
Anthropic Chat Model
@n8n/n8n-nodes-langchain.lmChatAnthropic
Default Data Loader
@n8n/n8n-nodes-langchain.documentDefaultDataLoader
Embeddings OpenAI
@n8n/n8n-nodes-langchain.embeddingsOpenAi
Recursive Character Text Splitter
@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter
Simple Memory
@n8n/n8n-nodes-langchain.memoryBufferWindow
Simple Vector Store
@n8n/n8n-nodes-langchain.vectorStoreInMemory