Skip to main content

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.

Python 3.12+ License: Apache 2.0 FastAPI WhatsApp Business API


๐Ÿš€ 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

  1. Visit Meta for Developers
  2. Create a WhatsApp Business App
  3. 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

๐Ÿ“– Complete Documentation

Quick Links

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

๐Ÿ“ž Get Support

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guide for details.

๐Ÿ“‹ 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wappa-0.2.25.tar.gz (8.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wappa-0.2.25-py3-none-any.whl (8.3 MB view details)

Uploaded Python 3

File details

Details for the file wappa-0.2.25.tar.gz.

File metadata

  • Download URL: wappa-0.2.25.tar.gz
  • Upload date:
  • Size: 8.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.5

File hashes

Hashes for wappa-0.2.25.tar.gz
Algorithm Hash digest
SHA256 92239f82e17a1d061a6802224bbe3f9ba62088d2b7f94d86f7b91d7dc00a12d0
MD5 63f2fe308922510e69756bdc84689a4c
BLAKE2b-256 a32f1f5a3e1d932dec0b45179f5c218b6a9af98e5e436ab7da4ddf5094249f8b

See more details on using hashes here.

File details

Details for the file wappa-0.2.25-py3-none-any.whl.

File metadata

  • Download URL: wappa-0.2.25-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

Hashes for wappa-0.2.25-py3-none-any.whl
Algorithm Hash digest
SHA256 009d39493204cfe9b9d5c3e4199c6aaac92892c1a99636d9c3ad87db65d0154d
MD5 d7ca93b329ac944482f29c8001d084d8
BLAKE2b-256 1bcdcc593442e3be4d941f2f485e1cf353b261449ba1ed7709c814d9ee85b56b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page