Skip to content

barisegesevgili/InstaBridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

πŸŒ‰ InstaBridge

The Open-Source Alternative for Instagram to WhatsApp Automation

Automatically forward Instagram posts, stories, and reels to WhatsApp, Telegram, and more

License: MIT Python 3.13+ Code style: black Tests Coverage Security

Why InstaBridge? Free, open-source, personal use focused - unlike $50-500/month commercial tools designed for businesses


⚠️ CRITICAL WARNING

This project uses UNOFFICIAL APIs that violate Instagram and WhatsApp Terms of Service.

Risk Impact
🚫 Account Bans Possible permanent loss of accounts (risk varies by use case)
⏸️ Rate Limits Temporary restrictions on API access
πŸ”’ Account Locks Verification challenges and login issues
βš–οΈ Legal Risk Potential ToS violation consequences

Risk by use case: For the intended use (downloading your own stories/content, ~once per day, no social manipulation), risk is lower: instagrapi is LOW→MEDIUM; Playwright is VERY LOW when used with a normal browser profile. See Risk by use case.

πŸ›‘οΈ Safety recommendations:

  • βœ… Prefer throwaway/test accounts; primary accounts are an informed choice
  • βœ… This is for learning and personal automation
  • βœ… Not for commercial or production use
  • ❌ Do not use for growth automation, spam, or scraping others

🎯 What InstaBridge Does

InstaBridge is a free, open-source personal automation tool that:

  • πŸ“Έ Monitors your Instagram for new posts and stories
  • πŸ€– Automatically downloads media content
  • πŸ’¬ Forwards content to specified WhatsApp contacts
  • πŸŽ›οΈ Filters content by type (posts, stories, close friends)
  • πŸ“Š Provides insights (who doesn't follow back, unfollow tracking)
  • ⏰ Runs on a schedule or on-demand

Real-World Use Cases

  • Content Creators: Share Instagram posts with a WhatsApp community group
  • Personal Sharing: Auto-forward stories to family members
  • Backup: Keep a local copy of your Instagram content
  • Analytics: Track follower/following relationships
  • Learning: Understand browser automation and unofficial APIs

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Instagram     β”‚
β”‚   (instagrapi)  │──┐
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
                     β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                     β”œβ”€β”€β”‚  InstaBridge     β”‚
                     β”‚  β”‚  Core Engine     β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚  - State Mgmt    β”‚
β”‚   WhatsApp Web  β”‚  β”‚  β”‚  - Scheduling    β”‚
β”‚   (Playwright)  │───  β”‚  - Multi-platformβ”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚  - Deduplication β”‚
                     β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚           β”‚
β”‚  Telegram       β”‚β”€β”€β”˜  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  (Coming Soon)  β”‚     β”‚                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”
                    β”‚ Web UI β”‚      β”‚ Analytics β”‚
                    β”‚ (Flask)β”‚      β”‚  Engine   β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Extensible Design: Ready for Telegram, Discord, and more platforms

See ARCHITECTURE.md for detailed design decisions.


✨ Features

🌟 Why Choose InstaBridge Over Commercial Tools?

Feature Commercial Tools InstaBridge
Cost $50-500/month Free Forever
Target Business/Marketing Personal Use
Open Source ❌ Closed βœ… Open
Learning ❌ Black box βœ… Educational
Extensibility ❌ Locked βœ… Add platforms
Privacy ⚠️ Cloud-based βœ… Self-hosted

🎯 Core Automation

  • βœ… Instagram post/story monitoring
  • βœ… Multi-recipient support with per-recipient filtering
  • βœ… Smart deduplication (never send duplicates)
  • βœ… Close friends story detection
  • βœ… Carousel/album support
  • βœ… Custom message prefixes

⏰ Scheduling

  • βœ… Daily scheduled runs (customizable time & timezone)
  • βœ… Weekly unfollow notifications
  • βœ… One-time scheduled runs
  • βœ… Settings auto-reload without restart

πŸ“Š Analytics

  • βœ… "Not following back" analysis with filtering
  • βœ… Unfollow detection and alerts
  • βœ… Follower statistics and trends
  • βœ… Warm cache system for performance

πŸŽ›οΈ Management

  • βœ… Web UI for configuration (localhost:5000)
  • βœ… Per-recipient content preferences
  • βœ… JSON-based settings (easy to edit)
  • βœ… Session persistence (scan QR once)

πŸš€ Quick Start

Platform Compatibility

Platform Status Notes
macOS βœ… Fully Supported Native file picker via AppleScript
Linux βœ… Supported Tested on Ubuntu 22.04+
Windows ⚠️ Compatible DOM file input (no native picker)

Minimum Requirements:

  • Python 3.13+
  • 2GB RAM
  • 500MB disk space
  • Internet connection

Tested Configurations:

  • macOS 13+ (Ventura, Sonoma)
  • Ubuntu 22.04+ / Debian 12+
  • Windows 10/11 (WSL2 recommended)

Prerequisites

  • Python 3.13+
  • Instagram account (test/throwaway recommended)
  • WhatsApp account

Installation

# Clone the repository
git clone https://github.com/barisegesevgili/InstaBridge.git
cd InstaBridge

# Create virtual environment
python3 -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Install Playwright browsers
python -m playwright install chromium

# Create configuration
cp .env.example .env
# Edit .env with your credentials

Configuration

πŸ” RECOMMENDED: Secure Credential Storage (v1.0.2+)

InstaBridge now supports system keychain for secure password storage:

# Install keyring for secure storage
pip install keyring

# Run interactive setup wizard
python -m src.credentials

# Passwords stored encrypted in:
# - macOS: Keychain Access
# - Linux: libsecret/gnome-keyring
# - Windows: Credential Manager

Benefits:

  • βœ… Passwords encrypted by OS (never in plain text)
  • βœ… No .env file with passwords
  • βœ… Protected by system authentication
  • βœ… Set once, use forever

Alternative: Manual .env setup (less secure)

If you prefer not to use keychain, edit .env:

# Instagram credentials (use throwaway account!)
IG_USERNAME=your_test_account
IG_PASSWORD=your_secure_password

# WhatsApp content recipient
WA_CONTENT_CONTACT_NAME=Friend Name
WA_CONTENT_PHONE=491701234567  # International format, digits only

# WhatsApp report recipient (for unfollow alerts)
WA_REPORT_CONTACT_NAME=Notes  # Your own "Notes" chat
WA_REPORT_PHONE=

# Optional: Custom message prefix
MESSAGE_PREFIX=New from Instagram:

πŸ“– See Keychain Setup Guide for detailed instructions

πŸ’‘ Pro Tip: Use WA_CONTENT_PHONE (international format) instead of contact name for 10x more reliability.

First Run

# Run once (you'll scan QR code for WhatsApp Web)
python -m src.main

# Expected output:
# βœ“ Instagram login OK
# βœ“ WhatsApp Web ready (scan QR if first time)
# βœ“ Found 1 new post
# βœ“ Sent to Friend Name

πŸ“– Usage

Basic Commands

# Dry run (simulate without sending)
python -m src.main --dry-run

# One-time run
python -m src.main

```bash
# One-time run
python -m src.main

# Resend last batch (testing)
python -m src.main --resend-last

# Force resend (ignore deduplication)
python -m src.main --force

# Limit files for testing
python -m src.main --resend-last --max-files 2

Scheduled Automation

# Daily at 19:00 Berlin time (keeps running)
python -m src.scheduler

# Weekly unfollow checker (Sunday 22:00 Berlin)
python -m src.unfollow_scheduler

# Different weekday
python -m src.unfollow_scheduler --weekday monday

# One-time scheduled run
python -m src.run_at --time 14:50 --tz Europe/Berlin

Web UI

# Start web interface
python -m src.webapp

# Open browser to http://127.0.0.1:5000

Features:

  • πŸŽ›οΈ Settings management (recipients, schedule)
  • πŸ“Š "Not following back" reports with filters
  • πŸ”„ Warm cache for performance
  • πŸ“ˆ Next run preview

Analytics Commands

# List accounts not following you back
python -m src.unfollow

# Check for new unfollows (sends WhatsApp alert)
python -m src.unfollow --check-unfollows --notify

🎨 Per-Recipient Configuration

Create settings.json to manage multiple recipients:

{
  "schedule": {
    "enabled": true,
    "tz": "Europe/Berlin",
    "time_hhmm": "19:00"
  },
  "recipients": [
    {
      "id": "friend1",
      "display_name": "Best Friend",
      "wa_phone": "491701234567",
      "enabled": true,
      "send_posts": true,
      "send_stories": true,
      "send_close_friends_stories": false
    },
    {
      "id": "family",
      "display_name": "Family Group",
      "wa_contact_name": "Family Chat",
      "enabled": true,
      "send_posts": true,
      "send_stories": false,
      "send_close_friends_stories": false
    }
  ]
}

Or use the Web UI at http://127.0.0.1:5000/settings to manage visually.


πŸ”§ Advanced Configuration

Session Files

  • ig_session.json - Instagram session (auto-managed)
  • wa_profile/ - WhatsApp Web profile (persistent login)
  • state.json - Deduplication state
  • follow_cache.json - Follower/following cache
  • user_cache.json - User stats cache

Rate Limiting & Delays πŸ›‘οΈ

v1.0.1+ includes comprehensive rate limiting to minimize ban risk:

  • Automatic delays: 2-5 seconds + random jitter between all Instagram requests
  • Hourly limits: Max 60 requests per hour (configurable)
  • Human-like timing: Random variations to avoid detection patterns
  • Download throttling: 0.5-1.5s delays between file downloads
  • Analytics delays: 0.7-1.0s between user stats requests

Three safety levels:

  • CONSERVATIVE: 3-7s delays, 40 req/hour (safest for new accounts)
  • MODERATE: 2-5s delays, 60 req/hour (default, balanced)
  • AGGRESSIVE: 1-3s delays, 80 req/hour (higher risk, testing only)

πŸ“– See Safe Usage Guide for detailed recommendations.

Platform-Specific Notes

macOS:

  • βœ… Native file picker automation via AppleScript
  • ⚠️ Requires Accessibility permissions: System Settings > Privacy & Security > Accessibility > Terminal/iTerm
  • βœ… Best performance and reliability

Linux:

  • βœ… DOM-based file picker (fully functional)
  • βœ… No special permissions required
  • ⚠️ Ensure Chromium dependencies: sudo apt install -y libglib2.0-0 libnss3 libx11-6
  • βœ… Tested on Ubuntu 22.04+, Debian 12+

Windows:

  • βœ… DOM-based file picker (functional)
  • ⚠️ WSL2 recommended for best experience
  • ⚠️ Native Windows: May need playwright install chromium --with-deps
  • ⚠️ Path separators: Use forward slashes or escape backslashes

πŸ› Troubleshooting

Instagram Issues

"Login failed" or "Challenge required"

  • Complete Instagram verification in the mobile app
  • Delete ig_session.json and try again
  • Wait 15-30 minutes between attempts

"Rate limited" errors

  • Stop all automation for 1-2 hours
  • Reduce request frequency
  • Use a less active Instagram account

WhatsApp Issues

QR code not appearing

  • Delete wa_profile/ folder
  • Restart the script
  • Check Playwright browser window

Wrong contact opened

  • Use phone number instead of name (WA_CONTENT_PHONE)
  • Ensure international format (e.g., 491701234567)

Upload fails / wrong input selected

  • Known issue: WhatsApp Web DOM changes frequently
  • Try closing and reopening the script
  • Check logs for specific errors

See TROUBLESHOOTING.md for more solutions.


πŸ§ͺ Development

Running Tests

# Install dev dependencies
pip install pytest pytest-cov

# Run all tests
pytest

# Run with coverage
pytest --cov=src --cov-report=html

# Run specific test file
pytest tests/test_ig.py -v

Code Quality

# Format code
black src/ tests/

# Type checking
mypy src/

# Linting
ruff check src/

Project Structure

InstaToWhatsapp/
β”œβ”€β”€ src/                    # Source code
β”‚   β”œβ”€β”€ ig.py              # Instagram client
β”‚   β”œβ”€β”€ wa.py              # WhatsApp automation
β”‚   β”œβ”€β”€ main.py            # Core orchestration
β”‚   β”œβ”€β”€ settings.py        # Configuration management
β”‚   β”œβ”€β”€ state.py           # State persistence
β”‚   β”œβ”€β”€ insights.py        # Analytics engine
β”‚   β”œβ”€β”€ scheduler.py       # Daily scheduler
β”‚   β”œβ”€β”€ unfollow.py        # Unfollow tracking
β”‚   └── webapp.py          # Web UI
β”œβ”€β”€ tests/                 # Test suite
β”œβ”€β”€ docs/                  # Documentation
β”œβ”€β”€ .env.example           # Configuration template
β”œβ”€β”€ requirements.txt       # Python dependencies
└── README.md             # This file

πŸš€ Roadmap

Current (v1.0) βœ…

  • WhatsApp automation
  • Multi-recipient support
  • Analytics & insights

Coming Soon (v1.1) πŸ”œ

  • Telegram support
  • Discord webhooks
  • Docker deployment
  • Enhanced UI

Future (v2.0) πŸ’‘

  • Multi-platform dashboard
  • Plugin architecture
  • Cloud deployment options

See ROADMAP.md for details.


🀝 Contributing

We welcome contributions! InstaBridge is ideal for learning:

  • Browser automation (Playwright)
  • Unofficial API usage (instagrapi)
  • State management patterns
  • Flask web apps
  • Scheduling systems

Ways to contribute:

  • πŸ› Report bugs via Issues
  • πŸ’‘ Suggest features (Telegram, Discord, etc.)
  • πŸ“– Improve documentation
  • πŸ§ͺ Add tests
  • πŸ”§ Fix bugs or add features
  • 🌍 Add new platform integrations

See CONTRIBUTING.md for guidelines.


πŸ“š Documentation

Document Description
KEYCHAIN_SETUP.md πŸ” Secure password storage (RECOMMENDED)
RISK_BY_USE_CASE.md πŸ“‹ Risk by use case (instagrapi vs Playwright, intended use)
SAFE_USAGE_GUIDE.md ⚠️ Minimize account ban risk
SECURITY_BEST_PRACTICES.md Security guidelines & credential safety
ARCHITECTURE.md Design decisions & system overview
SETUP.md Detailed setup guide
TROUBLESHOOTING.md Common issues & solutions
ROADMAP.md Future plans & wishlist
CHANGELOG.md Version history

πŸ—ΊοΈ Roadmap

v1.0 - Stability βœ…

  • Multi-recipient support
  • Per-recipient filtering
  • Web UI for configuration
  • Unfollow detection
  • Comprehensive documentation

v1.1 - Polish (Current)

  • Docker support
  • Windows compatibility testing
  • Enhanced error recovery
  • Performance optimizations

v2.0 - Extensibility

  • Plugin architecture
  • Discord/Telegram support
  • Cloud deployment guides
  • Official API support (business accounts)

See ROADMAP.md for details.


πŸ“Š Project Stats

  • Code Quality: Clean, typed Python
  • Test Coverage: (Coming soon)
  • Documentation: Comprehensive guides
  • Community: Open to contributions

πŸ™ Acknowledgments

InstaBridge is the open-source alternative to:

  • Zapier Instagram+WhatsApp integrations ($20-100/month)
  • Interakt (CRM tool for businesses)
  • Bardeen.ai (paid automation)
  • Mark360.ai (enterprise solution)

Built for personal use, learning, and the open-source community.

Technology Stack:

Inspired By:


βš–οΈ License

MIT License with important disclaimers - see LICENSE for details.

Remember: This is an educational project. Use responsibly and at your own risk.


πŸ“ž Support


πŸŒ‰ InstaBridge - Bridge Your Social Media Platforms

Free Forever β€’ Open Source β€’ Extensible β€’ Privacy-First

⭐ Star this repo | πŸ› Report Bug | πŸ’‘ Request Platform

Made with ❀️ for the open-source community

About

Open-source Instagram to WhatsApp automation - Free alternative to commercial tools. Extensible to Telegram, Discord, and more

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

 
 
 

Contributors

Languages