Wappa 🤖
Open Source Framework for WhatsApp Business Applications
Build intelligent WhatsApp bots, workflows, and chat applications with clean architecture and modern Python.
v0.32.0 — FastAPI compatibility and router authentication — Wappa uses FastAPI 0.162.x, keeps public router exemptions within their mounted prefixes, and simplifies cron route registration. See CHANGELOG.md.
🚀 What is Wappa?
Wappa is a modern Python framework that transforms WhatsApp Business API into a powerful platform for building:
- 🤖 Smart Chatbots - AI-powered conversational experiences
- 📋 Workflows - Multi-step business processes
- 🎯 Agents - Intelligent customer service automation
- 💬 Chat Applications - Full-featured messaging platforms
Built for developers who want clean code, not webhook complexity.
✨ Key Features
🎯 Simple & Clean
from wappa import Wappa, WappaEventHandler
from wappa.messaging import DirectMessage
class MyBot(WappaEventHandler):
async def process_message(self, webhook):
await self.messenger.send_text(
"Hello!",
DirectMessage(
inbox_ref=self.inbox_ref,
addresses=webhook.user.delivery_addresses(),
),
)
app = Wappa()
app.set_event_handler(MyBot())
app.run()
🏗️ Production-Ready Architecture
- Clean Architecture - Domain-driven design with dependency injection
- Type-Safe - Full Pydantic models for all WhatsApp data structures
- Multi-Inbox - Built for scaling across multiple business numbers
- Plugin System - Extensible with Redis, CORS, rate limiting, and custom plugins
📱 Complete WhatsApp Support
- All Message Types - Text, media, interactive buttons, lists, templates
- Rich Interactions - Buttons, lists, call-to-action messages
- Media Handling - Images, videos, audio, documents with automatic upload/download
- Templates - Pre-approved business message templates through the
ITemplateMessagingcapability
🆔 Message Targets and BSUID Support
- Explicit Targets - Every
self.messenger.send_*call takes atarget; there is norecipientkeyword and bare strings are rejected.send_textalso accepts aPrivateReply(Instagram). - DirectMessage -
DirectMessage(inbox_ref=..., addresses=...)binds a User's Delivery Addresses to the Inbox allowed to use them. In a handler, useself.inbox_refandwebhook.user.delivery_addresses(); outside webhooks, useDeliveryAddresses.of(*known). A target for a different Inbox fails before any send. - BSUID-Aware Fallback - The WhatsApp adapter tries the phone number first, then the BSUID, and moves to the next address only when Meta rejects the address itself (
131030, or131062when a message type cannot go to a BSUID). Authentication Templates go to phone numbers only. - No Blind Retries - Window, rate-limit, content and timeout errors are returned as-is, never retried on another address.
MessageResult.attempted_recipientslists the addresses tried after a fallback.
See docs/public-contract.md and ADR-0022 for the full contract.
🛠️ Developer Experience
# Initialize new project
wappa init my-bot
# Start development server with auto-reload
wappa dev app/main.py
# Browse interactive examples
wappa examples
💾 Flexible State Management
# Memory, JSON file, or Redis caching
app = Wappa(cache="redis") # or "memory" or "json"
# Automatic state persistence
await self.state_cache.set("conversation", {"step": "greeting"})
Inbox-scoped Template transport
Embedding applications send Templates through Wappa's public runtime capability; they do not construct WhatsApp clients, handlers, sessions, or pipelines:
from wappa import InboxRef
from wappa.messaging import (
OutboundRuntime,
PhoneNumberTemplateRecipient,
TextTemplateTransportRequest,
)
transport = OutboundRuntime.from_app(fastapi_app).templates(
InboxRef.whatsapp(phone_number_id)
)
result = await transport.send(
TextTemplateTransportRequest(
recipient=PhoneNumberTemplateRecipient(value="573001112233"),
template_name="welcome",
category="utility",
)
)
result.outcome is accepted, rejected, transport_unavailable, or
indeterminate. Acceptance proves a platform Message ID, not delivery or a Host
Application commit. Wappa's standalone Template HTTP routes are opt-in with
Wappa(include_template_transport_api=True).
An embedding application that owns its own authenticated boundary drops Wappa's unauthenticated mutation surface with one argument:
app = Wappa(cache="redis", route_profile="embedded")
That omits every route which sends a message, deletes a media asset, or
rewrites a recipient's cached state. Media upload/download/lookup, limits,
validation, Template info, webhooks, health, and every wappa.messaging
service stay exactly as they are. Standalone applications need no change.
📦 Installation
Using uv (Recommended)
# Create new project
uv init my-wappa-project
cd my-wappa-project
# Add Wappa
uv add wappa
# Initialize project structure
wappa init .
Using pip
pip install wappa
# Initialize new project
wappa init my-wappa-project
cd my-wappa-project
wappa init also adds Wappa's agent skills under .claude/skills/ and .agents/skills/, so coding agents build against the current public API: wappa-apps (WhatsApp and Instagram apps from one handler, media formats, connecting accounts, Meta setup), wappa-conversational-scores (Scores and guided forms), wappa-state-and-storage (caches, Redis, Postgres), wappa-scheduled-tasks (reminders, timers, recurring jobs and heartbeats on one hook) and wappa-host-integration (multi-Inbox, plugins, external webhooks, crons, upgrades). Existing skill folders are never overwritten.
Using Poetry
poetry new my-wappa-project
cd my-wappa-project
poetry add wappa
# Initialize project structure
wappa init .
🏃♂️ Quick Start
1. Get WhatsApp Business API Credentials
- Visit Meta for Developers
- Create a WhatsApp Business App
- Get your credentials:
- App Secret (
META_APP_SECRET) — Wappa verifies every webhook POST body with it; there is no development bypass - A verify token you choose (
META_WEBHOOK_VERIFY_TOKEN) — used only for Meta's GET challenge - Access Token, Phone Number ID, Business Account ID (
META_WHATSAPP_ACCESS_TOKEN,META_WHATSAPP_PHONE_NUMBER_ID,META_WHATSAPP_BUSINESS_ACCOUNT_ID) — the legacy single-Inbox bundle
- App Secret (
- Configure the one callback URL in the Meta App:
https://<host>/webhook/inboxes/whatsapp
2. Create Your Bot
# Initialize project
wappa init my-bot
cd my-bot
# The generated project already contains .env
# Edit .env with your credentials
3. Run Development Server
# Start with auto-reload
wappa dev app/main.py
# Or manually
uv run python -m app.main
4. Test Your Bot
Send a message to your WhatsApp Business number and watch it echo back!
Many Inboxes under one Meta App (explicit mode)
Wappa has exactly two Inbox Routing Modes and they never mix. legacy (the default) runs the single Inbox from the META_WHATSAPP_* bundle. explicit runs any number of Inboxes through Wappa's encrypted Inbox Directory: you implement a read-only IInboxDirectorySource over your own database, Wappa owns encryption (SYSTEM_TOKEN_ENC_KEY), caching, the WABA reverse index, and Messenger eviction.
Start a Host-adapter scaffold with wappa init my-bot --inbox-routing explicit.
It includes the required environment configuration and an
IInboxDirectorySource stub to connect to the Host's durable Inbox records.
# Explicit mode never mixes with the legacy META_WHATSAPP_* Inbox bundle.
SYSTEM_INBOX_ROUTING_MODE=explicit
SYSTEM_TOKEN_ENC_KEY=<Fernet key from CredentialCodec.generate_key()>
from wappa import Wappa, InboxRoutingMode
app = Wappa(
cache="redis",
inbox_routing=InboxRoutingMode.EXPLICIT,
inbox_directory_source=MyInboxSource(db), # implements IInboxDirectorySource
)
Explicit mode rejects META_WHATSAPP_ACCESS_TOKEN, META_WHATSAPP_PHONE_NUMBER_ID, and META_WHATSAPP_BUSINESS_ACCOUNT_ID at startup, and every Inbox-dependent /api/whatsapp/* call sends X-Wappa-Inbox-ID — a selector, not a credential; your authentication decides who may use it. The ordered setup, the credential commands, and the key-rotation runbook are in docs/migration/v0.27.0-multi-inbox.md.
🎛️ Architecture Overview
graph TD
A[👤 WhatsApp User] -->|Message| B[📡 Webhook Endpoint]
B --> C[🔄 Event Dispatcher]
C --> D[⚡ Your Event Handler]
D --> E[💬 Messenger Interface]
E --> F[📱 WhatsApp API]
D --> G[💾 State Management]
D --> H[🧠 Business Logic]
G --> I[🗄️ Redis/Memory/JSON Cache]
H --> J[🔗 External Services]
style D fill:#333481,color:#fff,stroke:#333481,stroke-width:3px
style E fill:#4A90E2,color:#fff,stroke:#4A90E2,stroke-width:3px
style G fill:#333481,color:#fff,stroke:#333481,stroke-width:3px
style A fill:#25D366,color:#fff,stroke:#25D366,stroke-width:3px
style F fill:#25D366,color:#fff,stroke:#25D366,stroke-width:3px
- Event-Driven: Webhook → Event Handler → Response
- Type-Safe: Full Pydantic models for all WhatsApp data structures
- FastAPI Core: Built on modern async Python with automatic OpenAPI docs
- Production Ready: Docker support, Redis caching, structured logging
📚 Documentation
Quick Links
- 🚀 Quick Start - Get running in 5 minutes
- 🏗️ Architecture Guide - Understanding the framework
- 📡 API Reference - Complete messaging API
- 💾 State Management - Caching and persistence
- 🚀 Deploy to Railway - Production deployment
- 🛠️ WhatsApp Setup - Configure WhatsApp Business API
Example Projects
Explore 9 complete example applications:
# Browse examples interactively
wappa examples
# Pick an example from the menu and copy it into ./my-bot/
wappa examples my-bot
- Basic Project - Minimal Wappa project with basic message handling
- Simple Echo Bot - Echoes all incoming messages with acknowledgment
- Expiry Actions Demo - Inactivity detection with message accumulation using ExpiryActions
- JSON Cache Demo - File-based caching with user management and state handling
- Redis Cache Demo - Redis-powered caching with advanced state management
- OpenAI Transcription - Voice message transcription using OpenAI Whisper API
- Redis PubSub Plugin - Multi-inbox Redis PubSub with self-subscribing pattern
- DB + Redis Cache - PostgreSQL + Redis two-tier storage with SOLID architecture
- Full-Featured Bot - Complete WhatsApp bot with all features and deployment configs
🛠️ Advanced Usage
Builder Pattern for Complex Apps
from wappa import Wappa, WappaBuilder
from wappa.core.plugins import CORSPlugin, RateLimitPlugin, RateLimitProfile, RedisPlugin
fastapi_app = (
WappaBuilder()
.with_inbox_routing("explicit")
.with_inbox_directory_source(MyInboxSource(db))
.add_plugin(RedisPlugin())
.add_plugin(CORSPlugin(allow_origins=["*"]))
.add_plugin(RateLimitPlugin([RateLimitProfile(name="default", limit=100, window_seconds=60)]))
.configure(title="My Wappa App")
.build()
)
app = Wappa()
app.set_app(fastapi_app)
app.set_event_handler(MyAdvancedHandler())
app.run()
Plugin System
from wappa import Wappa
from wappa.core.plugins import CORSPlugin, PostgresDatabasePlugin
app = Wappa(cache="redis")
app.add_plugin(PostgresDatabasePlugin("postgresql://..."))
app.add_plugin(CORSPlugin(allow_origins=["*"]))
app.set_event_handler(MyHandler())
app.run()
CLI Commands
# Project management
wappa init [directory] # Initialize new project
wappa examples [directory] # Pick an example and copy it to directory
# Development
wappa dev app/main.py # Development server with auto-reload
wappa prod app/main.py # Production server
# Help
wappa --help # Show all commands
🚀 Deployment
Railway (Recommended)
# Install Railway CLI
npm install -g @railway/cli
# Login and deploy
railway login
railway init
railway add redis
railway up
# Set environment variables (legacy single-Inbox mode)
railway variables set META_APP_SECRET=your_meta_app_secret
railway variables set META_WEBHOOK_VERIFY_TOKEN=your_verify_token
railway variables set META_WHATSAPP_ACCESS_TOKEN=your_token
railway variables set META_WHATSAPP_PHONE_NUMBER_ID=your_phone_id
railway variables set META_WHATSAPP_BUSINESS_ACCOUNT_ID=your_business_id
See complete Railway deployment guide.
Docker
FROM python:3.12-slim
WORKDIR /app
COPY . .
RUN pip install uv
RUN uv sync --frozen
EXPOSE 8000
CMD ["uv", "run", "python", "-m", "app.main"]
🧪 Development
Setup Development Environment
# Clone repository
git clone https://github.com/sashanclrp/wappa.git
cd wappa
# Install dependencies
uv sync --group dev
# Run tests
uv run pytest
# Code formatting
uv run ruff check .
uv run ruff format .
Project Structure
wappa/
├── wappa/ # Core framework
│ ├── core/ # Application core & plugins
│ ├── messaging/ # WhatsApp messaging implementation
│ ├── persistence/ # Cache backends (Memory/JSON/Redis)
│ ├── cli/ # CLI tools, project templates & examples/
│ └── api/ # FastAPI routes & dependencies
├── docs/ # Documentation source
└── tests/ # Test suite
🤝 Community & Support
💬 Join the Community
- 💭 Discord Community - Get help, share projects, and connect with other developers
- 🐛 GitHub Issues - Bug reports and feature requests
- 📖 GitHub Discussions - Questions and community discussions
📞 Get Support
- 📚 Documentation - Comprehensive guides and API reference
- 💡 Examples - 9 complete working examples
- 🔧 Configuration Guide - WhatsApp Business API setup
🤝 Contributing
We welcome contributions! Please see our Contributing Guide for details.
- 🐛 Found a bug? Open an issue
- 💡 Have an idea? Start a discussion
- 🔧 Want to contribute? Check out good first issues
📋 Requirements
- Python 3.12+ - Modern Python with latest type hints
- WhatsApp Business API - Meta for Developers account
- Redis (optional) - For production caching and state management
📄 License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
🙏 Acknowledgments
- Meta - For the WhatsApp Business API
- FastAPI - For the excellent async Python framework
- Redis - For high-performance caching
- Open Source Community - For inspiration and contributions
Built with ❤️ by Mimeia • Open Source • Apache 2.0 License
Transform your business communication with WhatsApp automation.
Instagram text (Unified Login)
Wappa has an Instagram adapter for DMs, comments and mentions. Use explicit Inbox routing and an encrypted Instagram credential record through IInboxDirectorySource. The callback is /webhook/inboxes/instagram; Meta signature authentication remains mandatory. Recipient-based Messenger sends use Inbox-qualified DirectMessage targets, including on WhatsApp. The same Messenger methods (send_button_message, send_list_message, send_carousel, send_location, send_contact, mark_as_read, ...) work on both Platforms, and a User's choice always arrives in process_message via get_interactive_selection() (ADR-0025). Media upload and download go through the shared IMediaLibrary capability; comment actions (ICommentControls) and WhatsApp Templates (ITemplateMessaging) are capability-gated too.
See the setup walkthrough and public contract for startup, addressing migration, and capability boundaries. Live receipt still requires an authorized account, subscriptions, and appropriate Meta app access.
The Instagram implementation PRD series tracks the remaining message/public-conversation capabilities, Unified Login, Symphonai integration, DDD updates and developer skill packages. Its planned capabilities and skills are not all available in the current adapter.
Metadata
Release files for wappa 0.34.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| wappa-0.34.8.tar.gz | 8.5 MB | Without provenance | Details for wappa-0.34.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| wappa-0.34.8-py3-none-any.whl | Python 3 | none | any | Details for wappa-0.34.8-py3-none-any.whl |
Total release size: 17.2 MB
Release files / wappa-0.34.8.tar.gz
| Download URL | wappa-0.34.8.tar.gz |
|---|---|
| Size | 8.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
066c280eabc55c648d72c3144b6e57316a9385f22143be491c8a02e804e69489
|
|
BLAKE2b-256 checksum How to use checksums |
f51406f455afc7b3dc2bdd3e0353907acc87bab9e8f0a6ba131b7c72c98f01eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / wappa-0.34.8-py3-none-any.whl
| Download URL | wappa-0.34.8-py3-none-any.whl |
|---|---|
| Size | 8.7 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bf0bb1096f087ed0b3b1b8128e5f614ac3f97b85bbb970cf28afcb629d6bff01
|
|
BLAKE2b-256 checksum How to use checksums |
9f9036c69bec973c8fa58f0b17ab9702c753bea2f95b287d126c1449a6171bad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for wappa 0.34.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.