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.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!
- 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
- 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 Management Commands
Monitor the Scheduler
Control the Scheduler
PM2 Configuration File
For advanced configuration, create anecosystem.config.js file:
Updating the Scheduler
When you need to deploy updates:Troubleshooting
Scheduler Not Starting
Check logs:- 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
-
Firewall Configuration
-
Keep System Updated
-
Use SSH Keys
- Disable password authentication
- Use strong SSH key passphrases
-
Environment Variables
- Never commit
.env.productionto git - Use strong, unique credentials
- Never commit
-
Monitor Logs
Performance Optimization
Log Rotation
Resource Monitoring
Next Steps
Environment Variables
Review all configuration options
Vercel Deployment
Deploy the web application