Skip to main content

Automated Instagram comment replies using Gemini AI with context-aware responses

Workflow preview

Workflow preview
100%
Automated Instagram comment replies using Gemini AI with context-aware responses preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Instagram Auto Comment Responder with AI Agent Integration Version: 1.1.0 ‧ n8n Version: 1.88.0+ ‧ License: MIT A fully automated workflow for managing and responding to Instagram comments using AI...

Best for

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

Tools used

n8n-nodes-base.webhook, n8n-nodes-base.stickynote, n8n-nodes-base.respondtowebhook, @n8n/n8n-nodes-langchain.agent, @n8n/n8n-nodes-langchain.lmchatopenrouter, n8n-nodes-base.httprequest, n8n-nodes-base.set, n8n-nodes-base.filter

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Luciano Gutierrez.

Original n8n.io source

1.1 Workflow description

Title
Automated Instagram comment replies using Gemini AI with context-aware responses
Workflow name
Automated Instagram comment replies using Gemini AI with context-aware responses

Instagram Auto-Comment Responder with AI Agent Integration

Version: 1.1.0 ‧ n8n Version: 1.88.0+ ‧ License: MIT

A fully automated workflow for managing and responding to Instagram comments using AI agents. Designed to improve engagement and save time, this system listens for new Instagram comments, verifies and filters them, fetches relevant post data, processes valid messages with a natural language AI, and posts context-aware replies directly on the original post.


Key Features

  • 💬 AI-Driven Engagement: Intelligent responses to comments via a GPT-powered agent.
  • Webhook Verification: Handles Instagram webhook handshake to ensure secure integration.
  • 📦 Data Extraction: Maps incoming payload fields (user ID, username, message text, media ID) for processing.
  • 🚫 Self-Comment Filtering: Automatically skips comments made by the account owner to prevent loops.
  • 📡 Post Data Retrieval: Fetches the media’s id and caption from the Graph API (v22.0) before generating a reply.
  • 🧠 Natural Language Processing: Uses a custom system prompt to maintain brand tone and context.
  • 🔁 Automated Replies: Posts the AI-generated message back to the comment thread using Instagram’s API.
  • 🧩 Modular Architecture: Clear separation of steps via sticky notes and dedicated HTTP Request and Agent nodes.

Use Cases

  • Social Media Automation: Keep followers engaged 24/7 with instant, relevant replies.
  • Community Building: Maintain a consistent voice and tone across all interactions.
  • Brand Reputation Management: Ensure no valid comment goes unanswered.
  • AI Customer Support: Triage simple questions and direct followers to resources or support.

Technical Implementation

  1. Webhook Verification

    • Node: Webhook + Respond to Webhook
    • Echoes hub.challenge to confirm subscription and secure incoming events.
  2. Data Extraction

    • Node: Set
    • Maps payload fields into structured variables: conta.id, usuario.id, usuario.name, usuario.message.id, usuario.message.text, usuario.media.id, endpoint.
  3. User Validation

    • Node: Filter
    • Skips processing if conta.id equals usuario.id (self-comments).
  4. Post Data Retrieval

    • Node: HTTP Request (Get post data)
    • GET https://graph.instagram.com/v22.0/{{ $json.usuario.media.id }}?fields=id,caption&access_token={{ credentials }}
    • Captures the media’s caption for richer context in replies.
  5. AI Response Generation

    • Nodes: AI Agent + OpenRouter Chat Model
    • Uses a detailed system prompt with:
      • Profile persona (expert in AI & automations, friendly tone).
      • Input data (username, comment text, post caption).
      • Filtering logic (spam, praise, questions, vague comments).
    • Returns either the reply text or [IGNORE] for irrelevant content.
  6. Posting the Reply

    • Node: HTTP Request (Post comment)
    • POST {{ $json.endpoint }}/{{ $json.usuario.message.id }}/replies with message={{ $json.output }}
    • Sends the AI answer back under the original comment.

Instructions for Setup

  1. Import Workflow
    In n8n > Workflows > Import from File, upload the provided .json template.

  2. Configure Credentials

    • Instagram Graph API (Header Auth or FacebookGraphApi) with instagram_basic, instagram_manage_comments scopes.
    • OpenRouter/OpenAI API key for AI agent.
  3. Customize System Prompt

    • Edit the AI Agent’s prompt to adjust brand tone, language (Brazilian Portuguese), length, or emoji usage.
  4. Test & Activate

    • Publish a test comment on an Instagram post.
    • Verify each node’s execution, ensuring the webhook, filter, data extraction, HTTP requests, and AI Agent respond as expected.
  5. Extend & Monitor

    • Add sentiment analysis or lead capture nodes as needed.
    • Monitor execution logs for errors or rate-limit events.

Tags

Social Media • Instagram Automation • Webhook Verification • AI Agent • HTTP Request • Auto Reply • Community Management

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

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

Block 2 - Sticky Note

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

Block 3 - Respond to Webhook

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1.1

Block 4 - AI Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 1.8

Block 5 - OpenRouter Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenRouter - lmChatOpenRouter
Config choices
Version 1

Block 6 - Sticky Note1

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

Block 7 - Sticky Note2

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

Block 8 - Sticky Note3

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

Block 9 - Sticky Note4

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

Block 10 - Get post data

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 11 - get_new_comments

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

Block 12 - data

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

Block 13 - its me?

Type / Role
n8n-nodes-base.filter - filter
Config choices
Version 2.2

Block 14 - Post comment

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

3. Summary Table

Workflow Automated Instagram comment replies using Gemini AI with context-aware responses
Complexity intermediate
Nodes 14
Categories Social Media, AI Chatbot
Author Luciano Gutierrez
Published 25 Apr 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/3713/3713.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 Automated Instagram comment replies using Gemini AI with context-aware responses do?

Instagram Auto Comment Responder with AI Agent Integration Version: 1.1.0 ‧ n8n Version: 1.88.0+ ‧ License: MIT A fully automated workflow for managing and responding to Instagram comments using AI...

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.