Production-Grade WhatsApp Web Automation for Python
Anti-detection browser automation built on Playwright + Camoufox.
Documentation Β· PyPI Β· Issues Β· Contributing Β· Mentors
WhatsApp automation is broken:
- Detection & Bans β Standard Selenium/Playwright scripts are fingerprinted and banned within hours
- Fragile Scripts β When WhatsApp updates its UI, your selectors break. You spend weeks patching instead of building
- No Production Patterns β Most automation tools are throwaway scripts, not production software with proper architecture
- Platform Lock-In β Want to add Telegram later? Start from scratch
The industry treats automation as disposable code. We don't.
Tweakio-SDK is a WhatsApp automation framework built with production-grade patterns:
| Problem | Tweakio Solution |
|---|---|
| Detection | Camoufox + BrowserForge fingerprinting (indistinguishable from humans) |
| Fragile selectors | Interface-driven architecture β when WhatsApp breaks, only src/WhatsApp/ needs updates |
| No persistence | Async SQLite storage with background queue workers |
| No typing | Type-safe dataclasses for Chat and Message objects |
Current: WhatsApp Web (v0.1.5)
Roadmap: Telegram (Q2 2026), Instagram (Q3 2026)
This gist provides templates for the following 2 files
Contributors are to strictly follow OSCG_CONTRIBUTOR_Guidelines.md and mentors are to follow OSCG_MENTORS_Guidelines.md respectively
pip install tweakio-sdkRequirements: Python 3.10+, Playwright browsers
# Install Playwright browsers (one-time)
playwright install chromiumimport asyncio
from BrowserManager import BrowserManager
from src.WhatsApp.login import Login
from src.WhatsApp.chat_processor import ChatProcessor
from src.WhatsApp.web_ui_config import WebSelectorConfig
from Custom_logger import logger
async def main():
# 1. Launch anti-detect browser
browser = BrowserManager(headless=False)
page = await browser.getPage()
# 2. Initialize UI config and Login
ui_config = WebSelectorConfig(page=page, log=logger)
login = Login(page=page, UIConfig=ui_config, log=logger)
# 3. Login (scan QR code on first run)
await login.login(save_path="./session.json")
# 4. Fetch chats
chat_processor = ChatProcessor(page=page, UIConfig=ui_config, log=logger)
async for chat, name in chat_processor.Fetcher(MaxChat=5):
print(f"π Chat: {name}")
asyncio.run(main())import asyncio
from BrowserManager import BrowserManager
from src.WhatsApp.login import Login
from src.WhatsApp.chat_processor import ChatProcessor
from src.WhatsApp.message_processor import MessageProcessor
from src.WhatsApp.web_ui_config import WebSelectorConfig
from src.StorageDB.sqlite_db import SQLITE_DB
from Custom_logger import logger
async def main():
# Browser + Login setup (same as above)
browser = BrowserManager(headless=False)
page = await browser.getPage()
ui_config = WebSelectorConfig(page=page, log=logger)
login = Login(page=page, UIConfig=ui_config, log=logger)
await login.login(save_path="./session.json")
# Initialize async storage
queue = asyncio.Queue()
async with SQLITE_DB(queue=queue, log=logger, db_path="messages.db") as storage:
# Initialize processors
chat_processor = ChatProcessor(page=page, UIConfig=ui_config, log=logger)
msg_processor = MessageProcessor(
page=page,
UIConfig=ui_config,
chat_processor=chat_processor,
log=logger,
storage=storage # Messages auto-saved to SQLite
)
# Fetch and process messages
async for chat, name in chat_processor.Fetcher(MaxChat=3):
print(f"π Processing: {name}")
# Fetcher returns wrapped Message objects with deduplication
messages = await msg_processor.Fetcher(chat=chat, retry=3)
for msg in messages:
print(f" π¬ {msg.data_type}: {msg.raw_data[:50]}...")
print(f" ID: {msg.message_id}")
print(f" Direction: {msg.direction}")
asyncio.run(main())tweakio-sdk/
βββ src/
β βββ BrowserManager/ # Anti-detect Playwright + Camoufox
β βββ WhatsApp/ # Platform-specific implementation
β β βββ login.py # QR + Phone authentication
β β βββ chat_processor.py
β β βββ message_processor.py
β β βββ web_ui_config.py # Selector definitions
β β βββ DerivedTypes/ # Chat, Message dataclasses
β βββ Interfaces/ # Abstract contracts (for future platforms)
β βββ StorageDB/ # Async SQLite with queue workers
β βββ Exceptions/ # Custom exception hierarchy
βββ tests/ # >90% coverage on core modules
- Interface-Driven: Every platform implements
ChatProcessorInterface,MessageProcessorInterface, etc. - Dependency Injection: All classes accept
logparameter for testability - Async-First: Non-blocking SQLite writes, background queue workers
- Anti-Detection: Camoufox fingerprints + human-like typing delays
| Module | Description |
|---|---|
| BrowserManager | Anti-detect browser with fingerprint rotation |
| Login | QR code + phone number authentication |
| ChatProcessor | Fetch chats, handle unread status, click navigation |
| MessageProcessor | Extract messages, deduplicate, filter, store |
| SQLITE_DB | Async queue-powered storage with batch inserts |
| WebSelectorConfig | Platform-specific DOM selectors |
1. ChatProcessor.Fetcher() β yields Chat objects
2. MessageProcessor.Fetcher(chat) β clicks chat, extracts messages
3. Messages wrapped as whatsapp_message dataclass
4. New messages enqueued to SQLITE_DB async queue
5. Background writer batches inserts every N seconds
Playwright (base) β Camoufox (fingerprint) β BrowserForge (realistic profiles)
We welcome contributions! Vibe coding accepted β if it works and is clean, we'll merge it.
- Fork β Branch β PR workflow required
- AI-Assisted code is welcome β just mention it in your PR description for transparency
- Tests required for new features (we maintain >90% coverage on core modules)
- Type hints required β we use
mypyfor static analysis
# Clone and setup
git clone https://github.com/BITS-Rohit/tweakio-sdk.git
cd tweakio-sdk
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
# Run tests
pytest --cov=src
# Your feature branch
git checkout -b feature/your-feature## What does this PR do?
[Description]
## AI Disclosure
- [ ] This PR includes AI-generated code (Claude/GPT/Copilot)
- [ ] This PR is fully human-written
## Testing
- [ ] Added/updated tests
- [ ] All tests pass locally- Custom Logger improvements
- Multi-Account Handling
- BrowserManager enhancements
- Dependency Injection & Interface renewal
- Directory structure improvements
- Separate Browser Logging
- Encryption & Decryption module
- KeyBox integration
- Stability & Decryptor additions
- Stability increase β 60-70% reliability
- Test coverage increase & logic improvements
- Web-UI tinkering & refinements
- Another Platform integration (Telegram/Instagram)
- Platform-agnostic architecture
Q: Will I get banned?
A: Tweakio uses Camoufox anti-detection. With reasonable rate limiting, bans are rare. Always test on disposable accounts first.
Q: Can I use this for spam?
A: No. This SDK is for legitimate automation (customer support, archiving, notifications). Spam violates WhatsApp ToS and is not supported.
Q: Why not just use the WhatsApp Business API?
A: Business API has message template restrictions and approval processes. Tweakio is for developers who need full control.
MIT License β see LICENSE
- PyPI: pypi.org/project/tweakio-sdk
- GitHub: github.com/BITS-Rohit/tweakio-sdk
- Issues: Report bugs
Keywords: tweakio, tweakio-sdk, whatsapp automation, whatsapp bot python, whatsapp api, web automation, playwright, browser automation, chatbot, messaging, anti-detection, camoufox
Built with β€οΈ by BITS-Rohit and the Tweakio community
