An automated WhatsApp messaging bot built with Python and Selenium that can send bulk messages to contacts from CSV files or Google Sheets. Perfect for sending news updates, announcements, or notifications to multiple contacts.
- Multiple Data Sources: Read contacts from CSV files or Google Sheets
- Bulk Messaging: Send personalized messages to multiple contacts
- Message Templates: Support for text files with message templates
- Unicode Safe: Automatic handling of emojis and special characters
- Session Persistence: Chrome user data saved for easy re-login
- Error Handling: Robust error handling with detailed feedback
- Progress Tracking: Real-time progress updates during message sending
- Python 3.7+
- Chrome/Chromium browser
- ChromeDriver (automatically managed by selenium)
- Virtual environment (recommended)
-
Clone the repository:
git clone <repository-url> cd whatsapp_iitk_news_bot
-
Create and activate virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Create/Edit
contacts.csv:Name,Phone John Doe,919876543210 Jane Smith,917890123456 -
Create your message in
message.txt:Hello! This is your news update for today... -
Run the bot:
python whatsapp_bot.py
- Set up Google Sheets API (see GOOGLE_SHEETS_SETUP.md)
- Download
credentials.jsonand place it in the project directory - Share your Google Sheet with the service account email
- Run the bot - it will automatically use Google Sheets if no CSV is found
whatsapp_iitk_news_bot/
βββ whatsapp_bot.py # Main bot script
βββ requirements.txt # Python dependencies
βββ message.txt # Message template
βββ message_no_emoji.txt # Emoji-free message template
βββ contacts.csv # Contact list (create this)
βββ credentials.json # Google Sheets API credentials (create this)
βββ GOOGLE_SHEETS_SETUP.md # Google Sheets setup guide
βββ User_Data/ # Chrome session data (auto-created)
βββ .gitignore # Git ignore rules
βββ README.md # This file
message.txt: Main message templatemessage_no_emoji.txt: Fallback template without emojis- Supports multi-line messages with proper formatting
CSV File:
Name,Phone
Contact Name,Country_Code_Phone_Number
Google Sheets:
- Column A: Name
- Column B: Phone
- Phone numbers should include country code (e.g., 919876543210 for India)
-
First Run:
- The bot will open WhatsApp Web
- Scan the QR code with your phone
- Session will be saved for future runs
-
Subsequent Runs:
- Bot will use saved session (no QR scan needed)
- Automatically reads contacts and sends messages
-
Message Personalization:
# Messages are automatically personalized: # "Hi {Name}! Your message content here..."
# In whatsapp_bot.py, you can modify Chrome options:
chrome_options.add_argument("--headless") # Run in background
chrome_options.add_argument("--no-sandbox") # For server environmentsThe bot includes comprehensive error handling for:
- Network connectivity issues
- WhatsApp Web loading problems
- Invalid phone numbers
- Unicode/emoji compatibility
- API rate limiting
- Credentials: Never commit
credentials.jsonor personal data - Session Data:
User_Data/contains your WhatsApp session - Contact Lists: Keep
contacts.csvprivate - Logs: Check logs for any sensitive information before sharing
-
"ChromeDriver only supports characters in the BMP"
- Solution: Bot automatically removes problematic characters
-
"No such file or directory: credentials.json"
- Solution: Use CSV file method or set up Google Sheets API
-
WhatsApp Web not loading
- Solution: Check internet connection, clear User_Data folder
-
Messages not sending
- Solution: Verify phone numbers include country code
- Check WhatsApp Web is properly loaded
# Run with verbose output
python whatsapp_bot.py --debugThis project is licensed under the MIT License - see the LICENSE file for details.
Additional Terms:
- If you use this project for events, organizations, or public purposes, please star β this repository and provide attribution as described in the Attribution section above.
- Commercial use is permitted under MIT License terms, but attribution is appreciated.
- This bot is for educational and legitimate business purposes only
- Respect WhatsApp's Terms of Service and local regulations
- Avoid spamming and respect recipient privacy
- Use responsibly and ethically
If you use this project for your events, organizations, or any public purpose, please:
- β Star this repository - It helps others discover this project
- π Give credit - Mention this project in your documentation/announcements
- π Link back - Include a link to this repository
Example credit format:
WhatsApp messaging powered by: https://github.com/Shuvam-Banerji-Seal/Automated-Whatsapp-Bulk-Message-Sender-using-Google-Forms-Sheets-and-Python
For academic/research use: Please cite this repository in your work.
For commercial use: Consider reaching out to discuss collaboration opportunities.
Your support helps maintain and improve this project for everyone! π
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Commit changes:
git commit -am 'Add feature' - Push to branch:
git push origin feature-name - Submit a Pull Request
If you encounter issues:
- Check the troubleshooting section above
- Review the setup guides in the docs folder
- Create an issue with detailed error logs
See CHANGELOG.md for version history and updates.
Happy Messaging! π