GitHunt

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:8086

Docker

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, timestamps
  • statuses โ€” Message delivery status updates (sent/delivered/read)
  • settings โ€” Persistent key-value config including read state (readstate_PHONE)

๐Ÿ”— Webhook Setup

  1. Set WEBHOOK_URL to your public URL (e.g. via Cloudflare Tunnel).
  2. In Meta Developer Console โ†’ WhatsApp โ†’ Configuration โ†’ set Webhook URL to {WEBHOOK_URL}/webhook.
  3. Set Verify Token to match WEBHOOK_VERIFY_TOKEN in .env.
  4. Subscribe to messages field.
akashfy/WhatsApp-Business-Api | GitHunt