How krutika9021/whatsapp_automator works
Project Type and Purpose
• This is a Python-based automation tool (“WhatsApp Automation Bot”) that uses Selenium to drive a Chrome browser and send messages to WhatsApp Web.
• It is not a multi-service or full-stack app; it’s a single script that orchestrates:
• Input files (numbers.txt, message.txt)
• A Selenium WebDriver session (via chromedriver.exe)
• A Chrome browser instance with a persistent user profile
High-Level Components
a. Inputs
• numbers.txt: list of target phone numbers
• message.txt: the message payload
b. Automation Layer (main.py)
• Python script
• Uses Selenium and webdriver-manager libraries
• Reads inputs, loops through numbers, builds WhatsApp Web URLs, types and sends messages
c. Selenium Infrastructure
• Selenium WebDriver API (Python bindings)
• webdriver-manager: automatically downloads & configures chromedriver.exe
d. Browser Layer
• ChromeDriver executable
• Google Chrome browser binary
• Custom Chrome user-data directory (chrome_automation_profile or User_Data) for session persistence
e. External Service
• WhatsApp Web over HTTPS (websocket/XHR to WhatsApp servers)
Component Relationships and Data Flow
1. main.py loads numbers.txt and message.txt.
2. main.py spawns a Selenium WebDriver session pointing at chromedriver.exe.
3. ChromeDriver launches Chrome with the custom profile directory.
4. Chrome (with persistent cookies & localStorage) connects to WhatsApp Web, requiring only a one-time QR scan.
5. main.py issues WebDriver commands:
– navigate to https://web.whatsapp.com/send?phone=<number>&text=<message chunk>
– send message (in chunks as needed)
6. Chrome communicates with WhatsApp servers to deliver the message.
7. main.py handles errors (invalid numbers) and logs progress.
Architectural Patterns and Principles
• Single-process orchestration (no microservices).
• Layered separation:
1. Data/Input layer
2. Automation/Control layer (Python)
3. Driver/Browser layer (Selenium + ChromeDriver + Chrome)
4. External Service layer (WhatsApp Web)
• Persistent state management via custom Chrome profile.
• Configuration via simple text files (numbers.txt, message.txt)
Essential Elements
• Clear component names: “main.py (Automation Script)”, “Selenium WebDriver (Python)”, “ChromeDriver”, “Chrome Browser + Profile”, “WhatsApp Web Service”
• Inputs: “numbers.txt” and “message.txt”
• Persistent profile: “chrome_automation_profile”
• Network boundary: WhatsApp Web servers