This project implements a modular, agentic AI workflow for automated support ticket handling using LangGraph.
It uses RAG for context retrieval and an iterative review loop to ensure high-quality, compliant responses — escalating to human review if necessary.
- Ticket Classification: Classify the ticket based on subject + description.
- Retrieval: Fetch relevant info for that category.
- Response Generation: Generate a draft response based on context and ticket details.
- Reviewer Feedback Loop: Reviews the draft for:
- Relevance & accuracy
- Helpfulness
- Compliance with support guidelines
- Max 2 Review Attempts: If both fail, escalate to a human agent.
- Escalation Logging: Failing drafts + feedback stored in
escalation_log.csv
.
Ensure you have installed:
- Python 3.10+
pip
- LangGraph
- An OpenAI API key
# Clone repository
git clone https://github.com/your-username/support-ticket-agent.git
cd support-ticket-agent
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # Linux/Mac
.venv\Scripts\activate # Windows
# Install dependencies
pip install langgraph langchain langchain-openai python-dotenv openai
# Create a `.env` file in the root directory:
OPENAI_API_KEY=your_openai_api_key_here
python main.py
support_ticket_system/
│
├── main.py # Entry point to run the workflow
├── graph.py # Entry point to run the workflow
│
├── nodes/
│ ├── classifier.py # Category classification node
│ ├── rag.py # Category-specific RAG retrieval
│ ├── generator.py # Generates draft responses
│ ├── reviewer.py # Reviews drafts, gives feedback
│ ├── escalate.py # Handles escalation logging
│
├── utils/
│ ├── formatters.py # Formates the context
│ ├── logger.py # Escalation CSV logging
│
└── logs/
└── escalation_log.csv # Where escalations are stored
Fetch relevant knowledge snippets based on the ticket content.
An LLM-based node that uses retrieved context + ticket details to draft a response.
Checks the draft for:
- Relevance & Accuracy
- Helpfulness
- Compliance
- No overpromises
- No unauthorized refunds
- No sensitive security advice
Logs the following into escalation_log.csv
:
- Original ticket
- Failed drafts
- Reviewer feedback