AI-powered WhatsApp bot that joins any group, tracks conversations, and generates intelligent summaries.
About this repo:
minime-wa-llmis a personal project built on top of ilanbenb/wa_llm (kept as theupstreamgit remote here). It's customi 10BC8 zed for personal/family use rather than being a general-purpose fork meant for upstream contribution β notably a Portuguese persona, a manual knowledge-base seeding endpoint (/kb/seed), an optional web-search tool for the Q&A agent, and support for running alongside other independent bot services (see "Companion services" below) that share the same WhatsApp session.
- π€ Automated group chat responses (when mentioned)
- π Smart LLM-based conversation summaries
- π Knowledge base integration for context-aware answers
- π Persistent message history with PostgreSQL +
pgvector - π Support for multiple message types (text, media, links)
- π₯ Group management & customizable settings
- π Opt-out feature: Users can opt-out of being tagged in summaries/answers via DM.
- β‘ REST API with Swagger docs (
localhost:8000/docs)
This project includes multiple Docker Compose files for different environments:
| File | Purpose | Usage |
|---|---|---|
docker-compose.yml |
Default/Development. Builds the application from source code. | docker compose up -d |
docker-compose.prod.yml |
Production. Uses pre-built images from GHCR. Recommended for deployment. | docker compose -f docker-compose.prod.yml up -d |
docker-compose.local-run.yml |
Local Execution. For running the app on host while services run in Docker. | docker compose -f docker-compose.local-run.yml up -d |
docker-compose.base.yml |
Base Configuration. Contains shared service definitions. | β Do not use directly |
- π³ Docker and Docker Compose
- π Python 3.13+
- ποΈ PostgreSQL with
pgvectorextension - π Voyage AI API key
- π² WhatsApp account for the bot
git clone https://github.com/chocksmith/minime-wa-llm.git cd minime-wa-llm
- Copy
.env.exampleto.envand fill in required values.
cp .env.example .env
| Variable | Description | Default |
|---|---|---|
WHATSAPP_HOST |
WhatsApp Web API URL | http://localhost:3000 |
WHATSAPP_BASIC_AUTH_USER |
WhatsApp API user | admin |
WHATSAPP_BASIC_AUTH_PASSWORD |
WhatsApp API password | admin |
VOYAGE_API_KEY |
Voyage AI key | β |
DB_URI |
PostgreSQL URI | postgresql+asyncpg://user:password@localhost:5432/postgres |
LOG_LEVEL |
Log level (DEBUG, INFO, ERROR) |
INFO |
ANTHROPIC_API_KEY |
Anthropic API key. You need to have a real anthropic key here, starts with sk-.... | β |
LOGFIRE_TOKEN |
Logfire monitoring key, You need to have a real logfire key here | β |
DM_AUTOREPLY_ENABLED |
Enable auto-reply for direct messages | False |
DM_AUTOREPLY_MESSAGE |
Message to send as auto-reply | Hello, I am not designed to answer to personal messages. |
Option A: Development (Build from source)
docker compose up -dOption B: Production (Use pre-built images)
docker compose -f docker-compose.prod.yml up -d- Open http://localhost:3000
- Scan the QR code with your WhatsApp mobile app.
- Invite the bot device to any target groups you want to summarize.
- Restart service:
docker compose restart wa_llm-web-server
-
open pgAdmin or any other posgreSQL admin tool
-
connect using
Parameter Value Host localhost Port 5432 Database postgres Username user Password password -
run the following update statement:
UPDATE public."group" SET managed = true WHERE group_name = 'Your Group Name'; -
Restart the service:
docker compose restart wa_llm-web-server
Swagger docs available at: http://localhost:8000/docs
- /load_new_kbtopics (POST) Distills recent chat history into knowledge-base topics for all managed groups.
- /summarize_and_send_to_groups (POST) Generates & dispatches daily summaries to all managed groups (and their linked community groups).
- /kb/seed (POST) Seeds a group's knowledge base with hand-written background info that didn't come from chat messages (e.g. the group's purpose, rules, reference facts). Re-seeding the same
subjectfor a group overwrites that entry. Example:curl -X POST http://localhost:8000/kb/seed \ -H "Content-Type: application/json" \ -d '{ "group_name": "Your Group Name", "topics": [ {"subject": "Purpose", "content": "What this group is about..."} ] }'
Live deployment: this repo is vendored as a submodule (
vendor/wa_llm) of chocksmith/minime, and the live stack (this app plusrealestate-bot) runs from minime'sdocker-compose.ymlβ see its README's "Running it" section. The commands below apply there; this repo's own compose files are for standalone development and must not be run on the live host at the same time.
All commands run from the repo root (where docker-compose.yml lives).
# Start everything (creates volumes/networks as needed; safe to re-run)
docker compose up -d
# Check what's running
docker compose ps
# Stop everything (containers stop, all data/volumes persist)
docker compose stop
# Fully remove containers (still keeps volumes/data β use before recreating)
docker compose down
# Watch logs
docker compose logs -f # everything
docker compose logs -f web-server # one service
docker compose logs -f realestate-bot # one service
# After an env change (picks up the new env without rebuilding)
docker compose up -d --no-deps <service>
# After a code change (rebuild image first, then recreate)
docker compose build <service> && docker compose up -d --no-deps <service>Service names: postgres, whatsapp, web-server, realestate-bot.
All four services run with restart: always, so a Docker/host restart brings the whole stack back automatically β no manual intervention needed. postgres must be healthy before whatsapp will start (it depends on it); if you ever see whatsapp crash-looping right after a fresh start, this is almost always just startup ordering catching up, and it self-resolves within seconds.
Never run docker compose down -v or remove the wa_llm_whatsapp volume casually β that discards the paired WhatsApp session and forces re-scanning the QR code for every bot on the stack.
Users can control whether they are tagged in bot-generated messages (summaries, answers) by sending Direct Messages (DMs) to the bot:
| Command | Description |
|---|---|
opt-out |
Opt-out of being tagged. Your name will be displayed as text instead of a mention. |
opt-in |
Opt-in to being tagged (default). |
status |
Check your current opt-out status. |
Note: This only affects messages generated by the bot. It does not prevent other users from tagging you manually.
To deploy in a production environment using the optimized configuration:
-
Create Production Environment File: Copy
.env.exampleto.env.prodand configure your production secrets.cp .env.example .env.prod
-
Start Services:
docker compose -f docker-compose.prod.yml up -d
This configuration includes:
- Automatic restart policies (
restart: always)
Install dependencies using uv:
uv sync --all-extras --devThe project uses Poe the Poet for task automation with parallel execution:
# Run all checks (format, then parallel lint/typecheck/test)
uv run poe check
# Individual tasks
uv run poe format # Format code with ruff
uv run poe lint # Lint code with ruff
uv run poe typecheck # Type check with pyright
uv run poe test # Run tests with pytest
# List all available tasks
uv run poeThe check command runs formatting first, then executes linting, type checking, and testing in parallel for faster execution.
- Main application:
app/main.py - WhatsApp client:
src/whatsapp/client.py - Message handler:
src/handler/__init__.py - Database models:
src/models/
whatsappβ GOWA (go-whatsapp-web-multidevice), the self-hosted WhatsApp Web REST API. Owns the one paired WhatsApp session/phone number for the whole stack. Exposes a REST API on port3000(basic auth) and pushes every incoming event as a webhook.postgresβ Postgres +pgvector, storing groups, messages, and the knowledge-base topic embeddings.web-serverβ this app. FastAPI backend (app/main.py) that receives WhatsApp webhooks, runs the message handler/router, and answers@mentionsusing an LLM agent (viapydantic-ai) backed by the Postgres knowledge base.
ββββββββββββββββββββββββββ
β whatsapp (GOWA) β
β one WhatsApp session β
β port 3000 β
βββββββββββββ¬βββββββββββββ
β every event is POSTed to
β every URL in WHATSAPP_WEBHOOK
βββββββββββββββ΄ββββββββββββββ
βΌ βΌ
βββββββββββββββββββββββββ βββββββββββββββββββββββββββββββ
β web-server β β (optional) other β
β port 8000 β β webhook consumers β
β only acts on groups β β e.g. realestate-bot - β
β it marked managed=true β β each ignores groups it β
β β β doesn't own (see below) β
ββββββββββββββ¬βββββββββββββ βββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββ
β postgres β
β pgvector KB β
βββββββββββββββββββββββββ
GOWA's WHATSAPP_WEBHOOK env var accepts a comma-separated list of URLs β it will fan out every event to all of them. This means a single paired phone number can serve web-server and any number of other independent bot services at once, each deciding for itself which groups/messages are its business, with zero code coupling between them. web-server's side of that decision is the managed boolean column on the group table (see "Activating the Bot for a Group" above) β any group that isn't managed is silently ignored by this app, after storing the message for its own records.
- Conversations in
managedgroups get periodically distilled into topics and embedded (/load_new_kbtopics), searchable via hybrid vector + keyword search. POST /kb/seedlets you inject hand-written background knowledge for a group directly (bypassing chat-history extraction) β useful for things like a group's purpose, rules, or reference facts that didn't come from conversation.- The agent optionally has a live web-search tool (DuckDuckGo, no API key required) for questions the group's own knowledge can't answer.
- Persona/response-style instructions live in
src/templates/persona.j2, shared by the summarize and Q&A prompts.
This stack is designed so other bot personalities can share the same WhatsApp session without touching this app's code at all β just add another WHATSAPP_WEBHOOK URL and let that service filter to its own group(s). One example run alongside this deployment: a realestate-bot service (from a separate repository) that answers questions and posts notifications in a dedicated group, backed by its own GitHub-repo-based knowledge store and email-polling pipeline, using Claude directly rather than this app's RAG pipeline. It's wired in via docker-compose.yml as an additional service (build.context pointing at that other repo's checkout) and requires no changes to this app beyond the extra webhook URL and never marking its group managed. If you don't have such a service configured, ignore this section β it has no effect on the rest of the stack.
- Fork the repository
- Create a feature branch
- Submit a pull request