Skip to content

Commit 7324ff9

Browse files
authored
Merge pull request #1 from cyberholics/a2a-customer-routing
A2a customer routing
2 parents 0abe6af + df42fce commit 7324ff9

File tree

16 files changed

+2025
-0
lines changed

16 files changed

+2025
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
NEBIUS_API_BASE="https://api.studio.nebius.com/v1/"
2+
NEBIUS_API_KEY="your-nebius-api-key-here"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.env
2+
.env
3+
.env
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Multi-Agent Customer Query Routing and Resolution With Google ADK and A2A Protocol
2+
3+
A customer support system built with distributed AI agents using the A2A (Agent-to-Agent) protocol and Google's Agent Development Kit (ADK). The system intelligently routes customer inquiries based on sentiment analysis and provides automated responses through knowledge base search or human escalation.
4+
5+
## System Architecture
6+
7+
```
8+
User Message → Coordinator Agent → Sentiment Analysis → Routing Decision
9+
10+
┌─────────────────────────────┐
11+
│ │
12+
Negative Sentiment Positive/Neutral
13+
│ │
14+
↓ ↓
15+
Escalation Agent Resolution Agent
16+
(Human Handoff) (Knowledge Base Search)
17+
│ │
18+
└─────────────────────────────┘
19+
20+
Final Response to User
21+
```
22+
23+
## Agent Overview
24+
25+
| Agent | Port | Purpose | Technology |
26+
|-------|------|---------|------------|
27+
| **Coordinator** | 10023 | Orchestrates workflow and routing | Llama 3.1 8B |
28+
| **Intake** | 10020 | Sentiment analysis (positive/neutral/negative) | Llama 3.1 8B |
29+
| **Resolution** | 10021 | Knowledge base search and answers | Qwen 235B |
30+
| **Escalation** | 10022 | Human support escalation | Llama 3.1 8B |
31+
32+
## Features
33+
34+
- **Intelligent Routing**: Automatic sentiment-based message routing
35+
- **Knowledge Base Integration**: Semantic search through FAQ database
36+
- **Human Escalation**: Automatic escalation for negative sentiment cases
37+
- **Distributed Architecture**: Each agent runs independently via A2A protocol
38+
- **Scalable Design**: Easy to add new agents or modify existing ones
39+
40+
## Prerequisites
41+
42+
- Python 3.8+
43+
- API access to Nebius AI models
44+
- Required Python packages (see requirements.txt)
45+
46+
## How to Run
47+
48+
1. **Clone the repository**
49+
```
50+
git clone https://github.com/Astrodevil/ADK-Agent-Examples.git
51+
cd ADK-Agent-Examples/"A2A Customer Query Routing and Resolution"
52+
```
53+
54+
2. **Install dependencies**
55+
```
56+
pip install -r requirements.txt
57+
```
58+
59+
3. **Set up environment variables**
60+
```
61+
cp .env.example .env
62+
# Edit .env with your API credentials
63+
```
64+
65+
4. **Run the multi-agent system**
66+
```
67+
python multi_agent/agent.py
68+
```
69+
70+
71+
## Workflow Examples
72+
73+
### Positive/Neutral Sentiment Flow
74+
```
75+
User: "How do I track my order?"
76+
77+
Coordinator → Intake Agent → "neutral"
78+
79+
Coordinator → Resolution Agent → KB Search
80+
81+
Response: " "
82+
```
83+
84+
### Negative Sentiment Flow
85+
```
86+
User: "This product is terrible! I want my money back!"
87+
88+
Coordinator → Intake Agent → "negative"
89+
90+
Coordinator → Escalation Agent → Human Escalation
91+
92+
Response: " "
93+
```
94+
95+
## System Components
96+
97+
### Core Classes
98+
99+
- **`KB`**: Knowledge base management with LlamaIndex integration
100+
- **`ADKAgentExecutor`**: Wrapper for Google ADK agents to work with A2A protocol
101+
- **`A2AToolClient`**: Client for agent-to-agent communication
102+
103+
104+
### Agent Tools
105+
106+
- **`resolve_query_fn`**: Searches knowledge base for answers
107+
- **`classify_fn`**: Performs sentiment analysis
108+
- **`escalate_fn`**: Handles human escalation logging
109+
110+
111+
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{
2+
"Returns & Refunds": [
3+
{
4+
"question": "What is SwiftCart's return policy?",
5+
"answer": "You can return most items within 30 days of delivery for a full refund. The items must be in their original condition."
6+
},
7+
{
8+
"question": "How long does it take to process a refund?",
9+
"answer": "Refunds are typically processed within 5\u20137 business days after we receive your return."
10+
},
11+
{
12+
"question": "Can I return items purchased on sale?",
13+
"answer": "Yes, sale items can be returned unless marked as 'final sale'."
14+
}
15+
],
16+
"Shipping & Delivery": [
17+
{
18+
"question": "What shipping methods are available?",
19+
"answer": "We offer standard, express, and overnight shipping via multiple carriers."
20+
},
21+
{
22+
"question": "How do I track my order?",
23+
"answer": "Once your order is shipped, you\u2019ll receive a tracking number via email or SMS."
24+
},
25+
{
26+
"question": "Do you ship internationally?",
27+
"answer": "Yes, SwiftCart ships to over 50 countries worldwide."
28+
}
29+
],
30+
"Payments & Billing": [
31+
{
32+
"question": "What payment methods are accepted?",
33+
"answer": "We accept credit/debit cards, PayPal, Apple Pay, Google Pay, and SwiftCart gift cards."
34+
},
35+
{
36+
"question": "When will my card be charged?",
37+
"answer": "Your card will be charged when your order is confirmed."
38+
},
39+
{
40+
"question": "Can I get an invoice for my order?",
41+
"answer": "Yes, invoices are sent via email and are also available in your account dashboard."
42+
}
43+
],
44+
"Troubleshooting": [
45+
{
46+
"question": "I'm having trouble logging in.",
47+
"answer": "Ensure you're using the correct email and password. Try resetting your password if the issue persists."
48+
},
49+
{
50+
"question": "My order hasn't arrived.",
51+
"answer": "Check the tracking link provided. If it's delayed beyond the estimated delivery date, contact our support."
52+
},
53+
{
54+
"question": "The website isn\u2019t loading correctly.",
55+
"answer": "Try clearing your browser cache or using a different browser. If the issue continues, contact support."
56+
}
57+
],
58+
"Product Warranty": [
59+
{
60+
"question": "Do products come with a warranty?",
61+
"answer": "Yes, most electronics come with a 1-year manufacturer warranty. Other product warranties vary."
62+
},
63+
{
64+
"question": "How do I claim a warranty?",
65+
"answer": "Contact support with your order number and a description of the issue. We\u2019ll guide you through the process."
66+
}
67+
],
68+
"Account Management": [
69+
{
70+
"question": "How do I change my password?",
71+
"answer": "Go to your account settings and click 'Change Password'. Follow the instructions."
72+
},
73+
{
74+
"question": "Can I delete my account?",
75+
"answer": "Yes, contact support to request account deletion. We'll process your request within 7 days."
76+
},
77+
{
78+
"question": "How do I update my address?",
79+
"answer": "Log in to your account, navigate to 'Addresses', and click 'Edit' next to the address you wish to update."
80+
}
81+
],
82+
"Company Policies": [
83+
{
84+
"question": "Is my data safe with SwiftCart?",
85+
"answer": "Yes, we follow industry-standard practices to protect your personal information and data."
86+
},
87+
{
88+
"question": "Do you share customer data?",
89+
"answer": "No, we do not sell or rent customer data. We only share data with partners as needed to fulfill your order."
90+
},
91+
{
92+
"question": "Where are SwiftCart\u2019s terms and conditions?",
93+
"answer": "You can view our full terms and conditions on our website\u2019s footer or at swiftcart.com/terms."
94+
}
95+
]
96+
}

0 commit comments

Comments
 (0)