A plug-and-try multi-agent customer support pipeline. Bring your own knowledge base (PDFs), connect your Slack, and the system handles triage, resolution, and human escalation automatically — no code changes required.
Built with LangGraph, FastAPI, Qdrant, and Supabase.
Customer Message
│
▼
┌─────────────┐
│ Triage │ Classifies intent / urgency / sentiment
└──────┬──────┘
│
┌────┴────────────────┐
│ │
▼ ▼
Out of scope? Requires human?
│ │
▼ ▼
Deflect Escalation ◄──── Resolver confidence < 0.7
│
├── Log to Supabase
└── Ping Slack
│
▼
Resolver (RAG)
│
confidence ≥ 0.7
│
▼
Final Response
| Agent | Trigger | Output |
|---|---|---|
| Triage | Every message | intent, urgency, sentiment, requires_human |
| Resolver | requires_human=False |
RAG answer + confidence score |
| Escalation | requires_human=True OR confidence < 0.7 |
Handoff summary → Supabase + Slack |
| Deflect | intent=out_of_scope |
Polite off-topic response, no KB lookup |
Agent Pipeline Tracer — watch every routing decision in real time
RAGAS Evaluation Dashboard — per-sample metric breakdown
| Component | Technology |
|---|---|
| LLM | gemini-2.0-flash via langchain-google-genai |
| Embeddings | models/embedding-001 (GoogleGenerativeAIEmbeddings) |
| Structured Output | response_schema JSON mode |
| Agent Orchestration | LangGraph StateGraph |
| Vector Store | Qdrant |
| Conversation Memory | Supabase PostgreSQL |
| Escalation Audit | Supabase |
| Notifications | Slack Web API (Block Kit) |
| API | FastAPI + Uvicorn |
| Evaluation | RAGAS |
No code changes needed to adapt this to your use case:
- Drop your product documentation PDFs into
data/ - Fill in
.envwith your API keys - Set your Slack channel in
SLACK_ESCALATION_CHANNEL - Call
POST /ingestto load your KB - Done — the agents work with whatever content you provide
- Python 3.11+
- Qdrant running locally or on Qdrant Cloud
- Supabase project (free tier works)
- Google AI API key
- Slack bot token (optional)
pip install -r requirements.txtcp .env.example .env
# Fill in your keysRun scripts/supabase_schema.sql in your Supabase SQL Editor.
docker run -p 6333:6333 -p 6334:6334 \
-v $(pwd)/qdrant_storage:/qdrant/storage:z \
qdrant/qdrantpython run.py
curl -X POST http://localhost:8000/ingest \
-F "files=@data/your_docs.pdf"| Page | Purpose |
|---|---|
frontend/trace.html |
Watch the full agent pipeline execute in real time |
frontend/admin.html |
Ingest PDFs, manage the knowledge base |
frontend/eval.html |
Run RAGAS evaluation against a ground truth dataset |
{
"session_id": "user-123",
"message": "Where is my order?"
}Response includes intent, urgency, sentiment, confidence, escalated, and retrieved_chunks.
Upload one or more PDFs to the knowledge base.
curl -X POST http://localhost:8000/ingest \
-F "files=@returns_policy.pdf" \
-F "files=@shipping_guide.pdf"Conversation history for a session.
Questions the resolver failed to answer confidently, ranked by frequency. Use this to identify what content to add to your KB.
Run RAGAS evaluation. Returns faithfulness, context precision, context recall, and answer relevancy per sample.
curl -X POST http://localhost:8000/evaluate \
-H "Content-Type: application/json" \
-d '{"limit": 5}'Qdrant and Supabase connectivity check.
- Triage flags the message as requiring a human (anger, legal threats, fraud, account security)
- Resolver confidence falls below the configured threshold (default
0.7) - Either agent fails — safe fallback always escalates rather than returning a bad answer
When escalation fires, a handoff summary is logged to Supabase and a rich Block Kit card is posted to your Slack channel with full session context and a recommended action.
The system includes a full RAG evaluation pipeline built on RAGAS. It measures whether the retrieval and answer generation are actually working — not just whether the API returns a 200.
For each question in the ground truth dataset, the pipeline:
- Retrieves the top-K chunks from Qdrant
- Generates an answer through the Resolver agent
- Scores the result across 4 metrics using RAGAS
| Metric | What it measures | Method |
|---|---|---|
| Faithfulness | Answer stays within the retrieved context — no hallucination | Token overlap between answer and retrieved chunks |
| Context Precision | Retrieved chunks are ranked correctly — most relevant first | Ranked chunk relevance vs ground truth |
| Context Recall | Retrieved chunks cover the ground truth answer | Sentence coverage of ground truth in retrieved chunks |
| Answer Relevancy | Answer directly addresses the question asked | LLM generates candidate questions from the answer, cosine similarity to original |
Step 1 — Generate the ground truth dataset
The repo ships with a 50-question dataset generator. Run it once after ingesting your KB:
python scripts/generate_eval_dataset.pyThis creates data/eval_dataset.json — 50 questions with ground truth answers spanning shipping, returns, payments, edge cases, and out-of-KB questions (to verify escalation fires correctly).
Step 2 — Run evaluation via API
# Full run (all 50 samples — slow, makes ~200 LLM calls)
curl -X POST http://localhost:8000/evaluate \
-H "Content-Type: application/json" \
-d '{}'
# Quick run (5 samples — good for a first check)
curl -X POST http://localhost:8000/evaluate \
-H "Content-Type: application/json" \
-d '{"limit": 5}'Step 3 — Or use the visual dashboard
Open frontend/eval.html in your browser. Set a sample limit and click Run Evaluation to see per-sample scores, a confidence bar per metric, and expandable answer/ground-truth comparisons.
To evaluate against your own KB, edit scripts/generate_eval_dataset.py — replace the EVAL_DATASET list with your own question/ground_truth pairs and re-run the script.
├── app/
│ ├── agents/
│ │ ├── triage.py # Intent / urgency / sentiment classification
│ │ ├── resolver.py # RAG retrieval + answer generation
│ │ └── escalation.py # Handoff summary + Supabase + Slack
│ ├── graph/
│ │ ├── state.py # LangGraph SupportState TypedDict
│ │ └── graph.py # StateGraph: routing, deflect, finalize nodes
│ ├── rag/
│ │ ├── ingestion.py # PDF → chunk → embed → Qdrant
│ │ ├── qdrant_store.py # Qdrant client + retrieval
│ │ └── evaluator.py # RAGAS evaluation pipeline
│ ├── db/
│ │ └── supabase_client.py # Conversation memory + escalation log + KB gaps
│ ├── services/
│ │ └── slack.py # Slack Block Kit notifications
│ ├── utils/
│ │ └── rate_limiter.py # API rate limiting
│ ├── config.py # Pydantic Settings (all config from .env)
│ └── main.py # FastAPI app + all endpoints
├── frontend/
│ ├── trace.html # Live agent pipeline tracer
│ ├── admin.html # KB ingestion dashboard
│ └── eval.html # RAGAS evaluation dashboard
├── scripts/
│ ├── generate_faq_pdf.py # Sample FAQ PDF generator
│ ├── generate_kb_pdfs.py # Extended KB generator
│ ├── generate_eval_dataset.py
│ └── supabase_schema.sql # Table definitions + RLS policies
├── tests/ # Pytest suite (6 test files)
├── run.py
├── requirements.txt
└── .env.example
| Variable | Required | Description |
|---|---|---|
GOOGLE_API_KEY |
✅ | Google AI API key |
SUPABASE_URL |
✅ | Supabase project URL |
SUPABASE_SERVICE_KEY |
✅ | Supabase service role key |
QDRANT_URL |
✅ | Qdrant URL (default: http://localhost:6333) |
QDRANT_API_KEY |
— | Qdrant Cloud API key (leave empty for local) |
SLACK_BOT_TOKEN |
— | Slack bot token — notifications disabled if unset |
SLACK_ESCALATION_CHANNEL |
— | e.g. #support-escalations |
RESOLVER_CONFIDENCE_THRESHOLD |
— | Escalation threshold (default: 0.7) |
RETRIEVAL_TOP_K |
— | Max chunks retrieved (default: 5) |
MAX_HISTORY_TURNS |
— | Conversation turns from Supabase (default: 10) |

