A RAG-based AI customer support agent built with Azure OpenAI and ChromaDB. It includes a FastAPI backend, a Next.js UI, and chat + voice workflows with agentic account actions.
LankaTel is a conceptual internet service provider in Sri Lanka. This project is its AI support product: a complete customer support stack with a RAG knowledge brain, action-ready backend, and a modern UI. It ships with realistic telecom knowledge, supports chat and voice, and can handle guided workflows like ticket creation or service changes. Use it as a drop-in reference only.
- Retrieval-augmented generation with source citations
- Azure OpenAI chat and embedding deployments
- ChromaDB local vector store with persistence
- Token-aware chunking with tiktoken
- CLI for ingest, query, chat, voice, and realtime voice
- FastAPI backend API for the UI and external clients
- Next.js UI with chat, voice, tools, and admin console
- Agentic actions (tickets, subscriptions, balance) backed by MySQL
- OTP verification with a shared session across chat + voice
- Quick actions panel in chat and voice once verified
- Voice UI (browser STT + backend Azure TTS) and realtime CLI voice (Azure Speech)
- Single-container Docker image with nginx reverse proxy
- Azure OpenAI (GPT-4o-mini, text-embedding-3-large)
- ChromaDB vector store
- tiktoken for chunking
- Python 3.10+, FastAPI, Uvicorn
- Pydantic v2 for validation
- SQLAlchemy + PyMySQL for DB access
- Next.js 16, React 19, TypeScript
- Tailwind CSS, PostCSS
- MySQL 8.x (actions, sessions, admin data)
- Browser Web Speech API (UI STT)
- Azure Speech Services (backend TTS + CLI realtime STT/TTS)
- Zoho Mail SMTP for OTP/notifications
- Cloudflare as DNS provider and security layer
- Docker + nginx (single-container)
- pytest, ESLint, Prettier
[Next.js UI] --> /api --> [FastAPI backend]
|-> [RAG pipeline] -> [ChromaDB]
|-> [Azure OpenAI]
|-> [MySQL] (actions, sessions, admin)
|-> [Azure Speech] (voice + TTS)
Customer-Support-Agent/
api_server.py # FastAPI backend
src/ # Core pipeline, services, realtime voice
ui/ # Next.js frontend
data/
raw/ # Raw JSONL knowledge files
processed/ # Generated KB (gitignored)
db/ # MySQL schema + seed data
docker/ # Nginx + container entrypoint
scripts/ # Utilities (KB build, quota check)
tests/ # Pytest suite
vectorstore/ # ChromaDB persistence (gitignored)
- Python 3.10+
- Node.js 18+ (for the UI)
- Azure OpenAI deployments:
chat-model(GPT-4o-mini)embedding-model(text-embedding-3-large)
- Optional: MySQL 8.x for actions/admin data
- Optional: Azure Speech for voice features
-
Create a virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Configure environment
cp .env.example .env # Edit .env with your Azure OpenAI credentials -
(Optional) Initialize MySQL data
mysql -u root -p < db/mysql_schema.sqlThis creates the
lankatel_demodatabase. PointDB_URLto it in.env. -
Test configuration
python -m src.cli test
-
Ingest documents
# Ingest the bundled Lankatel data (auto-builds a processed KB) python -m src.cli ingest data/raw/lankatel # Ingest a directory of documents python -m src.cli ingest data/documents/ --recursive
-
Ask questions
python -m src.cli query "How do I reset my password?" python -m src.cli query "What is my plan balance?" --stream
-
Interactive chat
python -m src.cli chat
-
Voice modes (optional)
python -m src.cli voice-chat python -m src.cli realtime
-
Start the backend
python api_server.py
-
Start the UI
cd ui cp .env.example .env.local npm install npm run dev
The UI will be available at http://localhost:3000 and the backend at http://localhost:8000.
- Account actions require OTP verification (mobile number → code).
- A verified session is shared across chat and voice in the UI.
- Once verified, a quick actions panel appears with account shortcuts.
- Action execution is done on non-streaming chat responses to keep tool calls deterministic.
- STT: Browser Web Speech API
- TTS: Backend
/api/tts(Azure Speech) - Supports agentic actions and OTP verification via voice
voice-chat: turn-based speech with Azure Speechrealtime: low-latency full-duplex voice with barge-in
| Command | Description |
|---|---|
ingest <path> |
Ingest documents from file or directory |
query <question> |
Ask a single question |
chat |
Start interactive chat session |
voice-chat |
Start turn-based voice chat |
realtime |
Start realtime full-duplex voice chat |
stats |
Show system statistics |
test |
Test system configuration |
clear |
Clear the vector store |
Supported input formats:
| Format | Extension | Description |
|---|---|---|
| Text | .txt |
Plain text files |
| Markdown | .md |
Markdown documents |
| JSON | .json |
JSON with text or content field |
| JSON Lines | .jsonl |
One JSON object per line |
JSONL example:
{"id": "faq_001", "question": "How do I reset my password?", "answer": "Click 'Forgot Password'...", "category": "account"}
{"id": "faq_002", "question": "What payment methods?", "answer": "We accept Visa, MasterCard...", "category": "billing"}To normalize the bundled Lankatel data manually:
python scripts/build_processed_kb.pyAll configuration is done via environment variables. See .env.example and ui/.env.example for the full list. Common settings:
# Azure OpenAI
AZURE_OPENAI_API_KEY=...
AZURE_OPENAI_ENDPOINT=...
AZURE_OPENAI_CHAT_DEPLOYMENT=chat-model
AZURE_OPENAI_EMBEDDING_DEPLOYMENT=embedding-model
# Vector store
VECTORSTORE_DIR=./vectorstore
VECTORSTORE_COLLECTION=support_docs
# Optional services
DB_URL=mysql+pymysql://user:password@localhost/lankatel_demo
AZURE_SPEECH_API_KEY=...
AZURE_SPEECH_REGION=eastus
# Email (Zoho SMTP)
EMAIL_ENABLED=true
EMAIL_SMTP_HOST=smtp.zoho.com
EMAIL_SMTP_PORT=587
EMAIL_SMTP_USERNAME=...
EMAIL_SMTP_PASSWORD=...
EMAIL_SENDER=...
EMAIL_USE_TLS=true
# Admin console
ADMIN_USERNAME=ltadmin
ADMIN_PASSWORD=change_me_strong
ADMIN_SECRET=change_me_secretCloudflare is used at the DNS and security layer during deployment; no app-level configuration is required.
pytest tests/ -vThis repository includes a Dockerfile that builds the Next.js UI and packages the Python backend into a single container. Nginx is used inside the container to reverse-proxy:
- Requests under
/api/are forwarded to the Python backend (uvicorn) on port8000 - All other requests are forwarded to the Next.js server on port
3000
Build and run locally:
docker build -t customer-support-agent:latest .
docker run -p 80:80 customer-support-agent:latestNotes on Azure deployment:
- Push the image to a container registry (ACR or Docker Hub) and point your Azure Web App for Containers or Azure Container Instance to the image.
- Azure expects a single HTTP port (80) to be served by the container; the image exposes port 80 and uses nginx as the entrypoint.
Contributions are welcome. Please open a PR with a clear description of the change.
MIT. See LICENSE.
- LangChain for RAG patterns
- ChromaDB for vector storage
- Azure OpenAI for LLMs and embeddings