This project automates sending WhatsApp messages using Python, Selenium, and ChromeDriver. It supports dynamically loading contacts and messages, making it flexible for personal or small-scale automation purposes.
- Automated Messaging: Send messages to individual contacts via WhatsApp Web.
- Chrome User Data Persistence: Maintain session data to avoid re-scanning the QR code.
- Customizable Messages: Easily configure messages directly in the script.
- Python: Ensure Python 3.x is installed. Download it from python.org.
- Google Chrome: Install the latest version of Google Chrome.
- ChromeDriver: ChromeDriver will be automatically installed using
webdriver_manager
.
-
Clone the repository:
https://github.com/monimahmadh/what_bot.git cd whatsapp-automation-bot
-
Install required Python libraries:
pip install -r requirements.txt
-
Create a
.env
file in the root directory to store phone numbers:PHONE_NUMBERS=+8801878119442,+880164*****,+19758*****
-
Create a
config.py
file to store your Chrome user data settings. It will allow you to avoid re-scanning the QR code:USER_DATA_DIR = r"C:\Users\YourUsername\AppData\Local\Google\Chrome\User Data" PROFILE_DIRECTORY = "Profile 1"
- Open the terminal and navigate to the project directory.
- Run the script:
python what_bot.py
- On the first run, you will need to scan the QR code on WhatsApp Web to log in.
- The script will:
- Load the phone numbers from the
.env
file. - Send the specified message to each contact.
- Load the phone numbers from the
whatsapp-automation-bot/
│
├── what_bot.py # Main script
├── config.py # Configuration file for Chrome user data
├── .env # Environment file for phone numbers
├── requirements.txt # Python dependencies
├── README.md # Project documentation
The following libraries are used in this project:
- selenium: For browser automation.
- webdriver_manager: Automatically manages ChromeDriver.
- python-dotenv: Load environment variables from a
.env
file.
Install dependencies using:
pip install -r requirements.txt
- Error initializing WebDriver: Ensure
Google Chrome
andChromeDriver
versions are compatible. - QR Code not appearing: Check the
USER_DATA_DIR
andPROFILE_DIRECTORY
paths inconfig.py
. - No messages sent: Verify the phone numbers in
.env
are in the correct format (e.g.,+8801234567890
).
Feel free to fork this repository and submit pull requests to improve functionality or add new features.
This project is open-source and available under the MIT License.