- Get link
- X
- Other Apps
🤖 WhatsApp Automation
Step‑by‑step tutorial
📱 mobile friendly
🐍 python · no api key
📅 2025 · beginner guide
Learn to automate WhatsApp messages using Python — from sending a quick "Hello" to scheduling bulk reminders. All steps tested on Windows, macOS & Linux. No coding experience? No problem.
📲⚙️
whatsapp + python = automation
📌 inside this guide
1. setup
2. pywhatkit
3. instant msg
4. schedule
5. selenium (extra)
🔰 before you start
What you need: a computer with internet, WhatsApp Web (already logged in), and basic Python installed. We'll use two friendly libraries: pywhatkit (simplest) and selenium (more control).
⚠️ Ethical use only — automate only with consent. Too many messages may get you banned. Keep delays > 5 seconds.
1 Install Python & pip
If you don't have Python, download from python.org (check "Add to PATH"). Open terminal / command prompt and verify:
python --version
pip --versionYou should see Python 3.7+ and pip. On Linux/macOS you might need to use python3 and pip3.
2 Install required packages
We'll install pywhatkit (handles web opening, delays, and scheduling) and optionally selenium + webdriver for advanced automation.
pip install pywhatkit
pip install selenium # optionalFor Selenium you also need a ChromeDriver matching your Chrome version. But don't worry — we focus on pywhatkit first.
💬 instant message (10 lines)
Open any text editor (Notepad, VS Code). Write this script:
import pywhatkit as kit
# send message instantly (phone number with country code)
kit.sendwhatmsg_instantly(
"+919876543210", # 👈 replace with receiver's number
"Hello! This is an automated WhatsApp message 🤖",
15, # wait 15 seconds before sending
True # close tab after 15 seconds
)Run it: python your_script.py. WhatsApp Web will open in a new tab and send after 15 seconds. Keep the tab active.
🖥️ [screenshot: terminal & WhatsApp web sending]
⬆️ expected behaviour: browser opens, waits, types, and sends
⏰ schedule messages (future time)
Use sendwhatmsg to schedule at a specific hour and minute (24h format).
import pywhatkit as kit
# send at 18:30 (6:30 PM) today
kit.sendwhatmsg("+919876543210",
"Don't forget our meeting 🕡",
18, 30) # hour, minuteMake sure your computer stays on, browser remains logged in, and the tab won't sleep. You can even close the lid if you set your PC to stay awake.
💡 Pro tip: For groups, use the group invite link or group ID? pywhatkit works only with phone numbers. To send to a group, use selenium (see step 5).
🧪 advanced: selenium (images & groups)
If you need to send images, documents, or interact with groups, Selenium is the way. Here's a minimal example that opens WhatsApp Web and waits for QR scan.
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
driver = webdriver.Chrome() # or Firefox
driver.get("https://web.whatsapp.com")
input("Scan QR code and press Enter here...")
# search contact
search_box = driver.find_element(By.XPATH, '//div[@contenteditable="true"][@data-tab="3"]')
search_box.send_keys("+919876543210")
time.sleep(2)
# ... then locate message box and type.This is just a skeleton. For full script, refer to selenium docs. Remember to add delays (time.sleep) so WhatsApp loads.
✅ quick checklist & troubleshooting
- Make sure you are logged into WhatsApp Web before running automation.
- If message doesn't send: increase the waiting time (3rd argument).
- Numbers must include country code without '+'? Actually with '+' is fine in pywhatkit.
- Keep your phone connected (WhatsApp Web requires active phone internet).
- On macOS, you might need to give terminal permission for automation.
📲📤
whatsapp web + pywhatkit in action
📦 full example: send bulk message with delay
import pywhatkit as kit
import time
contacts = ["+1234567890", "+1987654321", "+44123456789"]
message = "Hello, this is a broadcast 📢"
for number in contacts:
kit.sendwhatmsg_instantly(number, message, 20, True)
time.sleep(5) # wait between contacts⚠️ Use responsibly — spamming may get your number blocked. Add 30-60 seconds between messages.
📱 mobile friendly — this tutorial adapts to your screen. Bookmark it, and code on the go!
❓ FAQ (quick answers)
Can I automate without opening browser? No, both pywhatkit and selenium need a real browser instance (WhatsApp Web). There's no official API.
Do I need a second phone? No, your main phone stays connected to internet; you just control via PC browser.
Pywhatkit stops after sending? By default it closes tab after 15 sec. Use close_time=30 to keep open longer.
Images with pywhatkit? Not directly — use selenium for media.
✨
Disclaimer: this tutorial is for educational purposes. Automating WhatsApp may violate its Terms of Service. Use at your own risk.
- Get link
- X
- Other Apps

Comments
Post a Comment