📱 Auto-reply to Instagram comments with Gemini and Google Sheets tracking

⚡ 271 views · 📱 Social Media & Email Marketing

💡 Pro Tip — Heads up — if this workflow’s Instagram scraping breaks (it happens whenever Meta updates their frontend), ScraperNode is a community node that handles profiles, posts, reels, and comments without any HTML parsing.

View All Scrapers

Description

AI Auto-Reply to Instagram Comments with Gemini & Google Sheet Tracker

Summary

Automate your Instagram community management without sounding like a bot. This workflow monitors a specific Instagram post, uses Gemini 2.5 Flash to generate context-aware, highly personalized replies to new comments, and logs every interaction in Google Sheets.

It includes built-in deduplication (so you never reply to the same comment twice), rate-limit protection, and resilient error handling to ensure your workflow never crashes even if the Facebook API hiccups. Perfect for social media managers, creators, and brands handling viral posts or high-engagement campaigns.

> Note: This workflow processes up to 100 recent comments per run. Posts with more than 100 comments will have older comments silently skipped — pagination is not currently handled.

Key features

How it works

  1. Trigger: Runs automatically on a 15-minute schedule (or manually via click).
  2. Fetch: Pulls your recent media and up to 100 recent comments via the Facebook Graph API.
  3. Filter: Compares live comment IDs against your Google Sheet history to isolate strictly new comments.
  4. Generate: For each new comment, Gemini 2.5 Flash drafts a unique reply based on your preset brand guidelines.
  5. Execute & Log: Posts the reply to Instagram, waits 1 second (for API safety), and appends the complete interaction record to your Google Sheet. If a reply fails, it logs “API Error” to the sheet and continues processing the rest. If Gemini returns unparseable output, that comment is skipped gracefully and logged with an empty reply field.

Nodes used

Setup instructions

  1. Credentials: Authenticate your Facebook Graph API and Google Sheets credentials. For the Gemini node, create a new “Google Gemini(PaLM) Api account” credential and paste your Google AI Studio key.
  2. Database Setup: Create a blank Google Sheet and add these exact headers to Row 1: comment_id, username, comment, reply_id, reply, comments_timestamp, post_url, reply_timestamps. The workflow expects the sheet tab to be named Sheet1 (the default). If you rename the tab, update the sheetName field in both the Read Contacted Users and Record Contacted User nodes.
  3. Configuration: Open the ⚙️ Configure Post & Message node and fill in:
    • Target Instagram post URL
    • Instagram Business Account ID
    • Brand Name & Brand Tone
    • Google Sheet URL
  4. Test: Click “Test Workflow”. The template uses pinned sample data, allowing you to see exactly how the AI and loops function before going live.
  5. Error Workflow (Optional but recommended): Go to your workflow settings and assign a global Error Workflow so you get notified if the credentials ever expire.
  6. Activate: Switch the workflow to Active. It will now poll for new comments every 15 minutes.

Requirements

Customization ideas

đź”— Nodes Used

Google Sheets, Facebook Graph API, Schedule Trigger, Google Gemini

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup