How I Built a WhatsApp Bot to Send Real-Time Event Updates Using Node.js and AWS
Using Baileys with a lightweight EC2 instance, WebSocket events, DynamoDB, PM2, and EventBridge provided a simple, low-cost way to automate event coordination directly through the communication platform the volunteers were already using.
We were organizing AWS Community Day Singapore 2026 a 300+ attendee tech conference. During the event, we needed a way to keep our volunteer team updated in real-time: how many people checked in, which speakers arrived, and when t-shirt stock was running low.
The solution? A WhatsApp bot that automatically sends updates to our team group chat every 15 minutes, with instant alerts when something important happens.
Here's how I built and deployed it.
The Problem
Our check-in system was web-based volunteers scanned QR codes, attendees got marked in DynamoDB. But the coordination team was on WhatsApp. They needed to know:
- How many people have checked in so far?
- Has Speaker X arrived yet?
- Are we running low on size M t-shirts?
Manually checking the dashboard and typing updates into WhatsApp every few minutes? Not ideal when you're also managing 10 other things at a conference.
Why WhatsApp (and Why Not Telegram/Slack)
Our entire volunteer team was already on WhatsApp. Asking 20+ people to install Telegram or join a Slack workspace the day before the event wasn't realistic. We needed to meet people where they already were.
The Tech Stack
- Baileys a Node.js library that connects directly to WhatsApp via WebSocket (no browser needed)
- AWS EC2 (t3.micro) to host the bot
- AWS DynamoDB our attendee database
- WebSocket to receive real-time check-in events
- pm2 process manager to keep the bot alive
- EventBridge Scheduler to auto-start/stop the EC2 instance

Why Baileys Over whatsapp-web.js
I initially tried
whatsapp-web.js , the more popular library. It uses Puppeteer to run a headless Chrome instance that loads WhatsApp Web. On paper, it works. In practice:- Puppeteer 24.x broke compatibility completely
- The
getChats()call failed with a cryptic minified error
- It requires ~500MB of RAM just for Chrome
- Node.js v24 made things worse
After wasting an hour trying different Puppeteer versions and web cache workarounds, I switched to Baileys. It connects directly to WhatsApp's WebSocket no browser, no Puppeteer, no headaches. Works perfectly on Node 20+ and uses maybe 50MB of RAM.
Step 1: The Bot Script
Here's the core structure. The bot does three things:
- Connects to WhatsApp and finds our group
- Sends stats every 15 minutes
- Listens to a WebSocket for real-time speaker check-ins
const { default: makeWASocket, useMultiFileAuthState, DisconnectReason } = require('@whiskeysockets/baileys');const qrcode = require('qrcode-terminal');const WebSocket = require('ws');
const GROUP_NAME = 'Event Volunteers';const INTERVAL_MINUTES = 15;
async function startBot() { const { state, saveCreds } = await useMultiFileAuthState('./whatsapp_auth');
const sock = makeWASocket({ auth: state }); sock.ev.on('creds.update', saveCreds);
sock.ev.on('connection.update', async (update) => { const { connection, lastDisconnect, qr } = update;
if (qr) { console.log('Scan this QR with WhatsApp > Linked Devices:'); qrcode.generate(qr, { small: true }); }
if (connection === 'close') { const reason = lastDisconnect?.error?.output?.statusCode; if (reason !== DisconnectReason.loggedOut) { startBot(); // auto-reconnect } }
if (connection === 'open') { console.log('Connected!'); await new Promise(r => setTimeout(r, 5000));
const groups = await sock.groupFetchAllParticipating(); const target = Object.entries(groups) .find(([id, meta]) => meta.subject === GROUP_NAME);
if (!target) { console.error(`Group "${GROUP_NAME}" not found`); return; }
const [groupId] = target;
// Send periodic updates await sendStats(sock, groupId); setInterval(() => sendStats(sock, groupId), INTERVAL_MINUTES * 60 * 1000);
// Listen for real-time events listenForEvents(sock, groupId); } });}
startBot();
Step 2: Fetching Stats from DynamoDB
Every 15 minutes, the bot scans our attendee table and builds a message:
const { DynamoDBClient } = require('@aws-sdk/client-dynamodb');const { DynamoDBDocumentClient, ScanCommand } = require('@aws-sdk/lib-dynamodb');
const docClient = DynamoDBDocumentClient.from( new DynamoDBClient({ region: 'ap-southeast-1' }));
async function sendStats(sock, groupId) { const result = await docClient.send( new ScanCommand({ TableName: 'attendees' }) ); const items = result.Items || [];
const total = items.length; const checkedIn = items.filter(i => i.CheckIn === '1').length; const tshirtIssued = items.filter(i => i.TshirtIssued).length;
const now = new Date().toLocaleTimeString('en-SG', { timeZone: 'Asia/Singapore' });
const message = `📊 *Check-in Update* (${now})\n\n` + `✅ Checked in: *${checkedIn}* / ${total}\n` + `👕 T-shirts issued: *${tshirtIssued}*\n` + `⏳ Remaining: *${total - checkedIn}*`;
await sock.sendMessage(groupId, { text: message });}The actual message our team saw every 15 minutes:
📊 Check-in Update (9:30:00 AM)
✅ Checked in: 142 / 267👕 T-shirts issued: 138⏳ Remaining: 125
🛠️ Workshops: • Kiro workshop: 28/58 checked in • Amazon Quick Workshop: 12/17 checked in
🚨 T-Shirt Stock Alert: ⚠️ Low stock (<2): S (1 left)
👕 T-Shirt Stock: ⚠️ S: 1 remaining ✅ M: 12 remaining ✅ L: 8 remaining
Step 3: Real-Time Speaker Alerts
Our check-in Lambda broadcasts events via API Gateway WebSocket. The bot listens and sends instant alerts when a speaker checks in:
function listenForEvents(sock, groupId) { const WS_URL = 'wss://your-api.execute-api.region.amazonaws.com/prod';
function connect() { const ws = new WebSocket(WS_URL);
ws.on('message', async (data) => { const event = JSON.parse(data.toString());
// Only alert on check-in, not t-shirt issue if (event.action === 'tshirt') return;
// Only alert for speakers if (event.attendeesType?.toLowerCase() === 'speaker') { const name = `${event.firstName} ${event.lastName}`; const now = new Date().toLocaleTimeString('en-SG', { timeZone: 'Asia/Singapore' });
await sock.sendMessage(groupId, { text: `🎤 *Speaker Arrived!* (${now})\n\n⭐ *${name}* has checked in!` }); } });
ws.on('close', () => setTimeout(connect, 5000)); }
connect();}When a speaker scanned their QR code at registration, our WhatsApp group instantly got:
🎤 Speaker Arrived! (9:15:22 AM)
⭐ Imalka De Silva has checked in!This was surprisingly useful — our AV team knew exactly when to prepare the mic and slide deck.
Step 4: Deploying to EC2
The bot needs a persistent connection, so Lambda won't work (15-min timeout, no persistent state). A t3.micro EC2 instance is perfect — it's free tier eligible and the bot barely uses any resources.
The deployment flow:
# 1. Launch EC2 (Ubuntu, t3.micro)# 2. Install Node.js and pm2# 3. Copy bot code + auth session# 4. Start with pm2 (auto-restarts on crash/reboot)
scp whatsapp-bot.cjs ubuntu@<IP>:~/wa-bot/scp -r whatsapp_auth ubuntu@<IP>:~/wa-bot/
ssh ubuntu@<IP> "cd ~/wa-bot && \ npm install @whiskeysockets/baileys qrcode-terminal ws \ @aws-sdk/client-dynamodb @aws-sdk/lib-dynamodb && \ pm2 start whatsapp-bot.cjs --name wa-bot && \ pm2 save && pm2 startup"Key detail: I authenticated locally first (scanned the QR on my laptop), then copied the
whatsapp_auth/ folder to EC2. This means the bot connects immediately on EC2 without needing to scan again.
Step 5: Auto Start/Stop with EventBridge
Our event ran from 8 AM to 3 PM. No reason to keep the bot running (and paying for EC2) outside those hours.
I used EventBridge Scheduler to start the instance at 7:30 AM and stop it at 3:30 PM:
# Start at 7:30 AM SGT (23:30 UTC previous day)aws scheduler create-schedule \ --name start-wa-bot \ --schedule-expression "at(2026-08-22T23:30:00)" \ --schedule-expression-timezone "UTC" \ --flexible-time-window '{"Mode":"OFF"}' \ --target '{ "Arn": "arn:aws:scheduler:::aws-sdk:ec2:startInstances", "RoleArn": "arn:aws:iam::123456789:role/ec2-scheduler-role", "Input": "{\"InstanceIds\":[\"i-0abc123\"]}" }' \ --action-after-completion DELETEWith
--action-after-completion DELETE , the schedule cleans itself up after running. No leftover resources.On the EC2 side, pm2 with
pm2 startup means the bot auto-starts when the instance boots. So the full flow is: EventBridge starts EC2 → instance boots → pm2 starts the bot → bot connects to WhatsApp and begins sending updates. Fully automated.
What I Learned
1. Baileys > whatsapp-web.js for production use.
No browser dependency means fewer things that can break. The library connects directly via WebSocket and uses fraction of the RAM.
2. Copy the auth session, don't re-scan on the server.
Authenticate locally where you can easily scan the QR, then copy
whatsapp_auth/ to EC2. Saves you from SSHing in and trying to scan a QR code in a remote terminal.3. "Bad MAC" and "Session not found" errors are harmless.
When the bot reconnects after being offline, it can't decrypt messages that were sent while it was down. These errors flood the logs but don't affect sending.
4. The WebSocket approach for real-time alerts is cleaner than polling.
Instead of scanning DynamoDB every 30 seconds to detect new check-ins, having the Lambda broadcast via WebSocket means instant notifications with zero extra cost.
5. Schedule your EC2, don't leave it running.
EventBridge Scheduler + pm2 startup means you get fully automated start/stop. Our bot ran for 8 hours on event day and cost about $0.10.
Costs
Resource | Cost |
|---|---|
EC2 t3.micro (8 hours) | ~$0.10 |
DynamoDB scans | ~$0.01 |
EventBridge Scheduler | Free |
Total for event day | ~$0.11 |
The Result
During our event, the WhatsApp bot sent 32 periodic updates and 14 real-time speaker alerts. Our volunteer team always knew the current state without checking a dashboard. When size S t-shirts hit zero, everyone found out within 15 minutes. When the keynote speaker arrived, the AV team was ready before they even reached the stage.
For a few hours of setup and $0.11 in AWS costs, the coordination improvement was significant.
If you're organizing a tech event and your coordination happens on WhatsApp, this approach works remarkably well. The key insight is using Baileys instead of the browser-based alternatives — it's the difference between something that works in development and something that works in production.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article