Advanced14 min
Project: Build a Customer Support Agent
End-to-end walkthrough: build a customer support agent with query routing, RAG knowledge base, tool-calling for account actions, human-in-the-loop escalation, and multi-tenant auth.
Quick Reference
- →Architecture: router → specialized handlers (billing, technical, general) with shared RAG knowledge base
- →RAG: product docs in vector store with hybrid search + reranking for accurate answers
- →Actions: account lookup, refund processing, ticket creation — with HITL for destructive operations
- →Escalation: interrupt() when confidence is low or customer requests a human
- →Auth: multi-tenant with org-scoped threads and customer-scoped memory
- →Evaluation: resolution rate, customer satisfaction, escalation rate tracking
Requirements
| Requirement | Solution |
|---|---|
| Route queries to right handler | Router pattern with structured output classification |
| Answer product questions | RAG with hybrid search over product docs |
| Perform account actions | Tools: lookup_account, process_refund, create_ticket |
| Approve destructive actions | interrupt() before refunds > $100 or account changes |
| Remember customer preferences | Store for cross-session memory per customer |
| Multi-tenant isolation | Auth middleware with org_id + customer_id scoping |