An AI-powered customer message processing pipeline that classifies messages, detects sentiment, and generates professional auto-replies — all in a single API call.
Features • Demo • Project Structure • Setup • Usage • Output • Contributing
Customer Support AI Pipeline is a lightweight NLP system built for automating the first layer of customer support. Given any incoming customer message, the system produces three structured outputs:
| Output | Description |
|---|---|
| Category | Classifies the message into one of 7 predefined support categories |
| Sentiment | Detects the emotional tone of the message |
| Auto-Reply | Generates a short, professional response tailored to the message |
All three outputs are produced in a single API call per message, making the pipeline fast and token-efficient.
- ⚡ Single API call per message returns all three outputs as structured JSON
- 🎯 7 classification categories covering the full range of customer support scenarios
- 💬 Context-aware auto-replies that match the tone and urgency of each message
- 🎨 Styled Jupyter output with color-coded category and sentiment badges
- 📊 CSV export of all processed results for reporting and analysis
- 🛡️ Robust error handling with safe fallback values if parsing fails
- 🆓 Fully free — runs on Cohere's free trial API tier
Complaint • Refund/Return • Sales Inquiry • Delivery Question
Account/Technical Issue • General Query • Spam
Positive • Neutral • Negative
The pipeline processes each message and renders a styled card in the Jupyter notebook:
Input Message:
"I ordered a laptop two weeks ago and it still hasn't arrived! This is absolutely unacceptable."
Output:
┌─────────────────────────────────────────────────────┐
│ CATEGORY Complaint │
│ SENTIMENT ❌ Negative │
│ AUTO-REPLY We sincerely apologize for the delay │
│ in your order. Our team is urgently │
│ looking into this and will update you │
│ within 24 hours. │
└─────────────────────────────────────────────────────┘
customer-support-ai-pipeline/
│
├── 📓 Customer_Support_AI.ipynb # Main notebook — run this
│
├── 🐍 config.py # API key, model name, category & sentiment labels
├── 🐍 processor.py # Core pipeline: prompt builder, Cohere API call, JSON parser
├── 🐍 demo_messages.py # 7 sample messages covering all categories
├── 🐍 display_utils.py # Styled HTML card renderer for Jupyter output
├── 🐍 generate_notebook.py # Script used to generate the .ipynb (already run)
│
├── 📄 requirements.txt # Python dependencies
├── 📄 README.md # Project documentation
├── 📄 CONTRIBUTORS.md # Contributor guidelines
└── 📄 LICENSE # MIT License
Customer Message
│
▼
┌─────────────────────────────────────────┐
│ processor.py │
│ │
│ 1. Build structured prompt │
│ (category list + sentiment list) │
│ │
│ 2. Call Cohere Chat API │
│ model: command-a-03-2025 │
│ │
│ 3. Parse JSON response │
│ { category, sentiment, auto_reply } │
└─────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ display_utils.py │
│ Render styled HTML card in Jupyter │
└─────────────────────────────────────────┘
│
▼
CSV Export → customer_support_results.csv
The prompt instructs the model to return a strict JSON object with exactly three keys. A regex-based parser handles edge cases where the model wraps output in markdown fences.
git clone https://github.com/whozahm3d/customer-support-ai.git
cd customer-support-aipip install cohere>=5.0.0Sign up at dashboard.cohere.com/api-keys — no credit card required.
Open config.py and replace the placeholder:
COHERE_API_KEY = "your-actual-api-key-here"jupyter notebook Customer_Support_AI.ipynbThen run Kernel → Restart & Run All.
from processor import CustomerMessageProcessor
processor = CustomerMessageProcessor()
result = processor.process("I still haven't received my refund after 10 days!")
print(result["category"]) # Refund/Return
print(result["sentiment"]) # Negative
print(result["auto_reply"]) # We apologize for the delay in processing...messages = [
"Where is my order? It's been 2 weeks!",
"Do you offer student discounts?",
"Thank you, the product is amazing!",
]
results = processor.process_batch(messages)
for r in results:
print(r["category"], "|", r["sentiment"])import csv
with open("results.csv", "w", newline="", encoding="utf-8") as f:
writer = csv.DictWriter(f, fieldnames=["id", "original_message", "category", "sentiment", "auto_reply"])
writer.writeheader()
for i, r in enumerate(results, 1):
writer.writerow({"id": i, **{k: r[k] for k in ["original_message", "category", "sentiment", "auto_reply"]}})Each message renders as a color-coded card with:
- 🏷️ Category badge — unique color per category
- 💭 Sentiment badge — green / yellow / red
- 💬 Auto-reply box — blue-accented professional response
| id | original_message | category | sentiment | auto_reply | status |
|---|---|---|---|---|---|
| 1 | I ordered a laptop... | Complaint | Negative | We sincerely apologize... | success |
| 2 | I'd like to return... | Refund/Return | Neutral | Thank you for reaching... | success |
| 3 | Do you have discounts... | Sales Inquiry | Positive | We'd love to help you... | success |
| Tool | Purpose |
|---|---|
| Python 3.8+ | Core language |
Cohere API (command-a-03-2025) |
LLM for classification, sentiment & reply generation |
| Jupyter Notebook | Interactive execution environment |
| IPython Display | HTML card rendering inside notebook |
| CSV module | Results export |
cohere>=5.0.0No heavy ML frameworks required. The entire pipeline runs on a single lightweight API dependency.
- Streamlit web interface for non-technical users
- Support for multilingual customer messages
- Confidence scores for category predictions
- Integration with email/helpdesk platforms (Zendesk, Freshdesk)
- Fine-tuned model on domain-specific support data
- Real-time processing via webhook
We welcome contributions from the community! Whether you're fixing bugs, adding features, or improving documentation, your help is valued.
- Fork the repository
- Clone your fork:
git clone https://github.com/YOUR-USERNAME/customer-support-ai.git - Create a branch:
git checkout -b feature/your-feature-name - Make your changes and test thoroughly
- Commit with clear messages:
git commit -m "feat: Add your feature" - Push to your fork:
git push origin feature/your-feature-name - Open a Pull Request with a description of your changes
For detailed guidelines, please see CONTRIBUTORS.md.
- 🐛 Bug fixes — Found an issue? Help fix it!
- ✨ Features — Have a great idea? Implement it!
- 📚 Documentation — Improve README or add examples
- 🧪 Tests — Add test cases
- ⚡ Optimization — Improve performance
- 🎨 UI/UX — Enhance styling and display
This project was developed with invaluable support from:
- Claude AI (Anthropic) — Code generation, architecture design, documentation, testing & debugging
- Cohere — Powerful language model API and free tier access
Ali — BS Data Science, FAST NUCES Lahore
- GitHub: @whozahm3d
This project is licensed under the MIT License — see the LICENSE file for details.