A simple CLI tool to send automated WhatsApp messages using Puppeteer and Chrome's remote debugging.
- Node.js (>= 18.0.0)
- pnpm package manager
- Google Chrome or Chromium installed (supports Linux, macOS, and Windows)
# Run directly with npx
npx whatsapp-spammer-cli <contact> "<message>" [--port PORT] [--count NUMBER] [--browser BROWSER]
# Or install globally
npm install -g whatsapp-spammer-cli
whatsapp-spammer <contact> "<message>" [--port PORT] [--count NUMBER] [--browser BROWSER]- Clone or download this project
- Install dependencies:
pnpm installAfter installing globally or using npx:
whatsapp-spammer <contact> "<message>" [--port PORT] [--count NUMBER] [--browser BROWSER]Run the script directly from source:
pnpm run dev <contact> <message> [--port PORT] [--count NUMBER] [--browser BROWSER]contact(required): The name of the contact as it appears in WhatsAppmessage(required): The message to send (use quotes for multi-word messages)--portor-p(optional): Chrome remote debugging port (default: 3005)--countor-c(optional): Number of messages to send (default: 1)--browseror-b(optional): Path to browser executable (auto-detected if not specified)--helpor-h: Display help information
Using installed CLI:
# Basic usage (default port 3005, 1 message)
whatsapp-spammer "John Doe" "Hello there!"
# Send 10 messages
whatsapp-spammer zkaynl7 "Testing 123" --count 10
# Custom port with 500 messages
whatsapp-spammer Mom "Miss you" --port 9222 --count 500
# Using short flags
whatsapp-spammer "John" "Hello" -p 3005 -c 50
# Specify custom browser path
whatsapp-spammer "Alice" "Test message" --browser /usr/bin/chromium
# Mix and match flags in any order
whatsapp-spammer "Bob" "Hello" --count 20 --port 9000 --browser chromeDevelopment mode:
# Basic usage
pnpm run dev "John Doe" "Hello there!"
# With custom options
pnpm run dev zkaynl7 "Testing 123" --count 10 --port 3005
# Display help
pnpm run dev --helpBuild the TypeScript source to JavaScript:
# Build the project
pnpm run build
# Run the built version
pnpm start <contact> <message> [--port PORT] [--count NUMBER] [--browser BROWSER]Example:
pnpm run build
pnpm start zkaynl7 "Hello World" --port 3005 --count 100The build output goes to the ./build/ directory. The package is configured to run the compiled build/index.js when installed via npm.
- The script automatically detects and launches Chrome/Chromium with remote debugging enabled via
launchBrowser- Supports Linux, macOS, and Windows through
detectBrowser - Checks common installation paths defined in
browserPaths - Allows manual browser path specification via
--browserflag - Throws a helpful error if Chrome is not found
- Supports Linux, macOS, and Windows through
- Connects to Chrome using Puppeteer via
sendWhatsappMessage - Opens WhatsApp Web at the URL defined in
WHATSAPP_WEB_URL - Searches for the specified contact using selectors from
selectors.ts - Sends the message the specified number of times
- Disconnects from the browser
.
├── src/
│ ├── index.ts # Main CLI entry point
│ ├── features/
│ │ ├── browser/
│ │ │ ├── constants.ts # Browser paths for different platforms
│ │ │ ├── detector.ts # Auto-detect browser installation
│ │ │ ├── launcher.ts # Launch Chrome with debugging
│ │ │ └── index.ts
│ │ └── whatsapp/
│ │ ├── client.ts # WhatsApp message sender
│ │ ├── selectors.ts # WhatsApp Web selectors
│ │ └── index.ts
│ └── shared/
│ └── contants.ts # Shared constants
├── tests/ # Test files
├── build/ # Compiled JavaScript output
└── package.json
- You must be logged into WhatsApp Web before running the script
- Chrome will stay open after the script finishes
- The script uses
/tmp/chrome-profileas the user data directory on Linux/macOS - The script automatically launches Chrome - no need to start it manually
- Make sure WhatsApp Web is accessible and you're logged in
- Cross-platform support: Works on Linux, macOS, and Windows
- If Chrome is not found, install Google Chrome or Chromium browser, or specify the path with
--browser - Default message count is 1 (changed from 1000 for safety)
- "Chrome/Chromium not found": Install Google Chrome or Chromium browser for your platform, or use
--browserto specify the path- Linux:
sudo apt install google-chrome-stableorsudo apt install chromium-browser - macOS: Download from google.com/chrome
- Windows: Download from google.com/chrome
- Linux:
- "Could not find the search box": Wait for WhatsApp Web to fully load (timeout is set to 120 seconds via
WHATSAPP_LOAD_TIMEOUT_MS), you may need to scan the QR code first - Connection refused: The script auto-launches Chrome, wait a few seconds for it to start
- Contact not found: Ensure the contact name matches exactly as shown in WhatsApp
- Port already in use: Chrome might already be running on that port, use a different port number with
--port
This project is licensed under the MIT License - see the LICENSE file for details.
Nick-Lemy ([email protected])