Skip to main content

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

Workflow preview

Workflow preview
100%
Auto-reply to Instagram comments with Gemini and Google Sheets tracking preview
Open on n8n.io

1. Workflow Overview

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

Best for

  • Social Media automation workflows
  • AI Chatbot automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.stickynote, n8n-nodes-base.manualtrigger, n8n-nodes-base.scheduletrigger, n8n-nodes-base.set, n8n-nodes-base.facebookgraphapi, n8n-nodes-base.code, n8n-nodes-base.googlesheets, n8n-nodes-base.if

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Tricore Infotech Pvt Ltd.

Original n8n.io source

1.1 Workflow description

Title
Auto-reply to Instagram comments with Gemini and Google Sheets tracking
Workflow name
Auto-reply to Instagram comments with Gemini and Google Sheets tracking

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

  • Context-Aware AI Replies: Gemini analyzes both your original post caption and the user's specific comment to craft a relevant, brand-aligned response.
  • Smart Deduplication: Uses Google Sheets as a lightweight database to instantly filter out previously replied-to comments by comment ID. Note: if the same user leaves multiple comments on a post, each comment will receive its own reply.
  • Rate-Limit & Error Protection: Built-in batching, delay nodes, and an API Error Fallback branch ensure Instagram API calls mimic human behavior and gracefully handle temporary rate limits without breaking the loop. Malformed AI responses are caught and skipped rather than crashing the batch.
  • Centralized Audit Trail: Every comment, AI-generated reply, and timestamp (or error status) is cleanly logged in Google Sheets for easy review and analytics. Each execution also logs the total number of comments processed.
  • Ready to Test: Comes with pinned sample data so you can inspect the logic and data mapping immediately, even before connecting your own credentials!

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

  • Facebook Graph API (Fetch posts, fetch comments, send replies)
  • Google Sheets (Read history, append new logs)
  • Google Gemini (Advanced AI LangChain Node)
  • Loop (Split in Batches)
  • Wait
  • Code (Data filtering and AI output parsing)
  • Set (Configuration)
  • No Operation (API Error Fallback)
  • Schedule / Manual Triggers

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
  1. Test: Click "Test Workflow". The template uses pinned sample data, allowing you to see exactly how the AI and loops function before going live.
  2. 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.
  3. Activate: Switch the workflow to Active. It will now poll for new comments every 15 minutes.

Requirements

  • n8n version 2.11.3+
  • Google Gemini API key (Input via the PaLM API credential type)
  • Instagram Business Account connected to a Facebook Page
  • API scopes: Facebook Graph API (instagram_manage_comments, pages_show_list, instagram_basic), Google Sheets (read/write).

Customization ideas

  • Monitor multiple posts: Modify the ingestion Code node to target an array of URLs instead of a single post.
  • Change the frequency: Update the Schedule Trigger to run hourly or daily depending on your traffic volume.
  • Advanced AI routing: Update the Gemini system prompt to detect negative sentiment and flag those comments in a Slack channel instead of auto-replying.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Sticky Note - Configure Node

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 2 - Sticky Note - Google Sheets Setup

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 3 - Template Overview

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 4 - Zone

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 5 - Zone 2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 6 - Zone 3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 7 - Zone 4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 8 - Zone 5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 9 - Manual Trigger

Type / Role
n8n-nodes-base.manualTrigger - manualTrigger
Config choices
Version 1

Block 10 - Schedule Trigger (Every 15 min)

Type / Role
n8n-nodes-base.scheduleTrigger - scheduleTrigger
Config choices
Version 1.2

Block 11 - Configure Post & Message

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.3

Block 12 - Get Instagram Posts

Type / Role
n8n-nodes-base.facebookGraphApi - facebookGraphApi
Config choices
Version 1

Block 13 - Filter and Get Post ID

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 14 - Get All Comments

Type / Role
n8n-nodes-base.facebookGraphApi - facebookGraphApi
Config choices
Version 1

Block 15 - Read Contacted Users

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4

Block 16 - Filter New Comments

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 17 - Check If Has New Comments

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2

Block 18 - Reply on Comments

Type / Role
n8n-nodes-base.facebookGraphApi - facebookGraphApi
Config choices
Version 1

Block 19 - API Error Fallback

Type / Role
n8n-nodes-base.noOp - noOp
Config choices
Version 1

Block 20 - Skip (No New Comments)

Type / Role
n8n-nodes-base.noOp - noOp
Config choices
Version 1

Block 21 - Record Contacted User

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4

Block 22 - Generate Summary

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 23 - Loop Over Items

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 24 - Parse AI Reply

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Showing the first 24 of 26 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Auto-reply to Instagram comments with Gemini and Google Sheets tracking
Complexity advanced
Nodes 26
Categories Social Media, AI Chatbot
Author Tricore Infotech Pvt Ltd
Published 04 May 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/15465/15465.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Auto-reply to Instagram comments with Gemini and Google Sheets tracking do?

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

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Social Media, AI Chatbot use case.