Contextual IT Support Chatbot powered by RAG, Pinecone, and ChatGPT
Get instant, accurate IT support answers from your knowledge base
CustomerChat is a full-stack IT support chatbot that provides contextual answers to user queries using Retrieval-Augmented Generation (RAG). It leverages semantic search with Pinecone vector database and generates human-like responses using OpenAI's GPT-4o-mini model. The system indexes your knowledge base articles into Pinecone vectors, allowing it to find the most relevant content based on semantic similarity rather than just keyword matching. When a user asks a question, the system retrieves the top matching articles and uses them as context for GPT-4 to generate accurate, domain-specific answers. Every response includes sentiment analysis to detect user frustration levels and tracks which knowledge base articles were used, giving transparency into how answers are generated. The modern chat interface built with Next.js provides a seamless experience where users can get instant IT support without waiting for human agents.
| Feature | Description |
|---|---|
| ๐ Semantic Search | Pinecone-powered vector similarity search for finding relevant KB articles |
| ๐ค RAG Pipeline | Combines retrieval + generation for accurate, context-rich answers |
| ๐ฌ Session Management | Persistent chat sessions with conversation history |
| ๐ Sentiment Analysis | Real-time detection of user frustration levels (0-1 score) |
| ๐ Source Tracking | Shows which KB articles were used for each answer |
| ๐ Markdown Support | Beautiful formatted responses with lists, code blocks, and bold text |
| ๐ Knowledge Base Indexing | Admin endpoint to re-index the entire knowledge base |
| ๐ก๏ธ Clean UI | Modern, responsive chat interface built with Next.js & Tailwind |
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Frontend (Next.js) โ
โ โ
โ Landing Page โโโโโโบ Chat Interface โโโโโโบ Side Panels โ
โ (Hero Section) (Real-time Chat) (Sentiment + Sources)โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โ HTTP
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Backend (FastAPI) โ
โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ
โ โ Sessions โ โ Messages โ โ Admin โ โ
โ โ Router โ โ Router โ โ Router โ โ
โ โโโโโโโโฌโโโโโโโ โโโโโโโโฌโโโโโโโ โโโโโโโโโโฌโโโโโโโโ โ
โ โ โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Services Layer โ โ
โ โ โ โ
โ โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ OpenAI โ โ Pinecone โ โ Sentiment โ โ โ
โ โ โ Service โ โ Service โ โ Service โ โ โ
โ โ โ (GPT-4 + โ โ (Vector โ โ (Keyword-based โ โ โ
โ โ โ Embeddings) โ โ Search) โ โ Detection) โ โ โ
โ โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ SQLite โ โ Pinecone โ โ OpenAI โ
โ Database โ โ Vector DB โ โ API โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
- Python 3.10+
- Node.js 18+
- OpenAI API key
- Pinecone API key
# Navigate to backend
cd backend
# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Configure environment
cp .env.example .env
# Edit .env with your OpenAI and Pinecone API keys# Run the ingestion script to index KB articles
python scripts/ingest_kb.py# Start FastAPI server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
# API docs available at: http://localhost:8000/docs# New terminal - navigate to frontend
cd frontend
# Install dependencies
npm install
# Configure environment
cp .env.local.example .env.local
# Start development server
npm run dev- Frontend: http://localhost:3000
- API Docs: http://localhost:8000/docs
POST /sessionsCreates a new chat session.
Response:
{
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"user_id": null,
"created_at": "2024-01-15T10:30:00"
}GET /sessions/{session_id}/messagesRetrieves all messages for a session.
POST /sessions/{session_id}/messagesBody:
{
"content": "How do I reset my VPN password?"
}Response:
{
"reply": "To reset your VPN password, follow these steps...",
"sentiment": "neutral",
"frustration_score": 0.5,
"sources": [
{
"ki_id": "123",
"title": "VPN Password Reset Guide",
"category": "vpn",
"snippet": "To reset your VPN password..."
}
]
}POST /admin/kb/reindexRe-ingests all KB articles into Pinecone.
GET /admin/kb/statsReturns database and Pinecone vector counts.
GET /healthResponse:
{
"status": "healthy",
"service": "CustomerChat API",
"version": "1.0.0"
}| Column | Type | Description |
|---|---|---|
| id | Integer | Primary key |
| session_id | String | Unique UUID |
| user_id | String | Optional user identifier |
| created_at | DateTime | Creation timestamp |
| Column | Type | Description |
|---|---|---|
| id | Integer | Primary key |
| session_id | Integer | FK to sessions |
| role | String | "user" or "assistant" |
| content | Text | Message content |
| sentiment | String | positive/neutral/negative |
| frustration_score | Float | 0-1 scale |
| sources | Text | JSON of used KB articles |
| timestamp | DateTime | Message timestamp |
| Column | Type | Description |
|---|---|---|
| id | Integer | Primary key |
| ki_id | String | Unique KB identifier |
| title | String | Article title |
| content | Text | Full article text |
| category | String | Topic category |
| tags | String | Optional tags |
| Technology | Purpose |
|---|---|
| FastAPI | REST API framework |
| SQLAlchemy | ORM for SQLite |
| Pinecone | Vector database for embeddings |
| OpenAI | GPT-4o-mini + text-embeddings-3-small |
| Uvicorn | ASGI server |
| Technology | Purpose |
|---|---|
| Next.js 14 | React framework with App Router |
| TypeScript | Type safety |
| Tailwind CSS | Styling |
| React Markdown | Markdown rendering |
| Lucide Icons | Icon library |
| Technology | Purpose |
|---|---|
| Pinecone | Vector similarity search |
| OpenAI API | LLM + embeddings |
| SQLite | Local database |
CustomerChat/
โโโ backend/
โ โโโ app/
โ โ โโโ main.py # FastAPI entry point
โ โ โโโ config.py # Environment config
โ โ โโโ database.py # SQLite setup
โ โ โโโ models.py # SQLAlchemy models
โ โ โโโ schemas.py # Pydantic schemas
โ โ โโโ routers/ # API endpoints
โ โ โ โโโ sessions.py # Chat sessions
โ โ โ โโโ admin.py # Admin operations
โ โ โโโ services/ # Business logic
โ โ โโโ openai_service.py
โ โ โโโ pinecone_service.py
โ โ โโโ sentiment_service.py
โ โโโ scripts/
โ โ โโโ ingest_kb.py # KB ingestion script
โ โโโ requirements.txt
โ โโโ .env.example
โโโ frontend/
โ โโโ src/
โ โ โโโ app/
โ โ โ โโโ page.tsx # Landing page
โ โ โ โโโ chat/page.tsx # Chat interface
โ โ โ โโโ layout.tsx
โ โ โโโ components/ # UI components
โ โ โโโ lib/ # API client
โ โ โโโ types/ # TypeScript types
โ โโโ package.json
โ โโโ tailwind.config.ts
โโโ Dataset/
โโโ synthetic_knowledge_items.csv
- Ingestion: KB articles are embedded using
text-embedding-3-smalland stored in Pinecone - Query: User message is embedded with the same model
- Retrieval: Pinecone finds top-5 similar articles using cosine similarity
- Generation: GPT-4o-mini generates answer using:
- System prompt (role: IT support assistant)
- Retrieved context (KB articles)
- Conversation history
- User message
- Response: Formatted answer returned with sentiment + sources
Built with โค๏ธ using FastAPI, Next.js, Pinecone & OpenAI