Here’s a **basic WhatsApp automation sample program** using **Python** and **
pywhatkit
**, a popular library that allows you to send messages via WhatsApp Web.
> ✅ This works with **WhatsApp Web**, so your computer must be connected to the internet and logged into WhatsApp Web when the message sends.
---
## 🚀 Simple WhatsApp Automation Script (Send a Message)
### ✅ Step 1: Install
pywhatkit
bash
pip install pywhatkit
---
### ✅ Step 2: Python Code to Send a WhatsApp Message
python
import pywhatkit as kit
import datetime
# Set the time 1 minute ahead so WhatsApp Web has time to open
now = datetime.datetime.now()
hour = now.hour
minute = now.minute + 1
# Parameters
phone_number = '+1234567890' # Replace with recipient's number (with country code)
message = 'Hello from Python! This is an automated message 🤖'
# Send the message
kit.sendwhatmsg(phone_number, message, hour, minute)
---
### ⚠️ Important Notes:
* Your browser will open automatically to WhatsApp Web.
* You must **scan the QR code** the first time or be already logged in.
*
pywhatkit.sendwhatmsg()
waits for the exact time to send the message.
---
## 🧠 Cool Extensions (Ideas for Automation):
1. **Schedule daily messages** with a task scheduler (e.g.,
cron
,
Windows Task Scheduler
)
2. **Read messages from a CSV or database** and loop through them
3. **Send updates or reports automatically** (e.g., weather, stock prices, reminders)
---
## ⛔ Limitations:
* Can’t receive messages with
pywhatkit
(send-only).
* It’s not “instant” – messages are sent via browser automation.
* For full automation including reading messages, you’ll need:
* **WhatsApp Business API** (very limited access)
* Or **unofficial automation tools** (risk of ban – not recommended for production)
---