Skip to main content

Message Scheduler Setup

The message scheduler is a background service that automatically sends scheduled WhatsApp messages. It needs to run continuously on a server, separate from the Vercel-hosted frontend.
Important: The scheduler must run 24/7 on a VPS. Vercel’s serverless functions are not suitable for long-running background tasks. We recommend DigitalOcean, AWS EC2, or similar VPS providers.

How the Scheduler Works

The scheduler service:
  • Checks for pending messages every 30 seconds
  • Automatically sends messages when scheduled time arrives
  • Updates campaign status and tracking in real-time
  • Handles errors with retry logic and detailed logging
  • Runs independently from the web application

DigitalOcean VPS Setup

1. Create a Droplet

Get $200 in Credits

Use this referral link to get $200 in DigitalOcean credits!
Recommended specifications:
  • OS: Ubuntu 22.04 LTS (or latest LTS)
  • Plan: Basic Droplet with 1GB RAM minimum
  • CPU: 1 vCPU (sufficient for scheduler)
  • Storage: 25GB SSD
  • Region: Choose closest to your WAHA server
Authentication:
  • For beginners: Use password authentication
  • Recommended: Use SSH keys for better security

2. Initial Server Setup

Connect to your server and perform initial setup:

3. Deploy the Scheduler

4. Start Scheduler with PM2

PM2 ensures the scheduler runs continuously and restarts automatically if it crashes.
PM2 Startup: After running pm2 startup, it will output a command that you need to copy and execute. This ensures PM2 starts automatically when the server reboots.

PM2 Management Commands

Monitor the Scheduler

Control the Scheduler

PM2 Configuration File

For advanced configuration, create an ecosystem.config.js file:

Updating the Scheduler

When you need to deploy updates:

Troubleshooting

Scheduler Not Starting

Check logs:
Common issues:
  • Missing environment variables
  • Database connection failure
  • Invalid Prisma client (run pnpm prisma:generate)
  • Node.js version mismatch

Database Connection Issues

High Memory Usage

Scheduler Stopped After Reboot

Alternative VPS Providers

AWS EC2

Google Cloud Platform

Linode

Security Best Practices

  1. Firewall Configuration
  2. Keep System Updated
  3. Use SSH Keys
    • Disable password authentication
    • Use strong SSH key passphrases
  4. Environment Variables
    • Never commit .env.production to git
    • Use strong, unique credentials
  5. Monitor Logs

Performance Optimization

Log Rotation

Resource Monitoring

Next Steps

Environment Variables

Review all configuration options

Vercel Deployment

Deploy the web application