Self-hosted, WhatsApp-first AI customer support agent with full data sovereignty.
ODW Desk is a production-ready, self-hosted AI customer support platform that keeps all conversation data within your infrastructure while delivering intelligent, context-aware responses grounded in your organization's knowledge base.
Unlike cloud-based solutions that send customer data to third-party APIs, Desk maintains complete data sovereignty—ideal for regulated industries (healthcare, legal, fintech, government) where compliance and privacy are non-negotiable.
- PII Shield: Automatic detection and redaction of sensitive information (names, phones, emails, SSN, credit cards, medical IDs)
- Model Router: Intelligent routing between local models (Ollama/vLLM) and frontier models (OpenAI/Anthropic) based on PII presence and complexity
- Vault Integration: RAG-powered responses grounded in your organization's knowledge base
- Confidence Scoring: Multi-factor confidence assessment with automatic escalation to human agents
- Brand Persona: Configurable brand voice, tone, and vocabulary guidelines injected into AI responses
- Response Policies: Pre/post-generation guardrails for compliance and content control
- WhatsApp Business API: Full support for Meta's official WhatsApp Business Platform
- Extensible Architecture: Plugin system ready for Telegram, Discord, Slack, Signal, and iMessage adapters
- Real-time Updates: WebSocket-based live conversation monitoring for agents
- Agent Inbox: REST API for conversation management, takeover, and response composition
- Real-time Dashboard: WebSocket connections for live conversation monitoring
- AI Feedback: Thumbs up/down feedback on AI responses for continuous improvement
- Escalation Workflow: Seamless handoff from AI to human agents with full context
- GDPR Ready: Data export (Article 20) and deletion (Article 17) workflows
- Tamper-Evident Audit: Hash-chained audit log for all system actions
- Data Retention: Configurable retention policies with automatic enforcement
- License Management: Tier-based feature gating (Free/Paid/Enterprise)
- Docker Deployment: Multi-stage production Dockerfile with health checks
- Kubernetes Native: Helm charts with configurable values for scaling
- CI/CD Pipeline: GitHub Actions workflow with lint, test, and build stages
- Observability: 25+ Prometheus metrics across all system components
- Graceful Degradation: System continues operating when external services (LLM, Vault) are unavailable
┌─────────────────┐
│ WhatsApp API │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Channel Gateway │◄──── Other Channels (Telegram, Discord, etc.)
└────────┬────────┘
│
▼
┌─────────────────┐
│ Message Router │──── Customer Resolution
└────────┬────────┘
│
▼
┌─────────────────┐
│ Conversation │◄──── State Machine (new → active → escalated → resolved)
│ Manager │
└────────┬────────┘
│
▼
┌─────────────────────────────────────────┐
│ AI Engine Orchestrator │
├─────────────────────────────────────────┤
│ 1. PII Shield (detect & redact) │
│ 2. Model Router (local vs frontier) │
│ 3. Vault Client (knowledge retrieval) │
│ 4. Prompt Builder (persona + context) │
│ 5. LLM Inference (Ollama/OpenAI) │
│ 6. Confidence Scorer (escalation) │
│ 7. Policy Engine (guardrails) │
└────────┬────────────────────────────────┘
│
▼
┌─────────────────┐
│ Outbound │──── WhatsApp Response / Agent Notification
│ Dispatcher │
└─────────────────┘
| Component | Responsibility | Technology |
|---|---|---|
| Channel Gateway | Inbound/outbound message handling | FastAPI, WebSockets |
| Message Router | Customer resolution, context loading | SQLAlchemy, Redis |
| Conversation Manager | State machine, message persistence | PostgreSQL, async/await |
| AI Engine | Full RAG pipeline orchestration | Presidio, LangChain |
| PII Shield | PII detection and redaction | Presidio Analyzer |
| Model Router | Local/frontier model selection | Complexity scoring |
| Vault Client | Knowledge base retrieval | HTTP, Redis cache |
| Agent Inbox | Human agent interface | REST API, WebSocket |
| Compliance Engine | GDPR workflows, audit trails | Hash-chained logging |
| License Manager | Feature gating, tier enforcement | Database-backed |
- Python 3.14+
- PostgreSQL 16+
- Redis 7+
- (Optional) Ollama or vLLM for local LLM inference
- (Optional) ODW.ai Vault for knowledge base
- Clone the repository
git clone https://github.com/OnDemandWorld/odw-desk.git
cd odw-desk- Create 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 configuration- Initialize database
alembic upgrade head- Start the application
uvicorn desk.main:app --host 0.0.0.0 --port 8000 --reload# Build the image
docker build -t odw-desk:latest .
# Run with Docker Compose (includes PostgreSQL and Redis)
docker-compose -f docker-compose.dev.yml up -d# Add Helm repository
helm repo add odw-desk ./k8s/helm
# Install with custom values
helm install desk odw-desk -f values-production.yamlAll configuration is managed through environment variables. See .env.example for complete reference.
# Database
DATABASE_URL=postgresql+asyncpg://user:pass@localhost:5432/desk
# Redis
REDIS_URL=redis://localhost:6379/0
# WhatsApp Business API
WHATSAPP_ACCESS_TOKEN=your_token
WHATSAPP_PHONE_NUMBER_ID=your_phone_id
WHATSAPP_WEBHOOK_VERIFY_TOKEN=your_verify_token
# AI Models
OLLAMA_ENDPOINT=http://localhost:11434
LOCAL_MODEL_NAME=llama-3.1-8b
LOCAL_MODEL_ENABLED=true
# Optional: Frontier Models
FRONTIER_ENABLED=false
FRONTIER_PROVIDER=openai # or anthropic
FRONTIER_API_KEY=your_key
FRONTIER_MODEL_NAME=gpt-4o-mini
# Vault Integration
VAULT_URL=http://localhost:8100
VAULT_API_KEY=your_vault_key
VAULT_COLLECTION_ID=your_collection_id
# Security
SECRET_KEY=your_secret_key_min_32_charsOnce running, access the interactive API documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
POST /api/v1/webhooks/whatsapp
Receives incoming WhatsApp messages from Meta.
GET /api/v1/agents/conversations
GET /api/v1/agents/conversations/{id}
POST /api/v1/agents/conversations/{id}/takeover
POST /api/v1/agents/conversations/{id}/respond
POST /api/v1/agents/conversations/{id}/resolve
GET /api/v1/admin/setup/status
POST /api/v1/admin/setup/vault
POST /api/v1/admin/setup/whatsapp
GET /api/v1/admin/personas
GET /api/v1/admin/policies
GET /api/v1/admin/compliance/audit-logs
POST /api/v1/admin/compliance/export
POST /api/v1/admin/compliance/delete
WS /ws/agents/{agent_id}
Real-time conversation updates for agents.
desk/
├── src/desk/
│ ├── ai/ # AI Intelligence Pipeline
│ │ ├── engine.py # Main orchestrator
│ │ ├── pii_shield.py # PII detection & redaction
│ │ ├── model_router.py # Model selection logic
│ │ ├── vault_client.py # Knowledge retrieval
│ │ ├── prompt_builder.py # Prompt composition
│ │ ├── confidence_scorer.py
│ │ └── providers/ # LLM provider implementations
│ │ ├── ollama.py
│ │ └── openai.py
│ ├── agents/ # Human agent interfaces
│ │ ├── inbox_api.py # REST API
│ │ └── websocket.py # Real-time updates
│ ├── admin/ # Admin & configuration APIs
│ │ ├── api.py
│ │ └── persona_policy_api.py
│ ├── channels/ # Channel adapters
│ │ ├── base.py # Abstract adapter interface
│ │ ├── whatsapp_business.py
│ │ ├── manager.py
│ │ └── outbound.py
│ ├── conversations/ # Conversation management
│ │ ├── manager.py
│ │ └── state_machine.py
│ ├── compliance/ # GDPR & audit
│ │ └── engine.py
│ ├── license/ # License management
│ │ └── manager.py
│ ├── persona/ # Brand persona
│ │ ├── service.py
│ │ └── integration.py
│ ├── policy/ # Response policies
│ │ └── engine.py
│ ├── observability/ # Metrics & monitoring
│ │ └── metrics.py
│ ├── models/ # SQLAlchemy models
│ ├── events/ # Event bus (Redis Streams)
│ └── utils/ # Utilities
├── tests/
│ ├── integration/ # Integration tests
│ └── e2e/ # End-to-end tests
├── alembic/ # Database migrations
├── k8s/helm/ # Kubernetes Helm charts
└── .github/workflows/ # CI/CD pipeline
# Integration tests
pytest tests/integration/ -v
# End-to-end tests (requires running application)
pytest tests/e2e/ -v
# With coverage
pytest --cov=desk --cov-report=html# Linting
ruff check src/desk/
# Auto-fix linting issues
ruff check src/desk/ --fix
# Type checking
mypy src/desk/
# Formatting
black src/desk/
isort src/desk/- Set
ENVIRONMENT=production - Configure strong
SECRET_KEY(32+ chars) - Set up PostgreSQL with SSL
- Configure Redis with authentication
- Set
WHATSAPP_ACCESS_TOKENand related credentials - Configure Vault connection (if using knowledge base)
- Set up LLM provider (Ollama or frontier model)
- Configure monitoring/alerting
- Set up backup strategy for PostgreSQL
- Review and configure data retention policies
- Activate appropriate license tier
- Horizontal Scaling: Deploy multiple API instances behind load balancer
- Database: Use connection pooling (configured via
DATABASE_POOL_SIZE) - Redis: Cluster mode for high availability
- Worker Processes: Adjust uvicorn workers based on CPU cores
- Async Architecture: All I/O operations are non-blocking
Desk exposes 25+ metrics at /metrics endpoint:
desk_messages_received_total- Inbound message countdesk_ai_pipeline_duration_seconds- AI processing timedesk_pii_detected_total- PII detection eventsdesk_llm_requests_total- LLM API callsdesk_confidence_scores- Confidence distributiondesk_escalations_total- Human escalationsdesk_active_conversations- Current conversation countdesk_online_agents- Agent availability
# Application health
curl http://localhost:8000/health
# Returns:
{
"status": "healthy",
"version": "1.0.0",
"components": {
"database": "healthy",
"redis": "healthy",
"event_bus": "healthy"
}
}- All conversation data stored in your PostgreSQL instance
- PII detection prevents sensitive data from reaching external APIs
- Configurable routing: force local-only processing when PII detected
- Encrypted API keys at rest (AES-256-GCM)
- GDPR Article 20: Data export in JSON/CSV format
- GDPR Article 17: Right to erasure with audit trail
- Audit Logging: Tamper-evident hash-chained logs
- Data Retention: Automatic enforcement of retention policies
- License-based feature gating
- Agent role management
- API authentication (configurable)
- Webhook signature verification (HMAC-SHA256)
Database connection failed
# Check PostgreSQL is running
pg_isready -h localhost -p 5432
# Verify DATABASE_URL in .envRedis connection failed
# Check Redis is running
redis-cli ping
# Verify REDIS_URL in .envWhatsApp webhook not receiving messages
# Verify webhook URL is publicly accessible
# Check WhatsApp Business API configuration in Meta Business Suite
# Verify WHATSAPP_WEBHOOK_VERIFY_TOKEN matches Meta configurationLLM inference slow or failing
# Check Ollama is running
curl http://localhost:11434/api/tags
# Verify model is downloaded
ollama list
# Check logs for errorsAll logs use structured format (JSON) via structlog:
# View application logs
tail -f logs/desk.log
# Filter by level
grep '"level": "error"' logs/desk.logContributions welcome! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Make changes and add tests
- Ensure all tests pass and linting is clean
- Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
This repository is built to be extended with AI coding agents. Rather than a turnkey product, ODW Desk is a working, well-structured codebase you can clone and adapt to your own needs with an agent like Claude Code. The repo includes agent context files (e.g. CLAUDE.md) and clear architecture docs so an agent can quickly understand the structure and help you customise, integrate, and extend it. To get started: clone the repo, open it with your coding agent, point it at this README and the docs, and describe what you want to build.
This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation: See DEVELOPMENT.md for detailed technical documentation
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- ✅ WhatsApp Business API integration
- ✅ Full AI intelligence pipeline
- ✅ Human agent interfaces
- ✅ Compliance framework
- ✅ Production deployment infrastructure
- 🔜 Telegram Bot Adapter
- 🔜 Discord Bot Adapter
- 🔜 Slack App Adapter
- 🔜 Signal Messenger Adapter
- 🔜 iMessage Bridge Adapter
- 🔜 Advanced persona versioning
- 🔜 Intent classifier integration
Built with:
- FastAPI - Modern web framework
- SQLAlchemy - Database ORM
- Presidio - PII detection
- LangChain - LLM orchestration
- Redis - Event bus and caching
- PostgreSQL - Primary database
Made with ❤️ for organizations that value data sovereignty