Open Source Framework to develop smart Workflows, Agents and full chat applications through WhatsApp
Project description
Wappa ๐ค
Open Source Framework for WhatsApp Business Applications
Build intelligent WhatsApp bots, workflows, and chat applications with clean architecture and modern Python.
๐ 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
class MyBot(WappaEventHandler):
async def process_message(self, webhook):
await self.messenger.send_text("Hello!", webhook.user.user_id)
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-Tenant - 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
๐ ๏ธ 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"})
๐ฆ 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
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:
- Access Token
- Phone Number ID
- Business Account ID
2. Create Your Bot
# Initialize project
wappa init my-bot
cd my-bot
# Configure environment
cp .env.example .env
# Edit .env with your WhatsApp 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!
๐๏ธ 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 6 complete example applications:
# Browse examples interactively
wappa examples
# Copy specific example
wappa examples redis-cache-demo
- Simple Echo - Basic message echoing
- JSON Cache Demo - File-based state persistence
- Redis Cache Demo - High-performance caching
- OpenAI Transcription - Voice message processing
- Full-Featured Bot - Complete production example
- Basic Project - Minimal setup template
๐ ๏ธ Advanced Usage
Builder Pattern for Complex Apps
from wappa import WappaBuilder
app = await (WappaBuilder()
.with_whatsapp(
token="your_token",
phone_id="your_phone_id",
business_id="your_business_id"
)
.with_redis_cache("redis://localhost:6379")
.with_cors_enabled()
.with_rate_limiting(requests_per_minute=100)
.build())
app.set_event_handler(MyAdvancedHandler())
app.run()
Plugin System
from wappa.plugins import DatabasePlugin, CorsPlugin
app = Wappa(cache="redis")
app.add_plugin(DatabasePlugin("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 [target] # Browse/copy examples
# 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
railway variables set WP_ACCESS_TOKEN=your_token
railway variables set WP_PHONE_ID=your_phone_id
railway variables set WP_BID=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
โ โโโ api/ # FastAPI routes & dependencies
โโโ examples/ # Example applications
โโโ 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 - 6 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wappa-0.2.24.tar.gz.
File metadata
- Download URL: wappa-0.2.24.tar.gz
- Upload date:
- Size: 8.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a468b6b746495ec449601af86dc16e3cdb8e34626378c7c56993551ab02dfb1f
|
|
| MD5 |
f56fee584c03fedcedd3db306ad24e61
|
|
| BLAKE2b-256 |
feb1f1f9fc38e9e64425db2fb75d4f922ad9a808c4f1c14029ec62563b8cb315
|
File details
Details for the file wappa-0.2.24-py3-none-any.whl.
File metadata
- Download URL: wappa-0.2.24-py3-none-any.whl
- Upload date:
- Size: 8.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bd8b0d351b428ec64fe6d37624f1d3fd20e2599eb681123ef152f739a87fb0c
|
|
| MD5 |
70e5e85aafd2b0f601e21c6ef46acc2f
|
|
| BLAKE2b-256 |
b487eff6f18da884761a97582e2c29b0484666b18334eac49a10bd1b671842c3
|