Automate every Reel comment flow, one Reel at a time.
ReelPilot is an enhancement to an existing Instagram automation Telegram bot that lets users create independent automation rules for individual Instagram Reels. It is designed for creators, marketers, and operators who need separate messages, replies, and follow-gated delivery per Reel without cross-triggering or shared configuration leakage.
Creator Ops Nina, 31 - Nina manages multiple promotions from one Instagram account and needs separate comment automation for each Reel. She wants to avoid sending the wrong PDF or product link to the wrong audience.
Agency Admin Leo, 38 - Leo oversees multiple clients and multiple Instagram accounts in one Telegram workspace. He needs safe controls, approval visibility, and account-level monitoring without mixing data across users.
Solo Seller Maya, 27 - Maya sells digital products and uses Instagram Reels to drive leads into Telegram-delivered guides. She needs a simple setup flow that works without technical knowledge.
Maya runs a small digital product business and uses Instagram Reels to attract leads. Before this feature, she could only use one shared comment automation setup, which meant different Reels often sent the wrong message or the wrong file to commenters.
With Reel Automation Manager, Maya opens the Telegram bot, refreshes her Reels, picks one specific Reel, and attaches a unique message, link, and reply template. She sets another Reel to require follow verification before sending a premium guide, while a third Reel sends a different product pitch without any follow gate.
Now each Reel works independently, comments are handled safely, and failed verification never exposes protected material. Maya spends less time correcting mistakes and more time measuring which Reel converts best, while the bot stays aligned with the behavior of her campaign instead of one global rule set.
Team & resourcing - Small team - 2 backend engineers, 1 Telegram UX designer, part-time PM, and shared QA support.
Paste this into Cursor, Bolt, Lovable, or v0 to start building.
Build an enhancement for an existing Python Telegram bot that manages Instagram automation. The app already uses python-telegram-bot, instagrapi, asyncio background tasks, Fernet-encrypted sessions, and JSON persistence in data.json. Do not rewrite the app; add a new Reel Automation Manager with minimal, targeted changes and preserve all existing features and menus. Core requirement: Add independent per-Reel automation rules for connected Instagram accounts. Users must be able to fetch and view Reels, identify each Reel by media ID, caption preview, thumbnail when available, and publication date, then create separate automations per Reel. Each automation needs its own delivery text, URL, media/material attachment, public comment reply template, trigger mode, follow requirement, non-follower instruction, active/paused status, duplicate protection, and event history. Default trigger is every eligible comment. A comment on one Reel must never trigger another Reel’s automation. Functional scope: Create Telegram screens for My Reels, Create Automation, Active Automations, Refresh Reels, Statistics, and Back to Main Menu. Support edit, pause, resume, disable, and delete with confirmation. Preserve all existing global comment reply and delivery systems unchanged and independent from the new Reel manager. Data and architecture: Extend the existing JSON storage with backward-compatible defaults and migration for old records. Use atomic writes and synchronization to prevent lost updates. Persist automation state and recovery metadata so active automations can be restored after restart. Track comment processing states explicitly, including pending, replied, delivered, blocked, failed, and retryable. Use idempotent keys based on account ID, Reel media ID, comment ID, commenter ID, and automation ID. Workflow: For each new eligible comment, identify the exact account, Reel media ID, comment ID, and commenter. Check whether the comment was already processed. Publish the configured public reply when allowed. If follow requirement is off, send only that Reel’s assigned material. If follow requirement is on, verify the commenter with strict states FOLLOWING, NOT_FOLLOWING, UNKNOWN. Only send protected material for FOLLOWING. If NOT_FOLLOWING, send the configured follow-and-comment-again instruction. If UNKNOWN or API error, never send protected material; record the failure and retry safely. Prevent duplicate replies and deliveries. Instagram feasibility: Use instagrapi where supported for Reel listing, comment retrieval, and follower verification, but handle unsupported or unreliable operations safely. Never promise guaranteed delivery. Gracefully label unknown, blocked, or rate-limited states and keep protected material from being exposed when verification is not definitive. UI: Keep the current Telegram inline keyboard style. Show account name, Reel media ID, and clear status labels. Keep screens concise for mobile use. Add admin monitoring for automation counts, success/failure stats, active jobs, and safe pause controls. Implementation details: Use Python 3.11, the existing bot.py as the main integration point, and add new modules only if genuinely useful for Reel management, storage, and handlers. Do not remove or rename existing handlers unless required for compatibility. Add structured logging, retries with backoff, rate-limit handling, and restart recovery. Preserve legacy user records and existing scheduled DMs, comment reply, delivery, admin, and monitoring features. Include rollback support and feature flags or safe disable switches if needed. Deliver a production-ready scaffold with screens, state management, data models, event tracking, and safe defaults. Prioritize correctness, idempotency, and preserving all current bot behavior.
PRD REQUIREMENT: ADD A REEL AUTOMATION MANAGER TO THE EXISTING INSTAGRAM TELEGRAM BOT Act as a senior software architect, Python backend developer, Telegram bot specialist, and Instagram automation expert. First understand the existing project described below. Create a precise, implementation-ready Product Requirements Document (PRD). Do not write or modify code yet. 1. EXISTING PROJECT OVERVIEW The project is a Python-based Instagram automation Telegram bot. Its main source file is "bot.py" (approximately 1,153 lines). Supporting files are "README.md", "requirements.txt", "render.yaml", and ".gitignore". Current architecture: - Python with "python-telegram-bot" and "instagrapi". - Telegram inline keyboards, callback handlers, and conversation-based configuration. - Asyncio background tasks for automation. - JSON-based persistent storage through "data.json" at runtime. - Instagram sessions encrypted using Fernet. - Media storage and multiple Instagram accounts per user. - Instagram operations frequently run through "asyncio.to_thread()". - Existing account-specific locks and background loops. Important existing integration points: - "ig_comments()": background comment-scanning system. - "_deliver()": existing DM delivery helper. - "_follows_me()": Instagram follower-verification helper. - "r_cr()" and "in_cr_kw()": existing Comment Reply configuration. - "r_dl()", "in_d_text()", and "in_d_media()": existing Link/File Delivery configuration. - "A()": JSON data initialization/access helper. - "render.yaml": deployment configuration. Existing comment scanning checks approximately the latest five media posts and retrieves up to 30 comments per post per scan. It tracks processed comments, supports keyword filtering, can publish configured replies, and can send existing shared Delivery material. An empty keyword list currently allows all new comments. It does not provide independent automation settings for individual Reels. 2. EXISTING FEATURES THAT MUST BE PRESERVED Do not remove, replace, rename, redesign, or break any existing functionality. Preserve: - Telegram registration and user approval. - Instagram login, encrypted sessions, multiple accounts, account selection/removal. - Auto DM to targets and followers, single DM, incoming DM auto-reply. - General Link/File Delivery and keyword-triggered delivery. - Follow-required DM delivery and non-follower instructions. - Photo/video delivery, welcome DMs, story replies. - Existing Comment Reply and comment-triggered DM. - Scheduled DMs, saved templates, username placeholders, spintax. - Delays, daily limits, and user activity/status. - Admin approval/rejection, ban/unban, user search/details. - Admin limits, maintenance mode, broadcasts, statistics, account/job monitoring. The existing General Delivery and Comment Reply systems must remain independent of the new Reel Automation Manager. 3. NEW FEATURE: INDEPENDENT REEL AUTOMATION MANAGER Add a new Telegram menu item called Reel Automation Manager. Users should be able to: 1. Fetch and view Reels from their connected Instagram account. 2. Identify each Reel using its media ID, caption, thumbnail (if available), and publication date. 3. Select an individual Reel and create a separate automation for it. 4. Configure multiple Reels independently (e.g. 10 Reels, each with different messages and rules). 5. Enable, disable, edit, pause, or delete each automation. Each Reel must have its own: - Delivery text/message. - URL or link. - Supported media/material configuration. - Public comment reply template. - Trigger mode (default: every new comment; optional keyword filtering). - Follow requirement ON/OFF. - Non-follower instruction message. - Active/inactive status. - Duplicate protection settings. - Statistics and event history. Example: Reel A promotes a PDF guide and sends its link. Reel B promotes a course and sends a different message. Reel C promotes a product and sends different information. A comment on one Reel must never trigger another Reel's material. Default trigger: every eligible new comment, without requiring a keyword. 4. REQUIRED AUTOMATION WORKFLOW For every new eligible comment: 1. Identify the exact Instagram account, Reel media ID, comment ID, and commenter. 2. Check whether that comment has already been processed. 3. Publish the configured public reply, where permitted. 4. If follow requirement is OFF, send only that Reel's assigned material. 5. If follow requirement is ON, verify whether the commenter follows the connected account. 6. If FOLLOWING, send the assigned material. 7. If NOT FOLLOWING, send the configured instruction asking the user to follow and comment again. 8. When the user comments again, recheck follow status and deliver the correct material if verified. 9. If verification returns UNKNOWN or an API error, never send protected material. Record the failure and retry safely when appropriate. Use strict verification states: FOLLOWING, NOT_FOLLOWING, UNKNOWN. Never treat an API failure as proof that someone follows. Prevent duplicate replies and deliveries using appropriate comment, user, Reel, and account identifiers. 5. TELEGRAM INTERFACE Preserve the existing UI style and navigation. Add the new manager without disturbing existing menus. Suggested menu: - My Reels - Create Automation - Active Automations - Refresh Reels - Statistics - Back to Main Menu Each Reel's settings should be editable individually, with confirmation before deletion. Show useful status and delivery history. 6. ADMIN AND PERMISSIONS Users can manage only their own connected accounts and Reel automations. Admins retain existing permissions and gain suitable system-wide monitoring: - Automation counts and active jobs. - Success/failure statistics. - Per-user and global usage limits. - Error/health monitoring. - Ability to pause problematic automation safely. Check admin authorization on every privileged action. Never expose Instagram session credentials or private user data unnecessarily. 7. EXISTING CODE PROBLEMS TO ADDRESS The PRD must explicitly cover these observed issues and propose targeted fixes: - "_follows_me()" currently fails open by returning True when verification fails. Replace this behavior with strict verification for the new protected workflow. - "ig_comments()" marks comments processed before all operations are confirmed. Design safer processing states and retry handling. - Comment-triggered delivery needs consistent daily-limit accounting. - Concurrent access to "data.json" risks lost updates or corruption. Specify synchronization and atomic writes. - "A()" may not initialize every missing field in existing records. Define backward-compatible defaults and migration. - In-memory background tasks may be lost after restarts. Define safe recovery from persisted configurations. - Scheduled delivery may lose jobs if a schedule is removed before delivery succeeds. - Improve operation-level logging, error handling, duplicate prevention, and retry management. - "render.yaml" currently has an indentation/YAML parsing problem that must be corrected. - Verify persistent storage requirements for JSON data and media during deployment. - Review session security and avoid exposing credentials through Telegram messages or logs. Distinguish confirmed problems from risks requiring further testing. Do not claim unverified behavior is a confirmed bug. 8. ARCHITECTURE AND IMPLEMENTATION RULES This is an enhancement to an existing project, NOT a complete rewrite. - Keep "bot.py" and existing functions wherever practical. - Integrate with existing account management, Telegram handlers, storage, and background tasks. - Add separate modules for Reel management/storage/handlers only where genuinely useful. - Make minimal, targeted changes to existing functions. - Do not duplicate existing functionality unnecessarily. - Preserve existing data and support old user records. - Avoid unnecessary dependencies and database migrations. - Include error handling, logging, rate limits, retries, idempotency, and restart recovery. - Back up original files and data before implementation. - Provide rollback instructions. 9. INSTAGRAM API FEASIBILITY AND COMPLIANCE Do not assume "instagrapi" supports every requested operation reliably. Research and clearly document: - Reel discovery and pagination. - Comment retrieval and identification. - Private comment replies/DM delivery. - Follower verification. - Messaging restrictions and eligibility windows. - Rate limits, account restrictions, and platform policies. Separate supported, partially supported, and unsupported operations. Provide realistic alternatives where necessary. Never promise guaranteed delivery or bypass Instagram restrictions. 10. REQUIRED PRD OUTPUT Produce a professional PRD containing: 1. Executive summary and objectives. 2. Existing architecture and feature inventory. 3. Existing code integration points and exact functions affected. 4. Confirmed bugs, risks, and required fixes. 5. Detailed functional requirements and user workflows. 6. Telegram UI and admin requirements. 7. Data model and backward-compatible storage design. 8. Automation lifecycle, duplicate protection, retries, and recovery. 9. Security, permissions, and privacy. 10. Instagram API feasibility and compliance. 11. Performance, reliability, logging, and deployment. 12. Acceptance criteria and test cases. 13. Regression tests for every existing feature. 14. Phased implementation plan and rollback strategy. For every proposed change, specify WHAT changes, WHERE it changes, WHY it is necessary, HOW it integrates, and WHAT existing functionality must remain untouched. Include concrete examples, edge cases, failure scenarios, and measurable acceptance criteria. Do not use vague statements such as "improve automation." FINAL RESTRICTION This stage is PRD planning only. Do not generate source code, rewrite files, or assume permission to implement. The first priority is preserving the existing bot and adding the new Reel Automation Manager through minimal, controlled changes. If any requested feature is technically impossible or unsupported, state that honestly and propose the safest practical alternative. Wait for approval of the PRD before preparing the technical design and implementation plan.
Design by The Resonance | Powered by GPC – The AI Transformation Company