Skip to main content
This comprehensive guide covers everything you need to install, configure, and deploy WhatsApp Group Manager. Follow the sections relevant to your use case.

Prerequisites

Before installing WhatsApp Group Manager, ensure you have the following:

Required Software

Node.js 18+

JavaScript runtime required for Next.jsDownload Node.js

pnpm

Fast, disk-efficient package manager

MongoDB

NoSQL database for data storageMongoDB Atlas (Cloud) or local installation

WAHA Server

WhatsApp HTTP API for connectivityWAHA Documentation

Required Services

Option 1: MongoDB Atlas (Recommended for beginners)
  1. Create a free account at MongoDB Atlas
  2. Create a new cluster (free tier available)
  3. Add your IP to the whitelist (or allow access from anywhere for development)
  4. Create a database user with read/write permissions
  5. Get your connection string (looks like mongodb+srv://user:pass@cluster.mongodb.net/dbname)
Option 2: Local MongoDB
WAHA provides the WhatsApp connectivity layer. You have several options:Option 1: Docker (Recommended)
Option 2: Cloud HostedUse a cloud-hosted WAHA instance from providers or deploy to your own VPS.Option 3: NPM
Make note of your WAHA URL (default: http://localhost:3000) and API key for configuration.
Required for password reset and admin notification emails:
  1. Sign up at Mailgun
  2. Verify your email domain (or use sandbox domain for testing)
  3. Get your API key from the dashboard
  4. Note your domain name (e.g., mg.yourdomain.com)
Mailgun offers 5,000 free emails per month, perfect for most use cases.

Local Development Setup

1

Clone Repository

Clone the WhatsApp Group Manager repository from GitHub:
2

Install Dependencies

Install all project dependencies using pnpm:
This command will:
  • Install all packages from package.json
  • Run the postinstall script to generate Prisma client
  • Set up the development environment
3

Configure Environment Variables

Create your environment configuration file:
Edit .env with your actual configuration:
Never commit your .env file to version control. It contains sensitive credentials.
4

Generate Secure Secrets

Generate a cryptographically secure secret for Better Auth:
Use the output as your BETTER_AUTH_SECRET value.
5

Set Up Database

Push the Prisma schema to your MongoDB database:
This creates all necessary collections:
  • user - User accounts and authentication
  • session - User sessions
  • account - OAuth accounts and passwords
  • WhatsAppSession - WhatsApp connection sessions
  • WhatsAppGroup - Synced WhatsApp groups
  • MessageCampaign - Message campaigns
  • Message - Individual scheduled messages
  • Verification - Email verification tokens
Run pnpm db:studio to open Prisma Studio and visually inspect your database.
6

Start Development Server

Launch the Next.js application:
The application will start on http://localhost:3001
7

Start Message Scheduler

In a separate terminal, start the background scheduler:
The scheduler:
  • Runs independently of the Next.js app
  • Checks for pending messages every 30 seconds
  • Automatically sends messages at scheduled times
  • Logs all activity to the console
The scheduler must run continuously for automated message delivery. In production, use PM2 or similar process manager.

Production Deployment

Frontend Deployment (Vercel)

Deploy the Next.js application to Vercel for optimal performance:
1

Push to GitHub

Ensure your code is committed and pushed to GitHub:
2

Import to Vercel

  1. Visit Vercel
  2. Click “Add New Project”
  3. Import your GitHub repository
  4. Configure project settings:
    • Framework Preset: Next.js
    • Build Command: pnpm build (default)
    • Output Directory: .next (default)
3

Configure Environment Variables

Add these environment variables in Vercel dashboard:
Use different secrets and API keys for production. Never use development credentials in production.
4

Deploy

Click “Deploy” and wait for the build to complete. Vercel will:
  • Install dependencies
  • Run Prisma generation
  • Build the Next.js application
  • Deploy to CDN
Your app will be available at https://your-app.vercel.app

Backend Scheduler (DigitalOcean VPS)

The message scheduler needs to run on a server 24/7. Here’s how to deploy it to a VPS:
1

Create DigitalOcean Droplet

Create a VPS to run the scheduler:
  1. Get $200 in credits (referral link)
  2. Create a new Droplet:
    • Distribution: Ubuntu 22.04 LTS
    • Plan: Basic ($6/month, 1GB RAM is sufficient)
    • Datacenter: Choose closest to your WAHA server
    • Authentication: SSH keys recommended (or password for beginners)
A basic 1GB RAM droplet can handle thousands of scheduled messages efficiently.
2

Initial Server Setup

Connect to your server and set up the environment:
3

Deploy Application

Clone your repository and set up the scheduler:
Add your production environment variables:
Save and exit (Ctrl+X, then Y, then Enter).
4

Generate Prisma Client

Generate the Prisma client for production:
5

Start with PM2

Use PM2 to run the scheduler as a persistent background service:
The scheduler will now:
  • Run automatically on server restart
  • Restart automatically if it crashes
  • Log all activity for monitoring
6

Monitor Scheduler

Useful PM2 commands for managing the scheduler:

Updating Production Deployment

To update your production scheduler:

Environment Variables Reference

string
required
MongoDB connection stringFormat: mongodb+srv://username:password@cluster.mongodb.net/database-nameExample: mongodb+srv://admin:pass123@cluster0.mongodb.net/whatsapp-prod
string
required
Base URL of your WAHA serverExample: http://localhost:3000 or https://waha.yourdomain.com
string
required
API key for authenticating with WAHAExample: abc123xyz789
string
required
Secret key for Better Auth session encryptionGenerate with: openssl rand -base64 32Example: xK8vN2mP9qR4sT5uV6wX7yZ8aB1cD2eF3gH4iJ5kL6==
string
required
Base URL of your applicationDevelopment: http://localhost:3001Production: https://your-app.vercel.app
string
required
Mailgun API key for sending emailsFormat: key-xxxxxxxxxxxxxxxxxxxxxxxxFind in: Mailgun Dashboard → Settings → API Keys
string
required
Your verified Mailgun domainExample: mg.yourdomain.com or sandboxxxxx.mailgun.org
string
required
Email address to send from (must use Mailgun domain)Example: noreply@yourdomain.com
string
required
Admin email for receiving notificationsExample: admin@yourdomain.com
string
Admin WhatsApp number for notificationsFormat: Include country code with +Example: +1234567890
Show or hide footer in applicationDefault: trueOptions: true or false

Database Schema Overview

The application uses these main collections:
  • user: User accounts with roles (ADMIN, USER, GUEST)
  • session: Active user sessions with expiry
  • account: Password hashes and OAuth provider data
  • verification: Email verification tokens
  • WhatsAppSession: Connected WhatsApp accounts
    • sessionName: Unique session identifier
    • phoneNumber: Connected phone number
    • status: CONNECTED or DISCONNECTED
  • WhatsAppGroup: Synced WhatsApp groups
    • groupName: Display name
    • groupId: WhatsApp group ID
  • MessageCampaign: Scheduled campaigns
    • title: Campaign name
    • template: Message template with placeholders
    • sendTimeUtc: Scheduled send time
    • status: DRAFT, SCHEDULED, IN_PROGRESS, COMPLETED, CANCELLED, FAILED
  • Message: Individual messages to send
    • content: Processed message content
    • scheduledAt: When to send
    • sentAt: When actually sent
    • isSent: Delivery status

Available Scripts

Troubleshooting

Error: @prisma/client did not initialize yetSolution:
Error: Error connecting to database or ECONNREFUSEDSolutions:
  • Verify DATABASE_URL is correctly formatted
  • For MongoDB Atlas:
    • Whitelist your IP address in Network Access
    • Check username/password are URL-encoded
    • Ensure database user has read/write permissions
  • For local MongoDB:
    • Ensure MongoDB service is running
    • Try mongodb://localhost:27017/whatsapp-manager
Error: Cannot connect to WAHA serverSolutions:
  • Verify WAHA is running: curl http://localhost:3000/health
  • Check WAHA_API_URL points to correct address
  • Verify WAHA_API_KEY matches WAHA configuration
  • Ensure no firewall blocking the connection
Error: Failed to send email or Mailgun errorsSolutions:
  • Verify Mailgun API credentials are correct
  • Check domain is verified in Mailgun dashboard
  • Ensure FROM_EMAIL uses your Mailgun domain
  • For sandbox domain, add recipient email to authorized recipients
Issue: Scheduled messages remain in SCHEDULED statusSolutions:
  • Ensure scheduler is running: pnpm scheduler:start
  • Check scheduler logs for errors
  • Verify scheduled time is in the past (UTC)
  • Check WhatsApp session is CONNECTED
  • Ensure WAHA server is accessible from scheduler
Error: Port 3001 is already in useSolution:

Security Best Practices

Follow these security guidelines for production deployments:
  • Never commit .env file to version control
  • Use strong, unique secrets for BETTER_AUTH_SECRET in production
  • Rotate API keys regularly (Mailgun, WAHA)
  • Enable MongoDB authentication and use strong passwords
  • Restrict MongoDB network access to your server IPs only
  • Use HTTPS for production deployments (Vercel provides this automatically)
  • Set up IP whitelisting for WAHA if possible
  • Regularly update dependencies with pnpm update
  • Monitor logs for suspicious activity
  • Backup database regularly (MongoDB Atlas has automated backups)

Next Steps

After successful installation:

User Guide

Learn how to use the dashboard and manage campaigns

API Documentation

Explore tRPC API endpoints and integration options

Contributing

Contribute to the project on GitHub

Support

Get help and report issues