Installation
This guide walks you through the complete installation process for the WhatsApp Assistant Bot, from system prerequisites to running the bot for the first time.Prerequisites
Before you begin, ensure you have the following installed:Node.js 18+
Download from nodejs.org or use a version manager like nvm
PostgreSQL
Install from postgresql.org or use a managed service
Youβll also need a PostgreSQL database with a connection URL. This can be:
- A local PostgreSQL installation
- A managed database service (AWS RDS, Supabase, Railway, etc.)
Verify Node.js version
Check that you have Node.js 18 or higher:Set up PostgreSQL
You need a PostgreSQL database with SSL enabled. Here are a few options:- Local PostgreSQL
- Supabase (recommended)
- Railway
Install PostgreSQL locally and create a database:
Clone the repository
Install dependencies
Install all required packages:The repository includes
yt-dlp in the bin/ directory for Instagram video downloads. This binary is pre-installed and requires no additional setup.Core dependencies
Core dependencies
- baileys (^7.0.0-rc.9) - WhatsApp Web API library
- postgres (^3.4.7) - PostgreSQL client
- drizzle-orm (^0.45.1) - TypeScript ORM for PostgreSQL
- express (^5.2.1) - Web server for OAuth callbacks
- dotenv (^17.2.3) - Environment variable management
Utilities
Utilities
- sharp (^0.34.5) - Image processing for stickers
- wa-sticker-formatter (^4.4.4) - WhatsApp sticker creation
- node-cron (^4.2.1) - Scheduled task execution for reminders
- moment (^2.30.1) - Date/time parsing and formatting
- pino (^9.6.0) - Logging library
- qrcode-terminal (^0.12.0) - QR code display in terminal
Development dependencies
Development dependencies
- typescript (^5.7.2) - TypeScript compiler
- tsx (^4.19.2) - TypeScript execution for development
- drizzle-kit (^0.31.8) - Database migration tools
- @types/node, @types/express - TypeScript type definitions
Environment configuration
Create .env file
Copy the example environment file:If
.env.example doesnβt exist, create a new .env file:Environment variable reference
| Variable | Required | Description | Example |
|---|---|---|---|
DATABASE_URL | Yes | PostgreSQL connection string with SSL | postgres://user:pass@host:5432/db |
PORT | No | Main Express server port | 3000 (default) |
SPOTIFY_CLIENT_ID | No | Spotify OAuth client ID | From Spotify Developer Dashboard |
SPOTIFY_CLIENT_SECRET | No | Spotify OAuth client secret | From Spotify Developer Dashboard |
The Spotify OAuth callback server runs on port 8888 (hardcoded in
src/index.ts:39). This port is not configurable via environment variables.Database setup
The bot uses Drizzle ORM with PostgreSQL. The schema is defined insrc/db/schema.ts:
src/db/schema.ts
Generate database migrations
Create migration files from your schema:This creates SQL migration files in the
drizzle/ folder.Run migrations
Apply migrations to your database:This creates all necessary tables:
users- User profiles and settingstodos- Task list itemsreminders- Scheduled notificationsnotes- Saved text snippetstimers- Active countdown timers
Build the project
Compile TypeScript to JavaScript:tsc) and creates compiled files in the dist/ folder:
The
dist/ folder is created automatically and should not be committed to version control (itβs in .gitignore).Run the bot
You can run the bot in development or production mode:Development mode
Usestsx watch to automatically restart on file changes:
package.json
- Testing changes
- Debugging
- Adding new features
Production mode
Runs the compiled JavaScript fromdist/:
package.json
- Deployment to servers
- Running with process managers (PM2, systemd)
- Production environments
First run
When you start the bot for the first time, youβll see:Scan the QR code
- Open WhatsApp on your phone
- Go to Settings β Linked Devices
- Tap Link a Device
- Scan the QR code in your terminal
Verify installation
Run through this checklist to ensure everything works:β
Database connection successful
β Database connection successful
Check the logs for:If you see an error:
- Verify
DATABASE_URLin.env - Ensure PostgreSQL is running
- Check SSL configuration
β
WhatsApp connection established
β WhatsApp connection established
After scanning QR code, look for:If connection fails:
- Delete
auth_info/and try again - Check for WhatsApp Web version compatibility
- Ensure no other sessions are blocking
β
Commands work in DMs
β Commands work in DMs
Send
!help to yourself in WhatsApp. You should receive a list of commands.If no response:- Verify youβre messaging yourself (DM), not a group
- Check terminal logs for errors
- Ensure the bot process is running
β
Data persistence works
β Data persistence works
Test data persistence:
- Add a todo:
!todo add Test item - Stop the bot (Ctrl+C)
- Restart:
npm run dev - List todos:
!todo list
Troubleshooting
Module not found errors
Module not found errors
Database connection errors
Database connection errors
- Verify
DATABASE_URLformat:postgres://user:pass@host:port/db - Ensure PostgreSQL server is accessible
- Check firewall rules
- For managed databases, verify SSL is enabled
TypeScript compilation errors
TypeScript compilation errors
QR code not displaying
QR code not displaying
If the QR code doesnβt appear:
- Check that
printQRInTerminalis set correctly insrc/index.ts - Ensure your terminal supports Unicode characters
- Try a different terminal emulator
Port already in use
Port already in use
- Change
PORTin.envto a different value - Kill the process using port 3000:
Next steps
Quickstart guide
Send your first commands and test all features
Command reference
Learn all available commands and their usage
Deployment
Deploy to a VPS or cloud provider for 24/7 uptime
Customization
Add custom commands and modify bot behavior