DEV Community

Cover image for Smart Customer Support - A Multi Agent Ticketing System Using OpenAI Agents SDK
gins p cyriac
gins p cyriac

Posted on

Smart Customer Support - A Multi Agent Ticketing System Using OpenAI Agents SDK

Introduction

In this project, I built an intelligent car customer support system using AI agents which converts customer support emails into structured support tickets with AI generated draft response based on internal document references which are then reviewed by human agents.

Handling hundreds of customer support emails at scale is difficult, especially when many request are repetitive. Currently, the support teams often read through hundreds of emails everyday, analyze each request and send meaningful response to each customer. This is a tedious and time consuming process, especially if the customer service agent has to search through various internal documents before responding to each customer.

My goal with this project is to automate this repetitive parts of the support workflow while still giving the humans the final say. This project is a collaboration between AI and human agents. Full code for this project can be found on Link

Project Features

  • 📩 Email ingestion (Gmail)
  • 🤖 AI agent analyze support emails and generates
    • Priority
    • Summary
    • Draft response
  • 🧑‍💼 Human-in-the-loop approval before sending response to users
    • ✏️ Editable draft responses
    • ✅ Approve / ❌ Reject tickets
  • 📊 Analytics dashboard
    • Tickets per day
    • Tickets by priority
    • Tickets by status
    • Total tickets & pending review

🚀 Technologies

  • PostgreSQL – Data storage
  • FastAPI – Backend API implementation
  • LLM (GPT-5 Nano) – Language model powering the AI agent
  • Next.js – Frontend web application
  • Docker Compose – Service orchestration

Architecture Overview

Architecture Diagram

AI Agent Orchestration Design

Instead of using a single agent with a large prompt, in this project I have used separate specialized agents with a clear defined role and strict boundaries.

1. Email Analyzer Agent

The Email Analyzer Agent is responsible for processing incoming emails.

Its job is to:

  • Inspect the email body
  • Detect whether it contains a valid customer complaint or request
  • Assign a priority level (LOW, MEDIUM, HIGH, CRITICAL)
  • Generate a one sentence summary

If the email does not contain a valid request, the agent explicitly marks priority as INVALID.

2. Car Expert Agent (RAG based Domain Expert)

The Car Expert Agent acts as a car specific knowledge agent. It does not rely on general LLM knowledge. The agent provide response by strictly referencing car documentation using a Retrieval-Augmented Generation (RAG) approach. If the requested information is not found, then the agent provide the response accordingly.

3. Orchestrator Agent (Coordinator & Decision Maker)

The Orchestrator Agent is the brain of the system. It coordinates the entire workflow by invoking other agents as tools and enforcing business rules.

Its responsibilities include:

  • Calling the Email Analyzer Agent
  • Deciding whether a ticket should be created
  • Generating a human-readable ticket number
  • Detecting whether the request is car-related
  • Conditionally invoking the Car Expert Agent
  • Producing a draft email response for human review
class OrchestratorAgentOutput(BaseModel):
    priority:str
    summary:str
    draft_response: str
    subject: str
    ticket_number: str

orchestrator_agent = Agent(name="orchestrator agent",
                           instructions=""" 
                            You are a customer care car support orchestrator.
                            Process:
                            1. Use email_analyzer to classify priority and summarize.
                            2. If priority == INVALID:
                            - Create a polite rejection response
                            3. If priority != INVALID:
                            - Determine if the request is about car operation, maintenance, or faults
                            - ONLY IF it is car-related, call car_expert
                            4. Use car_expert output strictly; do not add assumptions
                            5. Produce a draft email response and subject

                            Output MUST match OrchestratorAgentOutput. 
                           """, 
                           model="gpt-5-nano",
                           tools=[    
                            create_ticket_number,     
                            email_analyzer_agent.as_tool(
                                tool_name="email_analyzer",
                                tool_description="Perform analysis of the email and provide a brief summary and priority of the email",
                            ),         
                            car_expert_agent.as_tool(
                                tool_name="car_expert",
                                tool_description="Provides correct answers regarding the car by referring the car documentation",
                            ),
                           ],
                           output_type=OrchestratorAgentOutput
                           )
Enter fullscreen mode Exit fullscreen mode

Here, the orchestrator agent use the email_analyzer_agent and car_expert_agent as tools. This approach keeps the prompts small and focused, it prevents role overlap while also allowing easy tool extension.

Human-in-the-Loop By Design

The orchestrator agent produces a draft response, not a final answer.

Every generated response is:

  • Stored as a draft.
  • Reviewed by a human agent.
  • Edited or Approved / Rejected by a human agent.

This ensures trust in AI-assisted workflows and also keeping the accountability.

🖼 Screenshots

Below are a few screenshots highlighting key parts of the system

Dashboard
Dashboard
Ticket Lists
TicketList
Edit Response
Editresponse

🚀 Next Steps

  • Pluggable LLM Provider Support.
  • Enhanced RAG Pipeline.
  • Mentioning source in AI Responses.
  • Add support for more agents (e.g., billing, warranty, returns)
  • UI Improvements

Top comments (0)