A Node.js application for sending WhatsApp messages to multiple recipients from CSV files using the whatsapp-web.js library.
- Authentication via QR code scanning
- CSV import functionality for sending messages to contacts
- Automatic phone number formatting
- Configurable delay between messages
- Check if numbers are registered on WhatsApp before sending
- Message personalization with
{name}placeholder - Parallel message processing with controlled concurrency
- Modern JavaScript features (ES Modules)
- Automatic application exit when processing is complete
- Default contacts file for simplified usage
- Support for multiline messages
- Node.js (v22 or later)
- PNPM package manager
- A phone with WhatsApp installed and connected to the internet
- Clone this repository
- Install dependencies:
pnpm install - Create a
.envfile (or use the existing one) with the following variables:DELAY_BETWEEN_MESSAGES=3000 - Create your contacts file by copying the sample:
Then edit
cp sample.contacts.csv contacts.csvcontacts.csvwith your actual contacts. This file is git-ignored for privacy.
The simplest way is to just specify the message (the app will use contacts.csv by default):
node src/index.js "Hello {name}, this is a test message"Or use the start script:
pnpm start "Hello {name}, this is a test message"If you want to use a different CSV file, you can specify it as the first argument:
node src/index.js path/to/other/file.csv "Hello {name}, this is a test message"The most reliable way to send multiline messages is to edit the src/csv-blast.js file directly. You can uncomment and modify the example there:
// In src/csv-blast.js, uncomment and edit this section:
const messageText = `Hello {name}! 👋
This is a multiline message with proper formatting.
It supports multiple paragraphs and special characters.
Thanks! 🙌
`For simpler multiline messages, use the \n escape sequence in your command:
pnpm start "Hello {name}!\nThis is a second line.\nThis is a third line."This method correctly produces line breaks in WhatsApp.
Note: When reading from text files, you may encounter issues with Windows-style line endings (\r\n). The content might be sent with literal \r\n characters instead of actual line breaks.
If you want to try using a message file:
- Create a message.txt file with your content
- Use the following command:
# PowerShell pnpm start "$(Get-Content -Raw message.txt)"
However, this may not work correctly with line breaks. For reliable multiline messages, use Method 1 or Method 2.
- When you first run the application, you'll see a QR code in the terminal
- Open WhatsApp on your phone
- Tap Menu or Settings and select WhatsApp Web
- Scan the QR code displayed in the terminal
- Once authenticated, you'll see "WhatsApp client is ready!" in the console
- The application will process the CSV file, send messages, and exit automatically when complete
The CSV file should have a header row with a column for names and a column for phone numbers. The application will try to detect the phone number column automatically by looking for column names containing 'phone', 'mobile', or 'tel'.
Example CSV format:
name,phone
John Doe,+6281234567890
Jane Smith,62812345678
Robert,6281234567891
Mike Johnson,081234567892
You can use the {name} placeholder in your message to personalize it with the contact's name.
A sample file (sample.contacts.csv) is provided which you should copy to contacts.csv and edit with your actual contacts.
The application will automatically format phone numbers:
- Non-digit characters will be removed
- If a phone number doesn't start with a country code (1, 62, 44), it will default to Indonesia code (62)
This application takes advantage of Node.js v22 features to improve performance:
- Parallel message sending with controlled concurrency
- Modern ES modules for better code organization
- Native timers/promises for delay management
- Stream-based CSV parsing with async iterators
- This application is designed for personal or authorized use only
- Do not use this to send spam or unsolicited messages
- Sending too many messages in a short time may result in your WhatsApp account being banned
contacts.csvis excluded from git to protect your contact privacy
This project is built with the help of Cursor Agent.
MIT