Voice AI Customer Service Platform
Next-Generation Customer Support: Intelligent AI agents that seamlessly collaborate with human representatives to deliver exceptional customer experiences at scale.
|
|
|
|
- Real-time dashboard with live metrics
- Switch tracking and resolution analytics
- Performance monitoring and SLA tracking
- Complete audit trail of all interactions
- Socket.io powered real-time updates
| Backend | Node.js, Express, TypeScript |
| Frontend | React 18, Vite, TypeScript |
| Database | PostgreSQL + pgvector (vector embeddings) |
| Cache | Redis (sessions + real-time state) |
| ORM | Prisma (type-safe database access) |
| Real-time | Socket.io (WebSocket communication) |
| AI Services | Retell AI (voice), Google Gemini (chat/copilot) |
| Telephony | Telnyx (phone network integration) |
| Embeddings | OpenAI (RAG knowledge base) |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CUSTOMER LAYER β
β (Voice Calls + Text Chat) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββ΄ββββββββββββββββ
β β
βΌ βΌ
ββββββββββββββββββββ ββββββββββββββββββββ
β VOICE CHANNEL β β TEXT CHANNEL β
β β β β
β Telnyx Phone β β Chat Widget β
β Retell AI STT β β Gemini LLM β
β Retell AI TTS β β Context Memory β
ββββββββββ¬ββββββββββ ββββββββββ¬ββββββββββ
β β
ββββββββββββββββ¬ββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββ
β BACKEND CORE β
β (Node.js + Express) β
β β
β β’ Session Manager β
β β’ Switch Controller β
β β’ Copilot Engine β
β β’ RAG Knowledge Base β
β β’ Analytics Engine β
β β’ Webhook Handlers β
βββββββββββ¬βββββββββββββββββ
β
βββββββββββββββΌββββββββββββββ
β β β
βΌ βΌ βΌ
ββββββββββββ ββββββββββββ ββββββββββββ
βPostgreSQLβ β Redis β βSocket.io β
β+pgvector β β Sessions β βReal-time β
ββββββββββββ ββββββββββββ βββββββ¬βββββ
β
βΌ
ββββββββββββββββββββββββββββ
β AGENT DASHBOARD β
β (React SPA) β
β β
β β’ Live Transcript View β
β β’ AI Copilot Sidebar β
β β’ Queue Management β
β β’ Control Panel β
β β’ Analytics Dashboard β
ββββββββββββββββββββββββββββ
The approach to seamless handoffs:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CONFERENCE ROOM β
β β
β ββββββββββββ ββββββββββββ ββββββββββββ β
β β CUSTOMER β β AI AGENT β β HUMAN β β
β β β β β β REP β β
β β Always β β Muted/ β β Muted/ β β
β β Active β β Unmuted β β Unmuted β β
β ββββββββββββ ββββββββββββ ββββββββββββ β
β β
β SWITCH = Mute one participant, Unmute another β
β RESULT = Zero call drops, full context preserved β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Benefits:
- No call reconnection required
- No context loss during handoff
- Sub-second switching time
- Customer doesn't hear any interruption
- Scalable to multiple agents per call
- Node.js 18+ and npm 9+
- Docker Desktop (optional - for PostgreSQL + Redis)
- API Keys (see Environment Variables section)
# 1. Clone the repository
git clone <repository-url>
cd Senpilot-Customer-Service-App
# 2. Install dependencies
npm install
# 3. Set up environment variables
cp .env.example .env
# Edit .env with your API keys (see below)
# 4. Start the development servers
npm run devThe app will start with:
- Frontend: http://localhost:5173
- Backend: http://localhost:3001
- Storage: In-memory (works without Docker)
For persistent data storage and full analytics:
# Start PostgreSQL + Redis containers
docker-compose up -d
# Initialize the database
npm run db:generate
cd packages/database
export DATABASE_URL="postgresql://postgres:postgres@localhost:5433/customer_service?schema=public"
npx prisma migrate dev --name init
npx tsx src/seed.ts
cd ../..
# Start the app
npm run dev| URL | Description |
|---|---|
http://localhost:5173 |
Customer Demo (Chat + Voice) |
http://localhost:5173/agent |
Agent Dashboard |
http://localhost:3001/health |
Backend Health Check |
The platform includes 3 pre-built demo scenarios to showcase different use cases:
| Scenario | Description |
|---|---|
| π° High Bill Dispute | Customer frustrated about unexpectedly high bill |
| π¨ Report Gas Leak | Emergency situation requiring immediate escalation |
| π Setup New Service | New customer requesting service activation |
Click any scenario button in the Chat or Voice interface to start a pre-configured conversation.
Create a .env file in the project root. Copy from .env.example and fill in your values:
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# MINIMAL SETUP (Works without Docker)
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Server Configuration
PORT=3001
NODE_ENV=development
FRONTEND_URL=http://localhost:5173
# Database (Required - but app falls back to in-memory if unavailable)
DATABASE_URL="postgresql://postgres:postgres@localhost:5433/customer_service?schema=public"
REDIS_URL="redis://localhost:6379"
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# AI SERVICES (Add these for full functionality)
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Google Gemini - Powers text chat + AI copilot
# Get key at: https://makersuite.google.com/
GEMINI_API_KEY=your_gemini_api_key
# Retell AI - Powers voice calls
# Get key at: https://retellai.com
RETELL_API_KEY=your_retell_api_key
RETELL_AGENT_ID=your_retell_agent_id
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# OPTIONAL SERVICES (Enhanced features)
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Telnyx - Phone number integration
TELNYX_API_KEY=your_telnyx_api_key
TELNYX_CONNECTION_ID=your_connection_id
TELNYX_PHONE_NUMBER=+1234567890
# OpenAI - For RAG embeddings
OPENAI_API_KEY=your_openai_api_key
# Webhooks - For production deployments
WEBHOOK_BASE_URL=https://your-domain.comποΈ Retell AI (Voice Agent)
- Sign up at retellai.com
- Create a new agent in the dashboard
- Configure the agent:
- Model:
gpt-4o-miniorgpt-4 - Voice: Select from 11labs voices
- System prompt: Use utility customer service context
- Model:
- Copy your API key and Agent ID to
.env
Utility Voice Agent Setup:
# Use our automated setup script
curl -X POST http://localhost:3001/api/voice/agent/create-llm
# This creates an LLM with:
# - Utility-specialized system prompt
# - Emergency gas leak detection
# - Billing/outage/payment knowledge
# - Natural conversation flow㪠Google Gemini (Text Chat + Copilot)
- Get API key from Google AI Studio
- Add to
.env:GEMINI_API_KEY=your_key - The platform automatically uses Gemini for:
- Text chat responses (same personality as voice)
- Agent copilot suggestions
- Sentiment analysis
- Context-aware recommendations
No additional setup required - it works out of the box!
Telnyx (Optional - Phone Integration)
- Sign up at telnyx.com
- Purchase a phone number
- Create a TeXML application
- Set webhook URL:
https://your-domain/webhooks/telnyx - Assign phone number to application
- Add credentials to
.env
Note: Phone integration is optional. Voice calls also work via browser WebRTC.
customer-service-app/
βββ apps/
β βββ backend/ # Node.js API Server
β β βββ src/
β β βββ controllers/ # HTTP endpoints & webhooks
β β β βββ chatController.ts # Text chat API
β β β βββ voiceController.ts # Voice call management
β β β βββ switchController.ts # AIβHuman switching
β β β βββ retellController.ts # Retell webhooks
β β β βββ analyticsController.ts # Metrics & diagnostics
β β βββ services/
β β β βββ chat/ # Chat message processing
β β β βββ voice/ # Voice call handling
β β β βββ ai/ # Gemini LLM integration
β β β βββ copilot/ # AI copilot engine
β β β βββ state/ # Redis session management
β β β βββ analytics/ # Metrics aggregation
β β βββ sockets/
β β β βββ agentGateway.ts # Socket.io real-time events
β β βββ server.ts # Express + Socket.io server
β β
β βββ web-client/ # React Frontend
β βββ src/
β βββ components/
β β βββ agent-dashboard/ # Agent UI components
β β β βββ QueuePanel.tsx # Incoming requests queue
β β β βββ LiveTranscript.tsx # Real-time conversation
β β β βββ SidebarCopilot.tsx # AI suggestions panel
β β β βββ ChatReplyInput.tsx # Agent message input
β β β βββ ControlPanel.tsx # Switch/mute controls
β β βββ customer-widget/ # Customer-facing UI
β β β βββ ChatWindow.tsx # Text chat interface
β β β βββ CallButton.tsx # Voice call button
β β βββ shared/ # Reusable components
β βββ hooks/
β β βββ useCallState.ts # Call state + Socket.io
β β βββ useAgentQueue.ts # Queue management
β β βββ useChatSocket.ts # Chat real-time sync
β βββ pages/
β βββ AgentPortal.tsx # Main agent dashboard
β βββ CustomerDemo.tsx # Customer demo page
β
βββ packages/
β βββ database/ # Prisma ORM
β β βββ prisma/
β β β βββ schema.prisma # Database models
β β βββ src/
β β βββ index.ts # Prisma client
β β βββ seed.ts # Test data seeder
β β
β βββ shared-types/ # TypeScript Interfaces
β βββ src/
β βββ index.ts # Shared types across apps
β
βββ docker-compose.yml # PostgreSQL + Redis
βββ package.json # Monorepo workspace config
βββ .env # Environment variables
The command center for human representatives:
- ** Queue Panel** (Left): Live incoming requests with alerts
- ** Transcript View** (Center): Real-time conversation display
- ** Copilot Panel** (Right): AI suggestions and knowledge search
- ** Control Panel** (Bottom): Switch to/from AI, mute, hold, end
- ** Metrics Footer**: Active calls, resolution times, performance
Dual-channel customer interface:
- Text Chat: Instant messaging with AI/human agents
- Voice Call: Browser-based WebRTC voice calls
- Seamless Mode Switching: Toggle between chat and voice
- Status Indicators: AI vs Human agent, connection status
| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check with service status |
/api/chat |
POST | Send customer chat message |
/api/chat/respond |
POST | Human agent response |
/api/chat/switch |
POST | Switch between AI and human |
/api/voice/web-call |
POST | Create browser-based voice call |
/api/voice/agent |
GET | Get voice agent configuration |
/api/switch |
POST | AIβHuman handoff for voice |
/api/analytics/dashboard |
GET | Live dashboard metrics |
/api/analytics/switches |
GET | Switch analytics by timeframe |
/api/copilot/search |
POST | Search knowledge base |
Client β Server:
agent:join- Agent joins their roomcall:join- Subscribe to call updatescall:request_switch- Request AIβHuman switchchat:send_message- Agent sends chat messagequeue:subscribe- Subscribe to queue updatesmetrics:subscribe- Subscribe to live metrics
Server β Client:
transcript:update- New message in conversationcopilot:suggestion- AI suggestion for agentcall:state_update- Call mode changedqueue:add- New request in queuequeue:update- Queue item updatedmetrics:update- Dashboard metrics refresh
The platform tracks comprehensive analytics:
{
"overview": {
"totalCalls": 1547,
"activeCalls": 12,
"avgDuration": 245,
"totalSwitches": 289
},
"today": {
"calls": 87,
"switches": 23,
"avgDuration": 198
},
"modeDistribution": {
"aiResolved": 1094, // 70.8% AI resolution
"humanResolved": 312, // 20.2% human only
"mixed": 141 // 9.1% both
},
"switchMetrics": {
"avgSwitchTime": 1.2, // Seconds
"topReasons": {
"CUSTOMER_REQUEST": 152,
"COMPLEXITY": 89,
"ESCALATION": 48
}
}
}- Average handle time (AHT)
- First response time (FRT)
- Resolution rate by channel
- Agent utilization
- Customer satisfaction proxy metrics
- Emergency detection accuracy
| Scenario | Channel | Steps |
|---|---|---|
| Happy Path | Voice | Customer inquiry β AI resolves β Call ends |
| Escalation | Voice | Customer requests human β Switch β Human resolves |
| Emergency | Voice | Gas leak mentioned β Auto-escalate β Emergency team |
| Text Chat | Chat | Customer asks question β AI responds β Follow-up |
| Multi-switch | Both | AI β Human β AI β Human (stress test) |
# Backend API tests
cd apps/backend
npm test
# Frontend component tests
cd apps/web-client
npm test
# E2E tests (full flow)
npm run test:e2eOur specialized domain with pre-built knowledge:
- Billing inquiries: Explain charges, rate tiers, high bills
- Payment support: Set up payment plans, financial hardship
- Outage reporting: Status updates, estimated restoration
- Service changes: Start/stop/transfer service
- Emergency response: Gas leak detection and escalation
ROI: 70% AI resolution rate = ~$3M annual savings for 100-agent call center
- Order tracking and status updates
- Returns and refund processing
- Product recommendations
- VIP customer prioritization
- Inventory and shipping inquiries
- Appointment scheduling and reminders
- Insurance verification
- Prescription refills
- General health information (non-diagnosis)
- HIPAA-compliant audit trails
- Account balance and transaction inquiries
- Fraud detection and reporting
- Loan/mortgage application support
- Investment guidance escalation
- Compliance-ready conversation logs
- All API calls encrypted with TLS 1.3
- Database encryption at rest
- Redis session data encrypted
- PII data masked in logs
- Complete conversation transcripts stored
- Switch events logged with timestamps
- Agent actions tracked
- GDPR data deletion support
- Configurable data retention policies
- Agent authentication (planned)
- Role-based access control (planned)
- API key rotation support
- Rate limiting on public endpoints
Redis connection refused
The app automatically falls back to in-memory storage. You'll see:
Redis unavailable - using in-memory storage
(Start Redis with: docker-compose up -d)
For persistent sessions, start Docker:
docker-compose up -dDatabase connection failed
If you see Prisma errors about database connection:
- Option A: Start Docker for full database support:
docker-compose up -d npm run db:generate
- Option B: Continue without database (analytics will show mock data)
Voice calls not working
Voice calls require Retell AI configuration:
- Sign up at retellai.com
- Create a voice agent
- Add to
.env:RETELL_API_KEY=your_key RETELL_AGENT_ID=your_agent_id - Restart the server
Text chat shows basic responses
For AI-powered responses, add your Gemini API key:
- Get key from Google AI Studio
- Add to
.env:GEMINI_API_KEY=your_key - Restart the server
Port already in use
Kill existing processes:
# Kill backend (port 3001)
lsof -ti:3001 | xargs kill -9
# Kill frontend (port 5173)
lsof -ti:5173 | xargs kill -9
# Restart
npm run devThis project is licensed under the MIT License - see the LICENSE file for details.
- Retell AI - Voice AI platform
- Google Gemini - LLM for chat & copilot
- Telnyx - Telephony infrastructure
- OpenAI - Embeddings for RAG
- Prisma - Next-gen ORM