Document-grounded AI support with confidence scoring and automatic human escalation
The Problem
A previous ChatGPT integration hallucinated a free returns policy that didn't exist — the store honored $200 in fraudulent refunds before discovering it. The root problem: generic AI with no access to actual store documents. 80–100 support emails daily, 70% asking questions already answered in existing policy docs.
The Solution
Two separate workflows. An ingestion workflow (run once) loads policy PDFs through n8n's Document Loader, splits them via Recursive Character Text Splitter (500-char chunks, 50-char overlap), vectorizes via OpenAI Embeddings, and upserts into Supabase PGVector. The support workflow triggers on IMAP email, runs an AI Agent grounded exclusively in retrieved document chunks via a Vector Store Retriever tool, maintains per-customer conversation context via Window Buffer Memory (keyed by sender email), and enforces a Structured Output Parser schema requiring answer, confidence score, escalation flag, and source document citation. Any response with confidence below 0.6 or escalate=true routes to Slack with full context for human review.
Key Engineering
Result
→ Zero hallucinated answers — agent cites the exact document section for every response. Escalation threshold catches genuinely ambiguous cases before they reach customers. 70% of repetitive support volume handled without human involvement.
Tech Stack
n8n AI Agent, LangChain Nodes, Document Loader, Text Splitter, OpenAI Embeddings, Supabase pgvector, Window Buffer Memory, Structured Output Parser, IMAP Trigger, Slack



