A powerful web application built with the T3 Stack to manage WhatsApp groups and schedule messages## π How It Works
- Users can sign up and await admin approval to access the dashboard
- Admins receive notifications via WhatsApp and email for new registrations
- Comprehensive user management with role-based access control (ADMIN, USER, GUEST)
Create message campaigns by:
- Selecting target WhatsApp groups with search and pagination
- Writing your message content with dynamic placeholders (e.g.,
{days_left}) - Setting the schedule date and time with timezone support
- Real-time progress tracking with completion percentages
The background scheduler service:
- Checks for pending messages every 30 seconds
- Automatically sends messages when scheduled time arrives
- Updates campaign status and tracking information in real-time
- Handles errors and retry logic with detailed logging
- Monitor all WhatsApp sessions and their connection status
- View connected groups and active campaigns
- Approve/reject user registrations with instant notifications
- Manage user roles and permissions
- Restart WhatsApp sessions when needed
- Dual-Channel Notifications: Admin notifications sent via both WhatsApp and email
- Password Security: Email notifications for password changes
- Registration Alerts: Instant notifications when new users register
- Fallback System: If WhatsApp notification fails, email is automatically sent application allows you to create message campaigns, schedule them for specific times, and automatically send them to your WhatsApp groups.
- π Secure Authentication - User authentication and authorization with password reset
- π§ Email Password Reset - Secure password reset via email using Mailgun
- οΏ½ Admin Dashboard - Comprehensive admin panel for user and campaign management
- π Multi-Channel Notifications - Admin notifications via both WhatsApp and email
- οΏ½π Campaign Management - Create and manage message campaigns with progress tracking
- β° Message Scheduling - Schedule messages for specific dates and times
- π€ Automated Sending - Background service that automatically sends scheduled messages
- π Campaign Analytics - Track campaign status and completion with detailed progress bars
- π― Group Management - Manage multiple WhatsApp groups with search and pagination
- π₯ User Management - Admin approval system for new user registrations
- π± Responsive Design - Works perfectly on desktop and mobile
- π Session Management - Auto-refresh WhatsApp session status and restart capabilities
- Framework: Next.js 15 with App Router
- Authentication: Better Auth v1.2+
- Database: MongoDB with Prisma v6.5+
- Email Service: Mailgun for password reset and admin notifications
- Styling: Tailwind CSS v4.0+
- Type Safety: TypeScript v5.8+
- API: tRPC v11+ for type-safe API calls
- State Management: TanStack Query for server state
- Package Manager: pnpm v10.4+
- Date Handling: Luxon for timezone-aware scheduling
Before you begin, ensure you have the following installed:
- Node.js 18+
- pnpm
- MongoDB database
- WhatsApp Web API Server (WAHA)
-
Clone the repository
git clone https://github.com/jevil25/whatsapp-group-manager.git cd whatsapp-group-manager -
Install dependencies
pnpm install
-
Set up environment variables Create a
.envfile in the root directory with the following content:# Database DATABASE_URL="mongodb+srv://username:password@cluster.mongodb.net/whatsapp-manager" # WhatsApp API WAHA_API_URL="http://localhost:3000" WAHA_API_KEY="your-waha-api-key" # Better Auth BETTER_AUTH_SECRET="your-better-auth-secret" BETTER_AUTH_URL="http://localhost:3000" # Mailgun (for password reset emails) MAILGUN_API_KEY="your-mailgun-api-key" MAILGUN_DOMAIN="your-mailgun-domain" FROM_EMAIL="noreply@yourdomain.com" # Admin Configuration ADMIN_EMAIL="admin@yourdomain.com" ADMIN_PHONE_NUMBER="+1234567890" # Optional - for WhatsApp notifications
-
Generate Prisma client
pnpm prisma:generate
-
Push database schema
pnpm db:push
-
Start the development server
pnpm dev
Visit https://whatsapp-groups-manager.vercel.app/ to see your application running!
Start by connecting your WhatsApp account to the system. Scan the QR code with your WhatsApp mobile app.
Use your WhatsApp mobile app to scan the QR code and establish the connection.
Once connected, you can see your WhatsApp session status and manage your campaigns.
View and manage all your connected WhatsApp groups in one place.
Create and schedule messages for your WhatsApp groups with an easy-to-use form.
Manage all aspects of your WhatsApp campaigns from the comprehensive admin dashboard.
- User Approval System: New users must be approved by admins before gaining access
- Multi-Channel Notifications: Admins receive notifications via both WhatsApp and email for new registrations
- Real-time Session Monitoring: Live status updates for WhatsApp sessions with restart capabilities
- User Role Management: Promote users to admin, revoke access, or delete users
- Progress Tracking: Visual progress bars showing campaign completion status
- Dynamic Message Templates: Support for placeholders like
{days_left}in messages - Advanced Group Selection: Search and pagination for WhatsApp groups
- Campaign Analytics: Detailed metrics on message delivery and completion
- Password Change Notifications: Users receive email confirmations for password changes
- Session Management: Automatic session refresh and manual restart options
- Better Error Handling: Comprehensive error messages and retry logic
Users can sign up and authenticate to access the dashboard where they can manage their WhatsApp campaigns.
Create message campaigns by:
- Selecting target WhatsApp groups
- Writing your message content
- Setting the schedule date and time
- Configuring campaign settings
The background scheduler service:
- Checks for pending messages every 30 seconds
- Automatically sends messages when scheduled time arrives
- Updates campaign status and tracking information
- Handles errors and retry logic
-
Push your code to GitHub
-
Connect to Vercel
- Visit Vercel
- Import your GitHub repository
- Configure environment variables in Vercel dashboard
-
Environment Variables for Vercel
DATABASE_URL=mongodb+srv://username:password@cluster.mongodb.net/whatsapp-manager BETTER_AUTH_SECRET=your-production-secret BETTER_AUTH_URL=https://your-app.vercel.app WAHA_API_KEY=your-waha-api-key WAHA_BASE_URL=http://your-waha-server:3000
4. **Deploy**
- Vercel will automatically build and deploy your application
- Your app will be available at `https://your-app.vercel.app`
### DigitalOcean VPS Setup for Message Scheduler
The message scheduler needs to run continuously on a server. Here's how to set it up on a DigitalOcean VPS:
#### 1. Create a DigitalOcean Droplet
[**Get $200 in credits with this referral link!**](https://m.do.co/c/ddd03661770c)
- Choose Ubuntu 22.04 LTS
- Select at least 1GB RAM droplet
- Add your password (as its easier for beginners, but SSH keys are recommended)
#### 2. Server Setup
```bash
# Connect to your server
ssh root@your-server-ip
(enter your password or use your SSH key)
# Update system
apt update && apt upgrade -y
# Install Node.js 18+
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
apt-get install -y nodejs
# Install pnpm
npm install -g pnpm
# Install PM2 for process management
npm install -g pm2
# Clone your repository
git clone https://github.com/yourusername/whatsapp-group-manager.git
cd whatsapp-group-manager
# Install dependencies
pnpm install
# Create production environment file
nano .env.production
# Add your environment variables
DATABASE_URL="your-mongodb-connection-string"
WAHA_API_KEY="your-waha-api-key"
WAHA_BASE_URL="http://your-waha-server:3000"
# Generate Prisma client
pnpm prisma:generate
# Start the scheduler with PM2
pm2 start src/scripts/messageScheduler.ts \
--interpreter ./node_modules/.bin/tsx \
--name whatsapp-scheduler \
--env production
# Save PM2 configuration
pm2 save
pm2 startup# Check status
pm2 status
# View logs
pm2 logs whatsapp-scheduler
# Restart if needed
pm2 restart whatsapp-scheduler| Variable | Description | Required |
|---|---|---|
DATABASE_URL |
MongoDB connection string | β |
BETTER_AUTH_SECRET |
Secret key for Better Auth | β |
BETTER_AUTH_URL |
Base URL for your application | β |
WAHA_API_KEY |
API key for WhatsApp API | β |
WAHA_API_URL |
Base URL for WAHA server | β |
MAILGUN_API_KEY |
Mailgun API key for sending emails | β |
MAILGUN_DOMAIN |
Mailgun domain for sending emails | β |
FROM_EMAIL |
Email address to send from | β |
ADMIN_EMAIL |
Admin email for notifications | β |
ADMIN_PHONE_NUMBER |
Admin phone number for WhatsApp notifications | β |
# Development
pnpm dev # Start development server
pnpm build # Build for production (includes Prisma push & generate)
pnpm start # Start production server
pnpm preview # Build and start in preview mode
# Database
pnpm db:push # Push schema to database
pnpm db:studio # Open Prisma Studio
pnpm prisma:generate # Generate Prisma client
# Message Scheduler
pnpm scheduler:start # Start message scheduler locally
# Code Quality
pnpm lint # Run ESLint
pnpm lint:fix # Fix ESLint issues
pnpm typecheck # Run TypeScript check
pnpm check # Run lint and typecheck together
pnpm format:check # Check code formatting
pnpm format:write # Format code with Prettiersrc/
βββ app/ # Next.js app directory
β βββ _components/ # Reusable components
β β βββ auth/ # Authentication components
β β βββ whatsapp/ # WhatsApp-related components
β βββ api/ # API routes
β βββ auth/ # Authentication pages
β βββ admin/ # Admin dashboard
βββ client/ # Client-side auth configuration
βββ scripts/ # Background scripts
β βββ messageScheduler.ts # Message scheduling service
βββ server/ # Server-side code
β βββ api/ # tRPC routers
β β βββ routers/ # Individual route handlers
β βββ auth.ts # Authentication config
β βββ db.ts # Database connection
β βββ mailgun.ts # Email service integration
β βββ user-service.ts # User management service
βββ styles/ # Global styles
βββ trpc/ # tRPC configuration
βββ types/ # TypeScript type definitions
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Aaron Nazareth
- π GitHub: @jevil25
- πΊ YouTube: @JevilCodes
- π¦ X: @jevil257






