Skip to content

codeasarjun/agentic_support

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi-Agent Customer Support Escalation System

An AI-powered multi-agent customer support system built using LangGraph, LangChain, and Ollama.

This project simulates a real-world customer support workflow where multiple AI agents collaborate to:

  • classify support tickets
  • analyze customer sentiment
  • resolve issues
  • retrieve knowledge-base answers
  • escalate critical cases to humans

The system is fully local and can run using Ollama models like llama3.2.


Features

Multi-Agent Workflow

The system contains specialized agents with independent responsibilities.

Agents

  • Triage Agent
  • Billing Support Agent
  • Technical Support Agent
  • FAQ Agent
  • Sentiment Analysis Agent
  • Escalation Agent

Ticket Classification

Automatically categorizes tickets into:

  • billing
  • technical
  • refund
  • account
  • complaint

Sentiment Detection

Analyzes customer tone:

  • angry
  • frustrated
  • neutral
  • happy
  • urgent

Intelligent Escalation

Escalates tickets when:

  • sentiment is highly negative
  • confidence is low
  • issue cannot be resolved
  • refund/legal keywords appear

Conversation Memory

Stores:

  • previous interactions
  • ticket history
  • escalation history
  • customer context

Local LLM Support

Runs locally using Ollama.

Supported models:

  • llama3.2

Architecture

graph TD
    %% Styling and Themes
    classDef client fill:#e1f5fe,stroke:#03a9f4,stroke-width:2px,color:#000;
    classDef orchestrator fill:#ffe0b2,stroke:#fb8c00,stroke-width:2px,color:#000;
    classDef agent fill:#e8f5e9,stroke:#4caf50,stroke-width:2px,color:#000;
    classDef data fill:#f3e5f5,stroke:#9c27b0,stroke-width:2px,color:#000;
    classDef infra fill:#eceff1,stroke:#607d8b,stroke-width:2px,color:#000;

    %% User Interface Layer
    subgraph UI_Layer ["User Interface (Streamlit / CLI)"]
        A[Customer / Support Agent] -->|Submits Ticket| B[Streamlit UI / CLI main.py]
    end
    class B client;

    %% Orchestration Layer
    subgraph Orchestration_Layer ["Graph Workflow Management (LangGraph & LangChain)"]
        B -->|Initializes State| C[LangGraph State Workflow]
        C -->|1. Parse Ticket| D[Triage Agent]
        
        %% Routing Decision
        D -->|2. Route Category| E{Category Router}
        
        %% Specialized Agents
        E -->|billing / refund| F[Billing Support Agent]
        E -->|technical / account| G[Technical Support Agent]
        E -->|complaint / general| H[FAQ Agent]
        
        %% Response Processing Pipeline
        F --> I[Response Aggregator]
        G --> I
        H --> I
        
        %% Sentiment and Evaluation
        I -->|3. Evaluate Output| J[Sentiment Analysis Agent]
        J -->|4. Check Escalation Triggers| K{Escalation Router}
    end
    class C,E,K orchestrator;
    class D,F,G,H,J,L agent;

    %% Human Escalation Fallback
    subgraph Escalation_Layer ["Escalation Management"]
        K -->|Highly Negative / Low Confidence| L[Escalation Agent]
        L -->|Handoff| M[Human Support Pipeline]
    end
    class M client;

    %% Data and Storage Layer
    subgraph Storage_Layer ["Data & Vector Systems"]
        C <-->|Read / Write History| N[(SQLite Chat Memory)]
        F & G & H <-->|Query Context| O[(ChromaDB Knowledge Base)]
    end
    class N,O data;

    %% Local LLM Execution Layer
    subgraph Local_Infra ["Local LLM Infrastructure"]
        D & F & G & H & J & L -.->|Local API Calls| P[FastAPI Backend]
        P -.->|Inference| Q[Ollama Service]
        Q -.->|Model Runtime| R[llama3.2]
    end
    class P,Q,R infra;

    %% Output Node
    K -->|Resolved State| S[Final Output Response to UI]
    M -->|Human Response| S
    S --> B
Loading

Tech Stack

Component Technology
LLM Ollama
Models llama3.2
Framework LangChain
Orchestration LangGraph
Backend FastAPI
UI Streamlit
Database SQLite
Vector Store ChromaDB

Project Structure

customer_support_ai/
│
├── agents/
│   ├── triage_agent.py
│   ├── billing_agent.py
│   ├── technical_agent.py
│   ├── faq_agent.py
│   ├── sentiment_agent.py
│   └── escalation_agent.py
│
├── graph/
│   └── workflow.py
│
├── prompts/
│   └── prompts.py
│
├── memory/
│   └── chat_memory.py
│
├── database/
│   └── tickets.db
│
├── ui/
│   │
│   ├── app.py
│   │
│   ├── pages/
│   │   ├── dashboard.py
│   │   ├── ticket_history.py
│   │   ├── analytics.py
│   │   └── settings.py
│   │
│   ├── components/
│   │   ├── agent_card.py
│   │   ├── workflow_graph.py
│   │   ├── sentiment_meter.py
│   │   └── escalation_box.py
│   │
│   └── assets/
│       └── styles.css
│
├── main.py
├── requirements.txt
├── .env
└── README.md

Installation

1. Clone Repository

git clone <your-repo-url>

cd customer_support_ai

2. Create Virtual Environment

Linux / macOS

python -m venv venv

source venv/bin/activate

Windows

python -m venv venv

venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

Install Ollama

Download and install Ollama:

https://ollama.com/


Pull LLM Model

ollama pull llama3.2

Run Ollama

ollama run llama3.2

Environment Variables

Create a .env file:

MODEL_NAME=llama3.2:latest
TEMPERATURE=0

Running the Application

Run CLI System

python main.py

Run Streamlit UI

streamlit run ui/app.py

Example Ticket

I was charged twice for my subscription and nobody has responded for 3 days.

Example Output

Category   : technical
Sentiment  : frustrated
Escalation : escalate

Response:
Step-by-step troubleshooting guide for payment failure...

Example Workflow

Ticket Received
      ↓
Triage Agent
      ↓
Routing (Billing / Technical / FAQ)
      ↓
Response Generation
      ↓
Sentiment Analysis
      ↓
Escalation Decision
      ↓
Final Output

Objectives

This project demonstrates:

  • Multi-agent orchestration
  • AI workflow design
  • LangGraph state management
  • LLM routing
  • Memory systems
  • Human escalation pipelines

Sample Agent Responsibilities

Agent Responsibility
Triage Agent Ticket classification
Billing Agent Payment/refund issues
Technical Agent Bug troubleshooting
FAQ Agent General support
Sentiment Agent Emotion detection
Escalation Agent Human escalation

Notes / Improvements (Next Phase Ideas)

  • Add RAG-based knowledge base
  • Add confidence scoring before escalation
  • Add structured JSON outputs
  • Add evaluation metrics for routing accuracy
  • Add logging dashboard for agent decisions
  • Voice based chat

License

MIT License


Built Using

  • LangChain
  • LangGraph
  • Ollama
  • Streamlit
  • FastAPI

About

An AI-powered multi-agent customer support system using LangGraph, LangChain, and Ollama to automate ticket classification, sentiment analysis, issue resolution, and intelligent escalation workflows.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors