Template

WhatsApp Cloud API webhook (Python, FastAPI)

FastAPI webhook with signature validation, background replies after the 200 response, deduplication and /healthz.

Download ZIP (6.9 KB)

SHA-256: e26241da2f4e2b87c6672a1180b3a47cb44d7e2a1cabde2f7c835dc1293ab7bf (checksum file)

Stack: Python 3.10+, FastAPI, httpx · License: MIT · Files: 12

What it includes

FastAPI webhook with signature validation, background replies after the 200 response, deduplication and /healthz.

File tree

whatsapp-python/
├── app/
│   ├── __init__.py
│   ├── logic.py
│   └── main.py
├── tests/
│   └── test_logic.py
├── .dockerignore
├── .env.example
├── .gitignore
├── Dockerfile
├── LICENSE
├── README.md
├── requirements-dev.txt
└── requirements.txt

Setup

unzip whatsapp-python.zip && cd whatsapp-python
python -m venv .venv && . .venv/bin/activate
pip install -r requirements-dev.txt
cp .env.example .env
set -a; . ./.env; set +a; uvicorn app.main:app --port 8080
pytest -q

Fill in .env with credentials from the platform's official developer console. Never commit it: the included .gitignore excludes it.

Run with Docker

docker build -t whatsapp-python .
docker run --rm --env-file .env whatsapp-python

Official documentation

https://developers.facebook.com/docs/whatsapp/cloud-api

All templates