A Python automation script that sends bulk messages via WhatsApp Web using Selenium WebDriver.
- Send personalized messages to multiple contacts
- Uses WhatsApp Web interface for reliable message delivery
- Reads contacts and messages from CSV file
- Preserves WhatsApp session using Chrome profile
- Error handling and progress tracking
- Non-blocking browser session (detached mode)
- Python 3.7 or higher
- Google Chrome browser
- ChromeDriver executable
- Active WhatsApp account
- Clone this repository:
git clone <repository-url>
cd whatsapp-bulk-sender- Install required dependencies:
pip install -r requirements.txt- Download ChromeDriver:
- Visit ChromeDriver Downloads
- Download the version matching your Chrome browser
- Place
chromedriver.exein the project directory
-
Prepare your contacts file (
contacts.csv): Create a CSV file with the following columns:Name,Phone,Message John,+919999900000,"Hello there!" Jane,+919999900001,"Hi, how are you?"
-
Configure Chrome Profile (Optional): The script uses a dedicated Chrome profile to maintain WhatsApp Web session. The profile is stored at:
C:/Users/swast/whatsapp_profileYou can modify this path in the script if needed.
- Run the script:
python script.py-
First Time Setup:
- The script will open WhatsApp Web in Chrome
- Scan the QR code with your phone to log in
- Press Enter in the terminal when ready
-
Subsequent Runs:
- If you're already logged in, the script will use the saved session
- Messages will be sent automatically to all contacts in the CSV
whatsapp-bulk-sender/
├── script.py # Main automation script
├── chromedriver.exe # Chrome WebDriver executable
├── contacts.csv # Contact list with messages
├── requirements.txt # Python dependencies
└── README.md # This file
Your contacts.csv file should follow this format:
| Column | Description | Example |
|---|---|---|
| Name | Contact name (for logging) | John Doe |
| Phone | Phone number with country code | +919999900000 |
| Message | Message to send | Hello there! |
Notes:
- Phone numbers should include country code (e.g., +91 for India)
- Messages can contain spaces and special characters
- The script will automatically handle URL encoding
You can modify the following settings in script.py:
- Chrome Profile Path: Change the
--user-data-dirargument - Wait Times: Adjust
time.sleep()values for different internet speeds - Button Selector: Update XPath if WhatsApp Web changes its interface
The script includes error handling for:
- Failed message delivery
- Element not found errors
- Network timeouts
Check the console output for detailed logs of success/failure for each contact.
-
ChromeDriver Version Mismatch:
- Ensure ChromeDriver version matches your Chrome browser version
-
QR Code Scanning:
- Make sure your phone and computer are on the same network
- Try refreshing the page if QR code doesn't appear
-
Send Button Not Found:
- WhatsApp may have changed their interface
- Check if the XPath selector needs updating
-
Messages Not Sending:
- Verify phone numbers are in correct format
- Check internet connection
- Ensure WhatsApp Web is fully loaded
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is for educational purposes. Please ensure compliance with WhatsApp's Terms of Service and local regulations regarding automated messaging.
This tool is for educational and personal use only. The authors are not responsible for any misuse or violation of WhatsApp's Terms of Service. Use at your own risk.