AK
akashfy/WhatsApp-Business-Api
Official WhatsApp Business Api
Official WhatsApp Business Api
A self-hosted WhatsApp automation dashboard built on Meta Cloud API (v25.0). Supports real-time chat, mass broadcasting, auto-replies, and follow-up sequences โ all from a clean, responsive UI.
๐ Quick Start
Local (Go)
# 1. Setup environment
cp .env.example .env
# Fill in your WHATSAPP_TOKEN, PHONE_NUMBER_ID, WABA_ID
# 2. Run
go run auto.go
# Open http://localhost:8086Docker
docker-compose up -d --build
# Open http://localhost:8086๐ณ Docker Hub Image
Get the pre-built image from Docker Hub:
docker pull akashyadav758/whatsapp-hub
Explore on Docker Hub
โ๏ธ Environment Variables (.env)
| Variable | Description |
|---|---|
WHATSAPP_TOKEN |
Meta Cloud API Bearer token |
PHONE_NUMBER_ID |
WhatsApp Phone Number ID |
WABA_ID |
WhatsApp Business Account ID |
WEBHOOK_PORT |
Local server port (default: 8086) |
WEBHOOK_URL |
Public URL for Meta webhook (e.g. Cloudflare Tunnel) |
WEBHOOK_VERIFY_TOKEN |
Webhook verification token |
APP_NAME |
Dashboard display name |
API_VERSION |
Meta API version (default: v25.0) |
AUTO_REPLY_DELAY_SEC |
Delay before auto-reply fires (default: 2) |
BROADCAST_DELAY_MS |
Delay between broadcast messages (default: 200) |
TZ |
Timezone (default: Asia/Kolkata) |
โจ Features
- ๐จ Real-time Chat โ Live incoming/outgoing messages via SSE + polling. Read state persisted in DB (works across browsers/devices).
- ๐ข Mass Broadcast โ Template-based broadcast with rate limiting and variable substitution.
- ๐ค Auto-Reply โ Smart auto-reply with configurable delay and 24h loop prevention.
- โฑ Follow-Up Sequences โ Up to 3 timed follow-up messages per contact.
- ๐ก Dark / Light Mode โ Theme toggle, persisted per browser.
- ๐ฑ Mobile Responsive โ WhatsApp-style layout with bottom tab bar on mobile.
- ๐ Unread Badges โ Per-contact unread counts, server-synced so badges stay correct across sessions.
๐ก API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/messages |
Fetch all messages (filter by ?phone=) |
| GET | /api/statuses |
Fetch message delivery statuses |
| GET/POST | /api/readstate |
Get/set per-contact read timestamps (DB-backed) |
| GET | /api/templates |
Fetch Meta approved templates |
| POST | /api/broadcast |
Send broadcast to multiple numbers |
| POST | /api/reply |
Send a single reply to a contact |
| GET/POST | /api/config |
Get/update runtime config |
| GET/POST | /api/settings |
Get/update persistent settings (auto-reply, follow-ups) |
| GET | /api/events |
SSE stream for real-time updates |
| GET | /health |
Health check |
| GET/POST | /webhook |
Meta Cloud API webhook endpoint |
๐ Project Structure
.
โโโ auto.go # Core backend (Go) โ HTTP server, webhook handler, DB, SSE
โโโ go.mod / go.sum # Go module files
โโโ .env # Environment config (not committed)
โโโ docker-compose.yml # Docker deployment
โโโ docker/
โ โโโ Dockerfile # Container build config
โโโ static/
โ โโโ index.html # App shell
โ โโโ app.js # React UI (single file, no build step)
โ โโโ app.css # Styles (CSS variables, dark/light theme)
โโโ data/
โโโ messages.db # SQLite database (auto-created on first run)
๐ Database
SQLite at data/messages.db. Key tables:
messagesโ All incoming/outgoing messages with direction, phone, type, timestampsstatusesโ Message delivery status updates (sent/delivered/read)settingsโ Persistent key-value config including read state (readstate_PHONE)
๐ Webhook Setup
- Set
WEBHOOK_URLto your public URL (e.g. via Cloudflare Tunnel). - In Meta Developer Console โ WhatsApp โ Configuration โ set Webhook URL to
{WEBHOOK_URL}/webhook. - Set Verify Token to match
WEBHOOK_VERIFY_TOKENin.env. - Subscribe to
messagesfield.
On this page
Languages
JavaScript38.1%Go36.2%CSS24.5%HTML0.7%Dockerfile0.6%
Contributors
Created March 14, 2026
Updated March 14, 2026