Skip to content

Enterprise-grade multi-agent AI customer support system. Built for production, saves companies £150K+ annually. Complete tutorials included.

License

Notifications You must be signed in to change notification settings

ntg2208/production-ai-customer-support

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Production AI Customer Support System

GitHub stars GitHub sponsors Buy Me A Coffee Ko-fi

The customer support system that enterprises pay £100K+ for - now open source with complete tutorials

🎥 Watch the Complete Tutorial Series →

✨ What Makes This Special

  • 🤖 Multi-Agent Architecture - Intelligent routing between specialized agents
  • 🧠 RAG + Database Hybrid - Best of both worlds for knowledge management
  • 🌍 Location Intelligence - Smart defaults based on customer location
  • 🛡️ Safety Guardrails - PII protection, prompt injection defense, content filtering
  • 📊 LLM-as-a-Judge Evaluation - Automated quality assessment with detailed reports
  • 🏢 Production Ready - 15 test scenarios, deployment docs, error handling
  • 💰 Proven ROI - Companies save £150K+ annually vs traditional support teams

🚀 Live Demo

UKConnect AI Customer Support Demo

Try it yourself (30 seconds):

git clone https://github.com/ntg2208/production-ai-customer-support
cd production-ai-customer-support
pip install -r requirements.txt
cp .env.example .env  # Add your GOOGLE_API_KEY
python interactive_test.py

🎓 Learn by Building

This isn't just code - it's a complete learning experience:

🎬 Tutorial Series: Building Enterprise AI Customer Support

  1. Introduction & Architecture (15 min)
  2. Database & RAG Setup (25 min)
  3. Policy Agent Build (20 min)
  4. Ticket Agent Build (25 min)
  5. Master Agent Design (20 min)
  6. Location Intelligence (15 min)
  7. Testing & Deployment (25 min)
  8. Business Applications (20 min)

🏢 Business Impact

Real companies using this approach report:

  • 📉 60% reduction in customer support costs
  • 24/7 availability without human agents
  • 📈 Consistent service quality across all interactions
  • 🌐 Multi-language support ready out of the box

💡 Key Features

Multi-Agent Orchestration

  • Master Agent: Primary orchestrator that analyzes customer queries, maintains context, and intelligently routes requests to specialist agents
  • Policy Agent: RAG-powered specialist for company policies, refund rules, terms & conditions, and fare regulations
  • Ticket Agent: Operational specialist for ticket searches, bookings, modifications, and transaction processing

🧠 Intelligent Routing: The Master Agent acts as the central intelligence hub, determining which specialist agent can best handle each customer request while preserving conversation context across all interactions.

Production Features

  • Location Intelligence: Auto-detects customer departure stations
  • State Management: Maintains context across conversations
  • Error Handling: Comprehensive exception management
  • Testing Suite: 15 realistic customer scenarios
  • Deployment Ready: Docker, cloud deployment guides

🛡️ Safety Guardrails

Built-in protection using Google ADK callbacks to ensure safe and compliant agent behavior:

  • PII Detection & Redaction: Automatically detects and sanitizes sensitive data (emails, phone numbers, credit cards, addresses)
  • Prompt Injection Defense: Blocks jailbreak attempts, instruction overrides, and system prompt extraction
  • Content Moderation: Filters toxic, threatening, and inappropriate content
  • Tool Validation: Validates tool arguments and blocks unauthorized operations
  • Audit Logging: Complete audit trail for compliance and debugging
from guardrails import create_safety_callbacks, GuardrailConfig

callbacks = create_safety_callbacks(GuardrailConfig(
    enable_pii_detection=True,
    enable_injection_detection=True,
    block_on_high_risk=True,
))

agent = Agent(
    model="gemini-2.0-flash",
    before_model_callback=callbacks["before_model"],
    after_model_callback=callbacks["after_model"],
)

📊 LLM-as-a-Judge Evaluation

Automated quality assessment system that evaluates agent responses across 6 dimensions:

Criterion Weight Description
Accuracy 25% Factual correctness, no hallucinations
Helpfulness 20% Addresses customer's actual need
Task Completion 20% Successfully performs requested action
Tone 15% Professional, appropriate communication
Routing 10% Correct agent handles the query
Policy Adherence 10% Follows company policies
# Run evaluation on test scenarios
python -m evaluation.run_evaluation --quick          # Quick eval (3 sessions)
python -m evaluation.run_evaluation --session 1      # Single session
python -m evaluation.run_evaluation --all            # Full test suite

Sample Output:

Session: Test Booking Flow
Overall Score: 4.58/5.0 - PASS
Turns: 3/3 passed
Scores: accuracy=5.0, helpfulness=4.67, task_completion=4.0

Enterprise Capabilities

  • Scalable Architecture: Handle 1000+ concurrent users
  • Database Integration: SQLite, PostgreSQL, MySQL support
  • API Ready: RESTful endpoints for integration
  • Monitoring: Built-in logging and metrics

🛠️ Technology Stack

  • LLM Framework: Google AI Platform / Google Cloud Vertex AI
  • Multi-Agent: Google ADK Agents Framework
  • Safety: ADK Callbacks (before/after model & tool)
  • Evaluation: LLM-as-a-Judge with Gemini
  • Vector Database: Embeddings with similarity search
  • Database: SQLite (development) / PostgreSQL (production)
  • Backend: Python 3.8+, FastAPI
  • Deployment: Docker, Google Cloud, AWS

📊 Architecture Overview

┌─────────────────────────────────────────────────────────────────┐
│                     Customer Interface                          │
│        • Natural Language Processing                            │
│        • Context Awareness • Location Intelligence              │
└─────────────────────────────────┬───────────────────────────────┘
                                  ▼
┌─────────────────────────────────────────────────────────────────┐
│                    🛡️ Safety Guardrails                         │
│  • PII Detection  • Prompt Injection Defense  • Content Filter  │
│  • before_model_callback        • after_model_callback          │
└─────────────────────────────────┬───────────────────────────────┘
                                  ▼
                    ┌─────────────────────────┐
                    │     Master Agent        │ ◄── Main Orchestrator
                    │   (Coordinator)         │
                    │                         │
                    │ • Query Analysis        │
                    │ • Intelligent Routing   │
                    │ • Context Preservation  │
                    │ • Response Coordination │
                    └─────────────┬───────────┘
                                  ▼
                    ┌─────────────┼─────────────┐
                    ▼                           ▼
          ┌──────────────────┐          ┌─────────────────┐
          │   Policy Agent   │          │  Ticket Agent   │
          │   (Specialist)   │          │  (Specialist)   │
          │                  │          │                 │
          │ • Company Policy │          │ • Ticket Search │
          │ • Refund Rules   │          │ • Booking Mgmt  │
          │ • T&C, Fares     │          │ • Customer Data │
          │ • RAG Knowledge  │          │ • Transactions  │
          └──────────────────┘          └─────────────────┘
                                  │
                                  ▼
                    ┌─────────────────────────┐
                    │  📊 LLM-as-a-Judge      │ ◄── Quality Assurance
                    │     Evaluation          │
                    │                         │
                    │ • Response Scoring      │
                    │ • Multi-turn Analysis   │
                    │ • Regression Detection  │
                    └─────────────────────────┘

🎯 Orchestration Flow:

  1. Customer Query → Master Agent analyzes intent and context
  2. Intelligent Routing → Routes to appropriate specialist agent
  3. Specialist Processing → Policy or Ticket agent handles specific task
  4. Response Coordination → Master agent ensures seamless customer experience

🤖 Orchestration Examples

Simple Policy Query:

Customer: "What's your refund policy?"
Master Agent: [Analyzes: policy question] → Routes to Policy Agent
Policy Agent: [RAG search] → Returns policy details
Master Agent: [Coordinates response] → Customer receives seamless answer

Complex Booking Operation:

Customer: "Cancel my booking UKC005 and tell me the refund amount"
Master Agent: [Analyzes: booking + policy] → Sequential routing
  ↓ Step 1: Ticket Agent → Cancels booking, calculates base refund
  ↓ Step 2: Policy Agent → Applies refund rules and fees
Master Agent: [Synthesizes] → "Booking cancelled, £67.50 refunded"

Mixed Query Handling:

Customer: "I need to change my London-Manchester ticket, what are my options?"
Master Agent: [Analyzes: operational + policy] → Parallel consultation
  ↓ Ticket Agent: Available alternative trains and pricing
  ↓ Policy Agent: Change fees and conditions
Master Agent: [Combines responses] → Comprehensive options presented

🎯 Use Cases

Perfect for these industries:

  • 🚄 Transportation (rail, bus, airline booking)
  • 🏨 Hospitality (hotel, restaurant reservations)
  • 🏥 Healthcare (appointment scheduling, patient queries)
  • 🛒 E-commerce (order management, product support)
  • 🏠 Property (tenant services, maintenance requests)

🚀 Getting Started

Prerequisites

  • Python 3.8+
  • Google AI API key (free tier available)
  • 10 minutes setup time

Installation

  1. Clone the repository
git clone https://github.com/ntg2208/production-ai-customer-support
cd production-ai-customer-support
  1. Install dependencies
pip install -r requirements.txt
  1. Set up environment
cp .env.example .env
# Edit .env and add your GOOGLE_API_KEY
  1. Initialize database
python -c "from utils.create_schema import create_database_schema; create_database_schema()"
python -c "from utils.populate_data import populate_data; populate_data()"

Your First Demo

# Quick demo with 3 scenarios
python run_test_scenarios.py

# Try specific interactions
python run_test_scenarios.py --session 1    # New customer
python run_test_scenarios.py --session 11   # Casual style
python run_test_scenarios.py --session 15   # Complex booking

# Interactive demo
python interactive_test.py

🔧 Development Utilities

Time Configuration

Control the system time for testing scenarios with specific dates:

from config.time_config import set_system_time, use_real_time, is_using_fixed_time

# Set a fixed date/time for testing (affects all database queries)
set_system_time("2025-07-29 14:30:00")

# Check if using fixed time
print(is_using_fixed_time())  # True

# Switch back to real current time
use_real_time()

Or edit config/time_config.py directly:

# Set to a specific date for reproducible testing
SYSTEM_CURRENT_TIME = "2025-07-29 14:30:00"

# Or use None for real current time
SYSTEM_CURRENT_TIME = None

Database Reset

Reset the database to a clean state with fresh sample data:

# Reset database to clean state
python test_message_scenarios.py --reset-db

# Or programmatically:
python -c "from utils.create_schema import create_database_schema; create_database_schema()"
python -c "from utils.populate_data import populate_data; populate_data()"

📊 Live Demo Results

Here's what you'll see when you run the demo:

Session 1 - New Customer Journey:

User: Hi, I'm new to UKConnect. Can you help me book a train ticket?
Agent: Welcome! I'd be happy to help you book your first ticket. Where would you like to travel from and to?

User: I need to go from London to Manchester tomorrow morning
Agent: Perfect! I can see several morning options from London Euston to Manchester Piccadilly...
[Shows available tickets with prices and times]

Session 11 - Casual Style:

User: yo need train london to bham tmrw
Agent: Hey! Got it - London to Birmingham tomorrow. Let me check the available trains for you...
[Adapts to casual communication style while maintaining professionalism]

📚 Documentation

💰 Support This Project

If this helps you or your company:

🏢 Enterprise Support

Need this customized for your business?

Get Enterprise Implementation →

  • Custom domain adaptation
  • Integration with existing systems
  • Production deployment support
  • Training and ongoing maintenance

🤝 Contributing

Contributions welcome! See CONTRIBUTING.md

Areas we need help:

  • 🌐 Translations - Multi-language support
  • 🏭 Industry Adaptations - Healthcare, e-commerce examples
  • 📚 Documentation - Tutorials, guides, examples
  • 🐛 Bug Fixes - Issue resolution
  • New Features - Enhanced capabilities

📄 License

MIT License - see LICENSE file

👨‍💻 About the Creator

Built by Truong Giang Nguyen - ML Engineer specializing in production AI systems that solve real business problems.

Background:

  • 4+ years building enterprise AI solutions
  • MSc Data Science (Distinction) from Northumbria University
  • Specialized in multi-agent systems and production deployment
  • Based in London, available for consulting

Connect:

🌟 Why This Project Matters

Customer support is broken in most companies:

  • ❌ Long wait times (avg 8 minutes)
  • ❌ Inconsistent service quality
  • ❌ High operational costs (£40K+ per agent/year)
  • ❌ Limited availability (business hours only)

This system solves all of these problems while being:

  • Instant: Immediate responses 24/7
  • Consistent: Same quality every interaction
  • Cost-effective: 90% cost reduction vs human agents
  • Scalable: Handle unlimited concurrent users

The best part? You get the complete blueprint to build and deploy this yourself.


Star this repo if it helps you build better customer support!