How t0mer/openwa_llm works
OpenWA LLM is a WhatsApp group bot with an authenticated admin console. Incoming WhatsApp events are verified and dispatched into message handling, while separate ingestion and scheduled/API summary workflows use stored conversation history and AI-generated output. Knowledge-base ingestion embeds extracted topics for later context-aware answers. The admin UI manages groups, contacts, messages, opt-outs, schedules, actions, and connection settings. Several route and storage implementations were not sampled; their presence and capabilities are reflected from the tree and README, but unverified internal links are omitted.
Main entry points: router.py Message handling · __init__.py Group summaries · gateway.py WhatsApp gateway · message.py Conversation and domain models
Components 28
Webhook and handling
- Webhook verification
src/api/webhook.py - Message handling
src/handler/router.py - Base handler
src/handler/base_handler.py - Group-link spam
src/handler/whatsapp_group_link_spam.py
Knowledge and answers
- Knowledge answers
src/handler/knowledge_base_answers.py - Knowledge Q&A
src/handler/kb_qa.py - Topic extraction
src/load_new_kbtopics/__init__.py - Hybrid search
src/search/hybrid_search.py
Summaries and scheduling
- Group summaries
src/summarize_and_send_to_groups/__init__.py - Summary scheduler
src/scheduling/runner.py - Summary and ingest APIs
src/api/summarize_and_send_to_group_api.py
Administration
- Admin routes
src/admin/router.py - Admin actions
src/admin/actions.py - Admin authentication
src/admin/auth_routes.py - Admin console
web/src/App.tsx
WhatsApp and state
- WhatsApp gateway
src/whatsapp/gateway.py - OpenWA adapter
src/whatsapp/openwa.py - Session registry
src/openwa_settings/registry.py - Encrypted settings
src/openwa_settings/store.py - Conversation and domain models
src/models/message.py - Prompt templates
src/services/prompt_manager.py - WhatsApp identity parsing
src/whatsapp/jid.py
Other components
- WhatsApp participants
- Admin operator
- OpenWA service
- LLM provider
- Voyage embeddings
- PostgreSQL pgvector
Connections 30
- WhatsApp participants → OpenWA service: sends messages
- OpenWA service → Webhook verification: posts events
- Webhook verification → Message handling: dispatches events
src/api/webhook.py - Webhook verification → WhatsApp gateway: syncs groups
src/api/webhook.py - Message handling → Base handler: delegates to
src/handler/router.py - Message handling → Knowledge answers: routes answers
src/handler/router.py - Message handling → Group-link spam: checks links
- Knowledge answers → Knowledge Q&A: uses Q&A
- Knowledge answers → Hybrid search: searches context
- Topic extraction → Voyage embeddings: embeds topics
src/load_new_kbtopics/__init__.py - Topic extraction → Conversation and domain models: stores topics
src/load_new_kbtopics/__init__.py - Hybrid search → Conversation and domain models: reads topic links
src/search/hybrid_search.py - Message handling → Prompt templates: renders prompts
src/handler/router.py - Group summaries → Prompt templates: renders prompts
src/summarize_and_send_to_groups/__init__.py - Group summaries → WhatsApp gateway: sends summaries
src/summarize_and_send_to_groups/__init__.py - Summary scheduler → Group summaries: runs summaries
src/scheduling/runner.py - Summary and ingest APIs → Group summaries: triggers summaries
- Group summaries → LLM provider: generates summaries
- Admin operator → Admin console: uses console
- Admin console → Admin routes: calls admin API
- Admin routes → Admin authentication: registers auth routes
src/admin/router.py - Admin routes → Admin actions: registers actions
src/admin/router.py - Admin actions → WhatsApp gateway: controls sessions
src/admin/actions.py - Session registry → OpenWA adapter: creates gateways
src/openwa_settings/registry.py - OpenWA adapter → WhatsApp gateway: implements interface
src/whatsapp/__init__.py - Session registry → Encrypted settings: loads connection
src/openwa_settings/registry.py - Encrypted settings → Conversation and domain models: reads settings records
src/openwa_settings/store.py - WhatsApp gateway → OpenWA service: connects to
- Conversation and domain models → PostgreSQL pgvector: persists history
- WhatsApp identity parsing → Message handling: normalizes identities
src/handler/router.py