Practical Multi-Agent Example
Build a complete multi-agent customer support system with a triage agent, specialist agents, and a quality assurance agent.
10 min•By Priygop Team•Updated 2026
Customer Support Multi-Agent System
Customer Support Multi-Agent System
# Multi-agent customer support system
class CustomerSupportSystem:
def __init__(self):
self.agents = {
"triage": self._triage_agent,
"billing": self._billing_agent,
"technical": self._technical_agent,
"general": self._general_agent,
"qa": self._qa_agent,
}
def _triage_agent(self, ticket: dict) -> dict:
"""Classify the ticket and route to the right specialist."""
keywords = ticket.get("message", "").lower()
if any(w in keywords for w in ["refund", "charge", "payment", "invoice"]):
category = "billing"
elif any(w in keywords for w in ["error", "bug", "crash", "not working"]):
category = "technical"
else:
category = "general"
return {"category": category, "priority": "high" if "urgent" in keywords else "normal"}
def _billing_agent(self, ticket: dict, triage: dict) -> dict:
"""Handle billing and payment enquiries."""
return {
"response": f"Thank you for your billing enquiry. I've checked your account and will process the refund within 3-5 business days.",
"action_taken": "refund_initiated",
"agent": "billing"
}
def _technical_agent(self, ticket: dict, triage: dict) -> dict:
"""Handle technical issues."""
return {
"response": "I've identified the issue. Please try clearing your cache and logging in again. If the problem persists, I'll escalate to engineering.",
"action_taken": "troubleshooting_provided",
"agent": "technical"
}
def _general_agent(self, ticket: dict, triage: dict) -> dict:
"""Handle general enquiries."""
return {
"response": "Thank you for reaching out. I'm happy to help with your enquiry.",
"action_taken": "answered",
"agent": "general"
}
def _qa_agent(self, response: dict) -> dict:
"""Review the agent response for quality."""
text = response.get("response", "")
approved = len(text) > 20 and "Thank" in text
return {"approved": approved, "score": 9 if approved else 4}
def handle_ticket(self, ticket: dict) -> dict:
print(f"Ticket: {ticket['message'][:50]}")
# Step 1: Triage
triage = self._triage_agent(ticket)
print(f" → Routed to: {triage['category']} ({triage['priority']} priority)")
# Step 2: Handle by specialist
specialist = self.agents.get(triage["category"], self.agents["general"])
response = specialist(ticket, triage)
print(f" → {response['agent']} responded")
# Step 3: QA review
qa_result = self._qa_agent(response)
print(f" → QA: {'✓ Approved' if qa_result['approved'] else '✗ Rejected'} (score: {qa_result['score']}/10)")
return {"ticket": ticket, "triage": triage, "response": response, "qa": qa_result}
support = CustomerSupportSystem()
ticket = {"id": "T001", "message": "I was charged twice for my subscription, please refund"}
result = support.handle_ticket(ticket)
print(f"\nFinal response: {result['response']['response'][:60]}...")