Public
Remixed
WhatsApp broadcast dashboard - UI on Val Town, bot on Termux
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

📢 WhatsApp Broadcast Dashboard

A web-based dashboard for broadcasting messages to WhatsApp groups with intelligent safety rules.

Architecture

  • Dashboard (Val Town) — Web UI + API. Serves the dashboard page and stores state in blob storage.
  • Bot (Termux) — Runs whatsapp-web.js on your phone. Connects to WhatsApp, polls the dashboard for commands, and reports status back.
┌─────────────────┐     poll commands      ┌──────────────────┐
│  Val Town        │ ◄──────────────────── │  Termux Bot       │
│  Dashboard       │ ────────────────────► │  (whatsapp-web.js)│
│  (this val)      │     report status      │  (your phone)     │
└─────────────────┘                         └──────────────────┘

Dashboard Features

  • 📱 Scan QR code directly in browser
  • ✏️ Write/edit broadcast message with {group} placeholder
  • ▶️ Start, ⏸️ Pause/Resume, ⏹️ Stop controls
  • 📊 Real-time progress (sent, remaining, progress bar)
  • 📋 Activity log
  • 🟢 Bot online/offline indicator

API Endpoints

MethodPathDescription
GET/api/statusCurrent state (polled by dashboard every 2s)
POST/api/messageUpdate broadcast message
POST/api/startStart broadcasting
POST/api/pauseToggle pause/resume
POST/api/stopStop and reset
POST/api/bot-updateBot reports status + gets command
GET/api/commandBot polls for commands
POST/api/command/ackBot acknowledges command
POST/api/resetFull state reset

Safety Rules (built into the bot)

  • ⏱️ Random delays: 30–90 seconds between messages
  • 📦 Batch cooldown: 2 hours after every 12 messages
  • 📅 Daily limit: 50 messages per day
  • 🕘 Working hours: 9 AM – 9 PM only
  • ⌨️ Typing simulation before each message
  • 💾 Progress persistence via Val Town blob storage

Setup

1. Dashboard (already deployed)

Your dashboard is live at the URL shown in main.tsx's endpoint.

2. Termux Bot

Install Termux from F-Droid (not Play Store), then run:

pkg update && pkg upgrade -y pkg install nodejs git python build-base -y npm install whatsapp-web.js qrcode

Download termux-bot.js from this val, then:

node termux-bot.js

3. Connect

  1. Open the dashboard URL in your browser
  2. The bot will send a QR code — scan it with WhatsApp
  3. Write your message (use {group} for personalization)
  4. Hit Start

Files

FilePurpose
main.tsxHTTP handler — API routes + static file serving
index.htmlDashboard UI
style.cssDark theme styling
script.jsFrontend polling and controls
termux-bot.jsBot script for Termux (download and run on phone)

⚠️ Safety Reminder

  • Use a spare/secondary WhatsApp number
  • Keep daily limit low (20–30) for the first few days
  • If you see rate limit errors, stop immediately and increase delays