Production-grade WhatsApp AI Agent built using:
- Spring Boot 3
- Ollama (Local LLM – FREE)
- MySQL
- Redis
- Qdrant (Vector DB)
- Docker
- Prometheus + Grafana
┌─────────────────────────┐
│ WhatsApp User │
└────────────┬────────────┘
│
▼
┌─────────────────────────┐
│ Meta WhatsApp Cloud │
│ (Free Tier) │
└────────────┬────────────┘
│ Webhook
▼
┌────────────────────────────────────────────────────────────────┐
│ ai-whatsapp-agent-service │
│ │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ Webhook Controller │ │
│ └──────────────────────────┬───────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ Agent Service │ │
│ │ │ │
│ │ 1. Rate Limiting │ │
│ │ 2. Load Memory (Redis + MySQL) │ │
│ │ 3. Tool Detection │ │
│ │ 4. RAG Search │ │
│ │ 5. Prompt Builder │ │
│ │ 6. LLM Call (Ollama) │ │
│ │ 7. Save Conversation │ │
│ └───────────────┬───────────────┬─────────────────────────┘ │
│ │ │ │
│ ▼ ▼ │
│ ┌─────────────┐ ┌───────────────┐ │
│ │ Redis │ │ MySQL │ │
│ │ Short-Term │ │ Long-Term DB │ │
│ └─────────────┘ └───────────────┘ │
│ │
│ ▼ │
│ ┌──────────────────────────┐ │
│ │ Qdrant │ │
│ │ (Vector Search) │ │
│ └──────────────────────────┘ │
│ │
│ ▼ │
│ ┌──────────────────────────┐ │
│ │ Ollama │ │
│ │ (Llama3 Model) │ │
│ └──────────────────────────┘ │
│ │
│ ▼ │
│ ┌──────────────────────────┐ │
│ │ WhatsApp Send API │ │
│ └──────────────────────────┘ │
└────────────────────────────────────────────────────────────────┘- WhatsApp Webhook Integration
- Local LLM (Ollama – llama3)
- RAG (Retrieval Augmented Generation)
- Tool Calling (Inventory, FAQ, Orders)
- Redis Short-Term Memory
- MySQL Persistent Memory
- Rate Limiting (Bucket4j)
- Structured Logging
- Global Exception Handling
- Monitoring with Prometheus
- Dockerized Deployment
ai-whatsapp-agent-service/
│
├── controller/
├── service/
├── llm/
├── rag/
├── repository/
├── model/
├── config/
├── exception/
├── monitoring/
│
├── docker-compose.yml
├── Dockerfile
├── pom.xml
└── README.mddocker compose up -dServices started:
- MySQL
- Redis
- Qdrant
- Ollama
docker exec -it ollama ollama pull llama3
docker exec -it ollama ollama pull nomic-embed-text-
Create Meta Developer Account
-
Add WhatsApp product
-
Get:
- Phone Number ID
- Access Token
-
Set Webhook URL:
ngrok http 8080Use generated HTTPS URL as webhook.
User Message
↓
Webhook Controller
↓
Validate Signature
↓
Rate Limit Check
↓
Load Redis
5F4A
Memory
↓
RAG Vector Search
↓
Tool Detection
↓
Build Prompt
↓
Call Ollama (LLM)
↓
Save Conversation
↓
Send WhatsApp Reply