Capstone Project for Kaggle 5-Day AI Agents Intensive Course
Intelligent multi-agent customer support system that automates first-line support with smart routing, sentiment analysis, and intelligent escalation.
Companies receive thousands of repetitive customer support queries daily (order status, refunds, shipping, FAQs). Human agents get overloaded, response times slow to 2-4 hours, and conversations lack continuity. This leads to:
- High operational costs: $15-25 per ticket for human agents
- Slow response times: 2-4 hours average, up to 24 hours during peak
- Inconsistent service quality: Varies by agent experience
- Customer frustration: 40% of customers abandon after 1 hour wait
- Scalability issues: Cannot handle traffic spikes without hiring
CustoFlow automates 80%+ of common queries with intelligent routing, freeing human agents for complex issues while maintaining high-quality, context-aware responses.
- β‘ Response time: 2-4 hours β <10 seconds (99% reduction)
- π° Cost reduction: 60% lower operational costs
- π Scalability: Handle 1000+ concurrent users vs 50-100 with humans
- π Satisfaction: 40% improvement in customer satisfaction scores
- π― Accuracy: 95%+ routing accuracy to correct specialist
flowchart TD
Start[Customer Query] --> Validate[Input Validation π]
Validate --> RateLimit[Rate Limiting β±οΈ<br/>60 req/min]
RateLimit --> Cache{Cache Check πΎ}
Cache -->|Hit| CacheResponse[Return Cached Response β
]
Cache -->|Miss| Orchestrator[Orchestrator Analysis π―]
Orchestrator --> Route{Route Decision}
Route -->|FAQ| FAQAgent[FAQ Agent π]
Route -->|Order| OrderAgent[Order Agent π¦]
Route -->|Sentiment| SentimentAgent[Sentiment Agent π]
Route -->|Escalation| EscalationAgent[Escalation Agent π«]
FAQAgent --> FAQTool[FAQ Tool<br/>Semantic Search]
OrderAgent --> OrderTools[Order Tools<br/>Lookup, Modify, Track]
SentimentAgent --> EscalationAgent
EscalationAgent --> TicketTool[Ticket Tool<br/>Create & Summarize]
FAQTool --> Database[(Supabase Database)]
OrderTools --> Database
TicketTool --> Database
Database --> Response[Generate Response]
CacheResponse --> User[Customer Response β
]
Response --> Store[Store in Cache πΎ]
Store --> Analytics[Update Analytics π]
Analytics --> User
style Start fill:#E3F2FD
style CacheResponse fill:#81C784
style User fill:#4CAF50
style Orchestrator fill:#4CAF50,stroke:#2E7D32,color:#fff
style Database fill:#A5D6A7
graph TB
Query["Customer: I'm frustrated with order 12345!"] --> Analysis[Orchestrator Analysis]
Analysis --> Sentiment[Sentiment Agent π<br/>Detects: Frustration, High Urgency]
Analysis --> Order[Order Agent π¦<br/>Retrieves Order Details]
Analysis --> Escalation[Escalation Agent π«<br/>Creates Urgent Ticket]
Sentiment -.->|A2A Protocol| Escalation
Order -.->|A2A Protocol| FAQ[FAQ Agent π<br/>Gets Refund Policy]
FAQ -.->|A2A Protocol| Order
Sentiment --> SentimentData[Sentiment Analysis<br/>Emotion: Frustrated<br/>Urgency: High]
Order --> OrderData[Order Details<br/>Status, Items, Tracking]
Escalation --> TicketData[Ticket Created<br/>Priority: Urgent<br/>Summary Generated]
FAQ --> PolicyData[Refund Policy<br/>30-day guarantee]
SentimentData --> Response[Combined Response<br/>Empathetic + Order Info + Ticket]
OrderData --> Response
TicketData --> Response
PolicyData --> Response
style Analysis fill:#4CAF50,stroke:#2E7D32,color:#fff
style Response fill:#81C784,stroke:#4CAF50,color:#fff
style Sentiment fill:#9C27B0,stroke:#4A148C,color:#fff
style Order fill:#FF9800,stroke:#E65100,color:#fff
style Escalation fill:#F44336,stroke:#B71C1C,color:#fff
style FAQ fill:#2196F3,stroke:#1565C0,color:#fff
graph TB
subgraph "Session Layer"
Session[Session Memory π<br/>InMemorySessionService<br/>Active conversation context]
end
subgraph "Persistence Layer"
History[Conversation History π<br/>Supabase Messages Table<br/>Full message history]
Metadata[Session Metadata<br/>Customer ID, User ID<br/>Session status]
end
subgraph "Long-Term Memory"
LongTerm[Long-Term Memory π§ <br/>Customer Knowledge<br/>Preferences, History]
Analytics[Analytics Data π<br/>Interaction patterns<br/>Satisfaction scores]
end
Session -->|Store Messages| History
Session -->|Store Context| Metadata
History -->|Aggregate| LongTerm
Metadata -->|Track| Analytics
LongTerm -->|Personalize| Session
Analytics -->|Improve| Session
style Session fill:#2196F3,stroke:#1565C0,color:#fff
style History fill:#FF9800,stroke:#E65100,color:#fff
style Metadata fill:#FFB74D,stroke:#E65100,color:#000
style LongTerm fill:#4CAF50,stroke:#2E7D32,color:#fff
style Analytics fill:#9C27B0,stroke:#4A148C,color:#fff
- π€ Multi-Agent System: 5 specialized agents with intelligent routing and A2A communication
- π§ Intelligent Routing: Automatic query classification with sentiment-first analysis
- π Context & Memory: Full conversation history and long-term memory for personalization
- π« Smart Escalation: Automatic ticket creation with summarization and LRO pattern
- π Semantic Search: FAISS vector embeddings for 50+ FAQs
- π€ Audio Support: Google Cloud Speech-to-Text and Text-to-Speech
- π Analytics & Observability: Real-time metrics dashboard and comprehensive logging
- π€ Self-Improving System: Automatic agent refinement from feedback and A/B testing
- π₯οΈ Modern Web Dashboard: React/Next.js with real-time updates and CRUD operations
- π Security & Performance: Input validation, rate limiting, caching, and adaptive polling
- Python 3.10+
- Google AI Studio API key (Get one here)
- Clone the repository:
git clone https://github.com/Rayyan-Oumlil/CustoFlow.git
cd CustoFlow- Install dependencies:
pip install -r requirements.txt- Create
.envfile:
GOOGLE_API_KEY=your_api_key_here
SUPABASE_URL=your_supabase_url
SUPABASE_KEY=your_supabase_key- Set up Google Cloud credentials (for Speech API & Vision API):
For local development, download your service account credentials from Google Cloud Console and place them in the project root:
# Download credentials.json from Google Cloud Console
# Place it in the project root directory
credentials.jsonFor Google Cloud Run deployment:
- Use
GOOGLE_APPLICATION_CREDENTIALS_JSONenvironment variable (JSON content as string) - Or use Application Default Credentials (ADC) if running on Cloud Run
Note: credentials.json is already in .gitignore - never commit it!
Optional: For semantic search, install additional dependencies:
pip install sentence-transformers faiss-cpu
python -m tools.init_semantic_search- Run tests to verify setup:
python -m pytest tests/React Frontend (Recommended):
python -m api.server # Backend
cd frontend && npm install --legacy-peer-deps && npm run dev # FrontendAccess at http://localhost:3000 - Chat, Analytics, Orders & Tickets dashboards.
Interactive CLI:
python main.pyAPI Server:
python -m api.serverAPI docs at http://localhost:8000/docs
CustoFlow/
β
βββ π€ agents/ # Agent Definitions (5 agents)
β βββ orchestrator_agent.py # π― Main routing agent
β βββ faq_agent.py # π FAQ specialist
β βββ order_agent.py # π¦ Order inquiry specialist
β βββ sentiment_agent.py # π Sentiment analysis
β βββ escalation_agent.py # π« Ticket creation
β
βββ π οΈ tools/ # Custom Tools (8 tools)
β βββ faq_tool.py # π FAQ search + cache
β βββ order_tool.py # π Order lookup + cache
β βββ order_modification_tool.py # π§ Order modifications
β βββ shipping_tool.py # π¦ Shipping tracking (OpenAPI)
β βββ ticket_tool.py # π« Ticket creation
β βββ ticket_modification_tool.py # π§ Ticket modifications
β βββ ticket_tool_lro.py # βΈοΈ LRO with human approval
β βββ conversation_tool.py # π¬ Conversation tools
β βββ document_analysis_tool.py # π Document analysis
β
βββ πΎ memory/ # Session & Memory
β βββ session_store.py # π Session management
β βββ long_term_memory.py # π§ Long-term memory
β βββ conversation_history.py # π Conversation history
β
βββ π observability/ # Logging, Metrics, Tracing
β βββ logging_config.py # π ADK LoggingPlugin
β βββ metrics.py # π Thread-safe metrics
β βββ tracing.py # π Request tracing
β
βββ π api/ # FastAPI Server
β βββ server.py # π RESTful API
β
βββ π¨ frontend/ # React/Next.js Frontend
β βββ app/ # Next.js app directory
β β βββ chat/ # Chat interface
β β βββ orders/ # Orders & Tickets dashboard
β β βββ analytics/ # Analytics dashboard
β β βββ page.tsx # Home dashboard
β βββ components/ # UI components (shadcn/ui)
β βββ lib/ # API client & state management
β
βββ π§ͺ tests/ # Test Suite (15+ tests)
β βββ test_faq_agent.py # β
FAQ agent tests
β βββ test_order_agent.py # β
Order agent tests
β βββ test_orchestrator_agent.py # β
Orchestrator tests
β βββ test_sentiment_agent.py # β
Sentiment tests
β βββ test_escalation_agent.py # β
Escalation tests
β βββ test_session.py # β
Session tests
β βββ test_validation.py # β
Validation tests
β βββ test_rate_limiter.py # β
Rate limiting tests
β βββ test_cache.py # β
Cache tests
β βββ test_security.py # β
Security tests
β βββ test_load.py # β
Load tests
β βββ test_integration.py # β
Integration tests
β
βββ π notebooks/ # Evaluation
β βββ evaluation.py # π Automated evaluation
β
βββ π docs/ # Documentation
β βββ API.md # π API documentation
β βββ SETUP.md # βοΈ Setup guide
β βββ TROUBLESHOOTING.md # π§ Troubleshooting
β βββ ADVANCED_EXAMPLES.md # π‘ Advanced examples
β
βββ πΌ utils/ # Utilities
β βββ validation.py # β
Input validation
β βββ cache.py # πΎ Caching system
β βββ rate_limiter.py # β±οΈ Rate limiting
β βββ error_handler.py # β οΈ Error handling
β βββ analytics.py # π Analytics
β βββ multilingual.py # π Multilingual support
β βββ supabase_client.py # ποΈ Supabase integration
β βββ auto_improver.py # π€ Automatic agent improvements
β βββ agent_improver.py # π§ Agent refinement system
β βββ kb_updater.py # π KB update suggestions
β βββ feedback_manager.py # π¬ Feedback analysis
β βββ conversation_summarizer.py # π Conversation summaries
β
βββ π¦ data/ # Knowledge Base
β βββ faq_knowledge_base.json # π FAQ database
β
βββ ποΈ sql/ # Database Scripts
β βββ create_complete_database.sql # Complete database schema
β βββ setup_rls_policies.sql # Row Level Security policies
β βββ setup_storage_permissions.sql # Storage bucket permissions
β
βββ βοΈ config/ # Configuration
β βββ settings.py # π§ Settings management
β
βββ π― main.py # CLI Entry Point
βββ π requirements.txt # Dependencies
The system includes 140+ comprehensive test cases across 30+ test files covering unit tests, integration tests, security tests, and load tests.
# Run all tests
python -m pytest tests/
# Run specific test category
pytest tests/test_security.py
pytest tests/test_integration.pyConfiguration is managed via environment variables in .env:
GOOGLE_API_KEY=your_api_key
MODEL_NAME=gemini-2.5-flash-lite
APP_NAME=CustoFlow
DEBUG=false
API_HOST=0.0.0.0
API_PORT=8000
# Optional: For Google Cloud Speech API & Vision API
# Local development: Place credentials.json in project root
# Cloud deployment: Use GOOGLE_APPLICATION_CREDENTIALS_JSON env varThis project demonstrates 11 key concepts from the Kaggle 5-Day AI Agents Intensive Course (organized by Kaggle and Google), built entirely with Google's Agent Development Kit (ADK) and Google Gemini 2.5 Flash Lite:
- π₯ YouTube Video: Watch the Capstone Project Demo
- π Live Website: https://custoflow.vercel.app
- βοΈ API Backend (Cloud Run): https://custoflow-api-171629812602.us-central1.run.app
- π¦ GitHub Repository: https://github.com/Rayyan-Oumlil/CustoFlow
To try the live website, simply enter one of the available customer usernames when prompted. For example, you can use:
cust_004(or any other customer ID from the system)
Just type the username directly - no password required!
MIT License - see LICENSE file for details.
Built for the Kaggle 5-Day AI Agents Intensive Course (Kaggle + Google).



