A WhatsApp bot that can participate in group conversations, powered by AI. The bot monitors group messages and responds when mentioned.
- Automated group chat responses when mentioned
- Message history tracking and summarization
- Knowledge base integration for informed responses
- Support for various message types (text, media, links, etc.)
- Group management capabilities
- Docker and Docker Compose
- Python 3.12+
- PostgreSQL with pgvector extension
- Voyage AI API key
- WhatsApp account for the bot
-
Clone the repository
-
Create a
.envfile in the src directory with the following variables:
WHATSAPP_HOST=http://localhost:3000
WHATSAPP_BASIC_AUTH_USER=admin
WHATSAPP_BASIC_AUTH_PASSWORD=admin
VOYAGE_API_KEY=your_voyage_api_key
DB_URI=postgresql+asyncpg://user:password@localhost:5432/postgres
LOG_LEVEL=INFO
ANTHROPIC_API_KEY=your-key-here # You need to have a real anthropic key here, starts with sk-....
LOGFIRE_TOKEN=your-key-here # You need to have a real logfire key here- Start the services:
docker compose up -d-
Initialize the WhatsApp connection by scanning the QR code through the WhatsApp web interface.
-
Restart web-server service to get the groups from the number
- install uv tools
uv sync --all-extras --active - run ruff (Python linter and code formatter)
ruff checkandruff format - check for types usage
pyright
The project consists of several key components:
- FastAPI backend for webhook handling
- WhatsApp Web API client for message interaction
- PostgreSQL database with vector storage for knowledge base
- AI-powered message processing and response generation
- Main application:
app/main.py - WhatsApp client:
src/whatsapp/client.py - Message handler:
src/handler/__init__.py - Database models:
src/models/
- Fork the repository
- Create a feature branch
- Submit a pull request