Self-hosted · No monthly fees · Open source

WhatsApp Gateway
for Multiple Staff

Connect unlimited WhatsApp accounts, queue messages, schedule delivery, receive webhooks — all from a single Node.js server you control.

Staff accounts

3

Message types

16+

REST endpoints

0

Monthly cost

Everything you need

A complete WhatsApp messaging infrastructure in one server.

👥

Multi-Staff Support

Each staff member gets an isolated WhatsApp session identified by a free-form staff_id. No limit on number of accounts.

📋

Message Queue

Insert messages into MySQL and deliver via cron trigger. Supports text, PDF, and media files. Auto-retry up to configurable max attempts.

🗓️

Scheduled Messages

Set scheduled_at on any queued message. The cron processor delivers only when the time arrives.

🔗

Outgoing Webhooks

Set WEBHOOK_URL to receive incoming messages and delivery ACKs (sent / delivered / read) pushed to your system instantly.

Delivery Tracking

Real-time ACK events update each message status in DB: sent → delivered → read. Queryable via API or visible in dashboard.

📊

Real-time Dashboard

Socket.IO-powered unified dashboard: stats, live feed, send messages, manage queue, view incoming, edit templates — all in one page.

🔐

API Key Auth

Optional API key protection on all /api/* endpoints via x-api-key header, Bearer token, or query param.

🛡️

Rate Limiting

30 req/min limit on direct-send endpoints. Configurable random delay between queue messages to mimic human behavior and avoid WA bans.

📝

Message Templates

Store reusable message templates in DB. Retrieve via API or select from the dashboard to fill forms instantly. Supports create, update, delete.

💾

Session Persistence

LocalAuth saves sessions to disk. On server restart, all staff sessions reconnect automatically — no re-scan QR needed.

📢

Broadcast

Send one message to hundreds of numbers in a single API call. Automatic delay between sends, per-number success/fail result returned.

❤️

Health Check

Public /api/health endpoint returns DB status, uptime, and active client count. Ready for uptime monitors and load balancers.

How it works

Two send modes — immediate or queued

Immediate Send

1

POST to /api/send-text with staff_id + phone + message

2

Server validates number is registered on WhatsApp

3

Message sent instantly, DB updated, messageId returned

4

ACK events update status to delivered → read automatically

⚠ Requires WA client to be connected

Queue Mode

1

POST to /api/queue-text (or queue-pdf / queue-media)

2

Row inserted to wa_outgoing with status=pending

3

Cron calls /api/run-cron?token=SECRET every N minutes

4

Processor sends pending messages, updates status, retries on failure

✓ Works even if client connects after queueing

Architecture

Your App

REST / Cron

This Server

Express + Socket.IO

Sessions

whatsapp-web.js

Delivery

WhatsApp Web

Persistence

MySQL

Real-time

Socket.IO → Browser

Push

Webhook → Your URL

Quick Start

Running in 4 steps

1

Clone & install

git clone https://github.com/ahmadfauzirahman99/wa-multi-staff-gateway.git
cd wa-multi-staff-gateway
npm install
2

Configure environment

cp .env.example .env
# Edit .env — set DB credentials and CRON_TOKEN
3

Create database

mysql -u root -p -e "CREATE DATABASE simrs_wa CHARACTER SET utf8mb4"
mysql -u root -p simrs_wa < schema-update.sql
4

Start server & connect

node server-new.js

# Open in browser:
# http://localhost:3030/main-dashboard.html  — Dashboard
# http://localhost:3030/qr-scanner.html      — Connect WhatsApp

API Overview

Simple REST API. Full interactive docs at /api-docs.html

Immediate Send

POST /api/send-text
POST /api/send-media
POST /api/broadcast-text

Queue

POST /api/queue-text
POST /api/queue-pdf
POST /api/queue-media
GET /api/run-cron?token=

Messages & Status

GET /api/outgoing?page=&limit=
GET /api/incoming?page=&limit=
GET /api/queue/stats
POST /api/queue/reset-failed

Utility

GET /api/health (no auth)
GET /api/clients
POST /api/logout
GET /api/templates

Example: Queue a message

curl -X POST http://localhost:3030/api/queue-text \
  -H "Content-Type: application/json" \
  -H "x-api-key: your-api-key" \
  -d '{
    "staff_id": "staff1",
    "wa_number": "628123456789",
    "message": "Hello from WA Gateway!",
    "scheduled_at": "2025-12-31 08:00:00"
  }'

# Response:
# { "success": true, "id": 42 }

Built with

Node.js 18+ Express 5 whatsapp-web.js Puppeteer Socket.IO 4 MySQL 2 dotenv express-rate-limit

Ready to deploy?

Self-hosted, open source, free forever. Your data stays on your server.