
WhatsApp Automation
March 20, 2024
WhatsApp Automation
A Python script I built to automate sending WhatsApp messages to multiple numbers. It reads contacts from a CSV file, tracks sent messages, and prevents duplicate sends.
What It Does
- Reads phone numbers from CSV files
- Automatically adds country codes
- Tracks sent messages to prevent duplicates
- Sends personalized messages to each number
- Provides sending statistics
How It Works
The script uses pywhatkit to interact with WhatsApp Web and pandas to handle the contact data. It maintains a database of sent messages to avoid duplicates.
import pywhatkit
import pandas as pd
# Load contacts and send messages
df = pd.read_csv('contacts.csv')
message = "Your message here"
for number in df['phone']:
pywhatkit.sendwhatmsg_instantly(number, message)
Technical Bits
- Built with Python and pywhatkit
- Uses pandas for data handling
- Maintains message history
- Handles country code formatting
Why I Built It
I needed a way to send messages to multiple WhatsApp contacts without manually copying and pasting. This tool automates the process while ensuring each contact only receives the message once.
Future Ideas
- Add message templates
- Support for media messages
- Schedule message sending
- Add message delivery tracking