Skip to content

Repository files navigation

🤖 AI Customer Support Automation

An AI-powered customer support automation system built with Python, LangGraph, LangChain, Ollama, RAG, and SQLite. The application classifies customer queries, routes them to specialized support agents, retrieves relevant information from a knowledge base, maintains customer conversation history, applies human approval to high-risk requests, and generates a polished final response.

The project demonstrates how agentic workflows, retrieval-augmented generation, persistent memory, and human-in-the-loop approval can be combined to build a practical customer support automation system.

✨ Key Features

  • 🤖 LLM-powered customer support
  • 🧠 Automatic customer-query intent classification
  • 🔀 LangGraph-based conditional routing
  • 💼 Specialized Sales support agent
  • 🛠️ Specialized Technical support agent
  • 💳 Specialized Billing support agent
  • 👤 Specialized Account support agent
  • 🧠 Conversation-memory support
  • 📚 Retrieval-Augmented Generation (RAG)
  • 🔎 Semantic knowledge-base retrieval
  • 💾 Persistent customer conversation history using SQLite
  • 🛡️ Human approval workflow for high-risk requests
  • 👨‍💼 Supervisor agent for final response review
  • 🖥️ Interactive Streamlit interface
  • 🏠 Local LLM inference using Ollama
  • 📊 Retrieved-context display and department identification

🧠 Architecture

Customer Query
      ↓
Intent Classification
      ↓
LangGraph Routing
      ↓
Specialized Support Agent
      ↓
Knowledge-Base Retrieval
      ↓
Agent Response
      ↓
High-Risk Check
      ↓
Human Approval if Required
      ↓
Supervisor Review
      ↓
Final Customer Response

🔀 Query Routing

The intent classifier assigns customer queries to supported categories such as:

  • Sales — Pricing, subscriptions, and product information
  • Technical — Login issues, crashes, errors, and installation problems
  • Billing — Invoices, refunds, and payments
  • Account — Passwords, profiles, and account-related requests
  • Memory — Questions involving previous customer conversations

LangGraph conditionally routes each request to the appropriate workflow.

🤖 Specialized Support Agents

💼 Sales Agent

Handles sales-related questions and uses relevant knowledge-base context to generate responses.

🛠️ Technical Agent

Handles technical issues and provides troubleshooting guidance using retrieved support information.

💳 Billing Agent

Handles billing-related questions such as invoices, refunds, and payments.

👤 Account Agent

Handles account-related questions involving passwords, profiles, and account information.

🧠 Memory Agent

Retrieves previous conversations for the specified customer from the SQLite database and uses that history to answer questions about earlier interactions.

📚 Retrieval-Augmented Generation

The support agents use a local knowledge base through a RAG pipeline.

The retrieval process:

  1. Loads text documents from the data/ directory.
  2. Splits documents into chunks using RecursiveCharacterTextSplitter.
  3. Generates embeddings using the local nomic-embed-text model through Ollama.
  4. Stores embeddings in Chroma.
  5. Performs similarity search for incoming customer queries.
  6. Retrieves relevant document chunks.
  7. Passes the retrieved context to the appropriate support agent.

This allows responses to be grounded in the project's available support knowledge base.

🧠 Conversation Memory

Customer conversations are stored in a local SQLite database.

Each conversation stores information such as:

  • Customer name
  • Customer query
  • Assistant response

When a customer asks about a previous interaction, the Memory Agent retrieves the customer's stored conversation history and uses it as context.

🛡️ Human-in-the-Loop Approval

Certain potentially high-risk requests trigger a human approval step.

Examples include requests involving:

  • Refunds
  • Subscription cancellation
  • Account closure
  • Compensation
  • Management or manager escalation

When a high-risk keyword is detected, the workflow requests explicit human approval before continuing.

The current implementation uses a simulated command-line approval prompt rather than an external support-management system.

👨‍💼 Supervisor Review

After a specialized support agent generates a response, the Supervisor Agent reviews it before the final response is returned.

The supervisor is responsible for:

  • Checking whether the response addresses the customer's question
  • Improving grammar when necessary
  • Keeping the response professional and polite
  • Preserving the original meaning
  • Producing the final customer-facing response

🔄 Complete Workflow

Customer Query
      ↓
Intent Classification
      ↓
Conditional Routing
      ↓
Specialized Agent
      ↓
RAG Retrieval
      ↓
Agent Response
      ↓
High-Risk Check
      ↓
Human Approval if Required
      ↓
Supervisor Review
      ↓
Final Response

Memory-related requests use stored customer conversation history through the Memory Agent.

🛠️ Technology Stack

Programming

  • Python

AI / LLM

  • LangChain
  • LangGraph
  • Ollama
  • Qwen3 8B
  • nomic-embed-text

Retrieval & Vector Search

  • Chroma
  • Ollama Embeddings
  • RecursiveCharacterTextSplitter

Database

  • SQLite

Application

  • Streamlit

Supporting Libraries

  • PyPDF
  • Sentence Transformers
  • ChromaDB
  • python-dotenv

📁 Project Structure

Customer-Support-Automation/
│
├── data/                  # Customer-support knowledge-base documents
├── vectorstore/           # Vector-store related project directory
├── app.py                 # Streamlit interface
├── database.py            # SQLite database initialization
├── graph.py               # LangGraph workflow and routing
├── human_loop.py          # High-risk human approval workflow
├── memory.py              # Conversation storage and retrieval
├── nodes.py               # Intent classifier and specialized agents
├── prompts.py             # Prompt definitions
├── rag.py                 # RAG and vector retrieval pipeline
├── state.py               # LangGraph shared state definition
├── supervisor.py          # Final response supervisor
├── memory.db              # SQLite conversation database
├── requirements.txt       # Python dependencies
└── .gitignore

🚀 Installation

1. Clone the Repository

git clone https://github.com/SurajGoyal13/Customer-Support-Automation.git
cd Customer-Support-Automation

2. Create a Virtual Environment

Windows

python -m venv .venv
.venv\Scripts\activate

macOS / Linux

python3 -m venv .venv
source .venv/bin/activate

3. Install Dependencies

pip install -r requirements.txt

4. Install Ollama

Install Ollama on your computer and make sure it is available from the command line.

Then download the models used by the project:

ollama pull qwen3:8b
ollama pull nomic-embed-text

Make sure Ollama is running before starting the application.

▶️ Running the Application

Start the Streamlit application:

streamlit run app.py

The application provides fields for:

  • Customer name
  • Customer query

After submitting a query, the interface displays the retrieved context, final response, department or intent, and whether human approval was required.

📚 Knowledge Base

The RAG pipeline expects text documents inside the data/ directory.

When the vector database does not already exist, the application creates it by:

  • Loading supported text documents from data/
  • Splitting them into chunks
  • Generating embeddings
  • Storing the resulting vectors in Chroma

The knowledge base can be updated by adding appropriate documents to the data/ directory and rebuilding the vector database when required.

⚠️ Limitations

  • The system uses a locally hosted Qwen3 8B model through Ollama.
  • Intent classification depends on the underlying LLM correctly selecting a supported intent.
  • The current human-approval workflow is a simulated command-line approval process.
  • High-risk detection uses predefined keywords.
  • Conversation memory is stored locally in SQLite rather than a production customer-support platform.
  • RAG response quality depends on the quality and coverage of the available knowledge-base documents.
  • The application does not directly integrate with external CRM, ticketing, payment, or customer-account systems.
  • No production authentication or authorization system is included.
  • The project is intended as a prototype and demonstration rather than a production customer-support platform.

🎯 Project Objective

The goal of this project is to demonstrate how modern AI application components can be combined into an automated customer-support workflow.

The project demonstrates:

  • LLM-based intent classification
  • Agent-based workflow orchestration
  • Conditional routing with LangGraph
  • Retrieval-Augmented Generation
  • Local vector search
  • Persistent conversation memory
  • Human-in-the-loop approval
  • Supervisor-based response refinement
  • Interactive Streamlit application development

🔮 Future Improvements

  • 🎫 Integrate with real ticketing systems
  • 💬 Add richer conversational memory
  • 🔐 Add authentication and role-based access
  • 🧑‍💼 Replace simulated approval with a web-based human-review interface
  • 📧 Add email-based support automation
  • 📊 Add support analytics and dashboards
  • 🔌 Integrate CRM and customer-account APIs
  • 🧠 Improve intent classification and routing
  • 📚 Support additional knowledge-base document formats
  • 🛡️ Add stronger validation and safety controls
  • 🧪 Add automated tests and evaluation datasets
  • 🚀 Deploy the system for production-style environments

👨‍💻 Author

Suraj Goyal

Computer Science Student · Python · AI/ML · Web Development · DSA


If you find this project useful, consider starring the repository.

About

AI-powered customer support automation using LangGraph, LangChain, RAG, Ollama, and SQLite.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages