An AI-powered customer service training simulation platform that helps Customer Service Representatives (CSRs) practice and improve their skills through realistic conversations with AI-powered customer personas.
CSR Trainer Bot provides an interactive learning environment where trainees can:
- Practice conversations with different customer personality types
- Receive real-time AI responses based on customer personas
- Get detailed performance analysis and feedback
- Learn from mistakes and improve customer service skills
- Angry Customer: Frustrated and demanding, needs empathy and quick resolution
- Confused Customer: Needs clear, patient explanation and guidance
- Technical Customer: Tech-savvy, expects detailed and accurate information
- Polite Customer: Courteous and patient, deserves warm assistance
- Impatient Customer: In a hurry, needs quick and direct solutions
- Real-time conversation with AI-powered customer responses
- Natural, context-aware replies based on conversation history
- Turn-by-turn interaction mimicking real customer service scenarios
- Overall performance score (0-10 scale)
- Inline feedback on each CSR message
- Identification of effective and problematic responses
- Key learning points and improvement suggestions
- Detailed performance summary
- Beautiful, responsive design
- Smooth animations and transitions
- Mobile-friendly interface
- Intuitive navigation
- Real-time feedback display
csr-trainer-bot/
βββ backend/
β βββ main.py # FastAPI application entry point
β βββ routers/
β β βββ chat.py # Chat endpoint handlers
β β βββ analyze.py # Analysis endpoint handlers
β βββ schemas/
β β βββ common.py # Shared Pydantic models
β β βββ chat.py # Chat request/response schemas
β β βββ analyze.py # Analysis request/response schemas
β βββ services/
β β βββ model.py # AI model service (replaceable)
β β βββ analyzer.py # Chat analysis service
β βββ utils/
β βββ fileio.py # JSON file operations
β βββ logger.py # Logging configuration
β βββ persona_cache.py # Persona caching
βββ storage/
β βββ chat_sessions.json # Session storage
β βββ personas.json # Persona configurations
βββ frontend/
β βββ index.html # Main HTML structure
β βββ styles.css # Styling and responsive design
β βββ script.js # Main application logic
β βββ api.js # API communication layer
β βββ consts.js # Configuration and constants
βββ README.md # This file
βββ .gitignore # Git ignore rules
βββ LICENSE # MIT License
- Python 3.8 or higher
- pip (Python package manager)
- Modern web browser (Chrome, Firefox, Safari, Edge)
-
Clone the repository
git clone <repository-url> cd csr-trainer-bot
-
Install Python dependencies
pip install fastapi uvicorn pydantic
-
Initialize storage Storage files will be automatically created on first run.
-
Start the backend server
cd backend python main.pyOr using uvicorn directly:
uvicorn main:app --reload --host 0.0.0.0 --port 8000
-
Access the application Open your browser and navigate to:
http://localhost:8000 -
Start training!
- Select a customer persona
- Click "Start Chat Session"
- Practice your customer service skills
- Click "End Chat" when done
- Click "Analyze Chat" to see your performance
Edit frontend/consts.js to configure API settings:
const API_CONFIG = {
BASE_URL: 'http://localhost:8000/api',
TIMEOUT: 30000
};Enable demo mode for offline testing (no backend required):
const DEMO_MODE = {
ENABLED: true, // Set to true for demo mode
MOCK_DELAY: 1500
};Edit storage/personas.json to add or modify personas:
{
"custom": {
"name": "Custom Persona",
"description": "Description here",
"icon": "π",
"traits": ["trait1", "trait2"],
"tips": "Tips for handling this persona"
}
}The current implementation uses a rule-based system for generating customer responses. You can easily replace it with:
-
Install the Hugging Face client:
pip install huggingface_hub
-
Set your API token:
export HF_TOKEN=your_token_here -
Modify
backend/services/model.pyto use theget_llm_responsefunction
-
Install the OpenAI client:
pip install openai
-
Set your API key:
export OPENAI_API_KEY=your_key_here -
Implement OpenAI integration in
backend/services/model.py
Use llama.cpp, Ollama, or similar tools to run models locally:
pip install llama-cpp-pythonSend a chat message and receive AI response.
Request:
{
"session_id": "uuid",
"persona": "angry",
"chat_history": [...]
}Response:
{
"session_id": "uuid",
"message": {
"sender": "customer",
"text": "Response text",
"timestamp": 1234567890
},
"success": true
}Analyze a completed chat session.
Request:
{
"session_id": "uuid",
"persona": "angry",
"chat_history": [...],
"ground_truth": "optional context"
}Response:
{
"session_id": "uuid",
"score": 7.5,
"inline_feedback": [...],
"good_responses": [...],
"bad_responses": [...],
"learning_points": [...],
"summary": "Performance summary",
"ground_truth_revealed": "Persona details",
"success": true
}Run the server and access from other devices on your network:
uvicorn main:app --host 0.0.0.0 --port 8000Access via: http://<your-ip>:8000
Backend (Hugging Face Spaces, Railway, Render, etc.):
- Push your code to GitHub
- Connect your repository to the platform
- Set environment variables
- Deploy!
Frontend (GitHub Pages, Netlify, Vercel):
- Update API_CONFIG.BASE_URL in
consts.js - Deploy the
frontendfolder - Configure CORS on backend
Create a Dockerfile:
FROM python:3.9-slim
WORKDIR /app
COPY backend/ ./backend/
COPY frontend/ ./frontend/
COPY storage/ ./storage/
RUN pip install fastapi uvicorn pydantic
EXPOSE 8000
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000"]Build and run:
docker build -t csr-trainer-bot .
docker run -p 8000:8000 csr-trainer-bot- Test each persona type
- Try different conversation lengths
- Test edge cases (empty messages, very long messages)
- Verify analysis accuracy
Add pytest tests in backend/tests/:
pip install pytest
pytest backend/tests/Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with FastAPI
- UI inspired by modern chat interfaces
- Designed for educational purposes
For issues, questions, or suggestions:
- Open an issue on GitHub
- Check existing documentation
- Review the code comments
- Add more persona types
- Implement voice chat simulation
- Add multi-language support
- Create admin dashboard for trainers
- Add progress tracking over time
- Implement team leaderboards
- Export analysis reports as PDF
- Add video tutorials
- For faster responses: Use local LLM or cached responses
- For better analysis: Fine-tune the analyzer prompts
- For scalability: Use Redis for session storage
- For production: Add rate limiting and authentication
- This is a training tool, not production-ready
- Add authentication before deploying publicly
- Sanitize user inputs
- Use environment variables for secrets
- Enable HTTPS in production
- Implement rate limiting
Built with β€οΈ for customer service excellence