Skip to main content

Tweakio-SDK: WhatsApp automation Python library with anti-detection, async storage, and production-grade architecture

Project description

Tweakio-SDK

Production-Grade WhatsApp Web Automation for Python
Anti-detection browser automation built on Playwright + Camoufox.

PyPI - Version PyPI - Python Version License: MIT Test Coverage

Documentation ยท PyPI ยท Issues ยท Contributing


๐Ÿ”ด The Problem

WhatsApp automation is broken:

  1. Detection & Bans โ€” Standard Selenium/Playwright scripts are fingerprinted and banned within hours
  2. Fragile Scripts โ€” When WhatsApp updates its UI, your selectors break. You spend weeks patching instead of building
  3. No Production Patterns โ€” Most automation tools are throwaway scripts, not production software with proper architecture
  4. Platform Lock-In โ€” Want to add Telegram later? Start from scratch

The industry treats automation as disposable code. We don't.


๐Ÿ’ก The Solution

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)


๐Ÿ“ฆ Installation

pip install tweakio-sdk

Requirements: Python 3.10+, Playwright browsers

# Install Playwright browsers (one-time)
playwright install chromium

โšก Quick Start

Basic: Fetch Chats

import 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())

Advanced: Message Processing with Storage

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())

๐Ÿ—๏ธ Architecture

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

Key Design Decisions

  • Interface-Driven: Every platform implements ChatProcessorInterface, MessageProcessorInterface, etc.
  • Dependency Injection: All classes accept log parameter for testability
  • Async-First: Non-blocking SQLite writes, background queue workers
  • Anti-Detection: Camoufox fingerprints + human-like typing delays

๐Ÿ“Š Modules

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

๐Ÿ› ๏ธ How It Works

Message Processing Flow

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

Anti-Detection Stack

Playwright (base) โ†’ Camoufox (fingerprint) โ†’ BrowserForge (realistic profiles)

๐Ÿค Contributing

We welcome contributions! Vibe coding accepted โ€” if it works and is clean, we'll merge it.

Contribution Rules

  1. Fork โ†’ Branch โ†’ PR workflow required
  2. AI-Assisted code is welcome โ€” just mention it in your PR description for transparency
  3. Tests required for new features (we maintain >90% coverage on core modules)
  4. Type hints required โ€” we use mypy for static analysis

Quick Start for Contributors

# 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

PR Template

## 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

๐Ÿ—บ๏ธ Roadmap

v0.1.6 โ€” Core Infrastructure

  • Custom Logger improvements
  • Multi-Account Handling
  • BrowserManager enhancements
  • Dependency Injection & Interface renewal
  • Directory structure improvements
  • Separate Browser Logging

v0.1.7 โ€” Security & Stability

  • Encryption & Decryption module
  • KeyBox integration
  • Stability & Decryptor additions
  • Stability increase โ†’ 60-70% reliability

v0.1.8 โ€” Quality Assurance

  • Test coverage increase & logic improvements
  • Web-UI tinkering & refinements

v0.2.0 โ€” Multi-Platform (Coming Soon)

  • Another Platform integration (Telegram/Instagram)
  • Platform-agnostic architecture

โ“ FAQ

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.


๐Ÿ“„ License

MIT License โ€” see LICENSE


๐Ÿ”— Links


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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tweakio_sdk-0.1.5.tar.gz (36.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tweakio_sdk-0.1.5-py3-none-any.whl (38.4 kB view details)

Uploaded Python 3

File details

Details for the file tweakio_sdk-0.1.5.tar.gz.

File metadata

  • Download URL: tweakio_sdk-0.1.5.tar.gz
  • Upload date:
  • Size: 36.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for tweakio_sdk-0.1.5.tar.gz
Algorithm Hash digest
SHA256 29b4c3f06eb027242caaef6c49148b3abc21c77856465efbbb467778ac8c0a65
MD5 f23b8ca1419a22b88c87a9cf03964364
BLAKE2b-256 127d3b0a0e7a250fd1561eeb2a47897e524e94ea37a20b1129f18eb3dfbbe31c

See more details on using hashes here.

File details

Details for the file tweakio_sdk-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: tweakio_sdk-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 38.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for tweakio_sdk-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 498212a5ae62c373598a5e4f3e204ab310f4505ac5d8c75b4b4152fe113311c4
MD5 677250785df80726d4336f0f799ba96e
BLAKE2b-256 84ecc7cdc8121321732bdc0e8cf0dae180119324b7d70a6435d2d701c7181643

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page