Skip to content
Alex ALAVO.

Case study 04 · Python · Automation · Bot

InstaBot

A multi-account dashboard to collect, filter and contact Instagram profiles, with real-time monitoring.

Role
End-to-end design and development: engine, interface and diagnostic tools
Category
Python · Automation · Bot
Stack
Python · Flask · Socket.IO
Quality
58 tests
History of contacts sent by the bot
Bot Instagram account management

01 — Context

For professionals managing several Instagram accounts, InstaBot brings profile collection and interaction automation together in a web dashboard.

02 — Problem

Building profile lists, switching between accounts and avoiding contacting the same people twice: hours of manual work.

03 — Solution

Users prepare their accounts, import a list or start a collection from accounts and posts. They configure selection criteria, message templates and pacing. The engine spreads profiles across active accounts and picks the action based on available content; jobs run in the background with live monitoring.

04 — Features

  • Centralised accounts

    Add, import, duplicate detection and per-account roles.

  • Audience collection

    Followers, followings and post interactions, relayed across accounts.

  • Filtering

    Public account, photo, bio, story and follower thresholds.

  • Interactions

    Story replies, highlight replies and direct messages.

  • Pacing and re-contact

    Delays, sleep windows, per-account caps and re-contact delays.

  • Supervision

    Start, stop, live logs and exportable history.

06 — Architecture

  1. Web interfaceJinja2 · JavaScript
  2. Flaskpages · API · auth
  3. Orchestrationthreads · asyncio
  4. Playwright servicescollection · interactions
  5. SQLite · Socket.IOhistory · real time

Flask receives commands and starts jobs in threads that each run their own async loop.

Collection links a producer and consumers through a queue: profiles are enriched as they arrive, without waiting for the full list.

07 — Technical challenges

  • Challenge

    Collect and enrich at the same time.

    Solution

    A producer / consumer pipeline fed by an asyncio queue.

  • Challenge

    Handle several login states.

    Solution

    Persistent browser profiles, state detection, TOTP and reconnection.

  • Challenge

    Avoid contacting people too often.

    Solution

    SQLite history per account and profile, with individual and global delays.

  • Challenge

    Cope with an external interface that changes.

    Solution

    Externalised selectors with fallbacks, error states and progressive back-off.

08 — My contribution

  • Modular architecture and automation scenarios
  • Flask backend and management interfaces
  • Collectors, filters and asynchronous processing
  • SQLite persistence and CSV log
  • Browser sessions, two-factor authentication and proxies
  • Tests, diagnostic tools and documentation

09 — Stack

Backend
Python, Flask, Flask-SocketIO, Eventlet
Automation
Playwright, Firefox, asyncio, multiprocessing
Storage
SQLite (WAL), CSV, JSON
Interface
Jinja2, HTML, CSS, JavaScript, Socket.IO
Quality
pytest, outils de diagnostic Playwright

10 — Results

  • 58

    passing unit tests

  • 4

    interaction types: story reply or reaction, highlight reply, direct message

Next case studyÉnergiePayTurns Mobile Money payment SMS into electricity top-ups, automatically and with full traceability.