🔓 Unlock all 10,000+ workflows & prompts free Join Newsletter →
✅ Full access unlocked — explore all 10,000 AI workflow and prompt templates Browse Templates →
Home n8n Workflow
January 22, 2026

Instagram + OpenAI: smart comment replies, less spam

Lisa Granqvist Partner Workflow Automation Expert

Your Instagram comments don’t arrive in neat batches. They trickle in all day, and somehow the spammy ones show up first. Meanwhile the real questions (“price?”, “ship to…?”, “is this in stock?”) sit there making your brand look slow.

Social media managers feel this as constant context-switching. Small business owners end up replying late at night. And marketing leads trying to keep “brand voice” consistent across a team get stuck policing replies instead of running campaigns. This Instagram comment automation answers the good comments fast, filters junk, and routes exceptions to you.

This workflow listens for new comments, pulls in the post caption for context, uses an AI agent to decide what to do, and posts the reply right under the original comment. You’ll see how it works, what you need, and where teams usually trip up.

How This Automation Works

See how this solves the problem:

n8n Workflow Template: Instagram + OpenAI: smart comment replies, less spam

The Challenge: Keeping Up With Comments Without Feeding Spam

Instagram comment management sounds simple until you do it at scale. You open the app, scan a thread, check what the post was about, decide if the commenter is legit, then reply in the right tone. Repeat. Every time you switch apps or hunt for context, you lose momentum, and honestly, that’s where mistakes happen. The worst part is the opportunity cost: the more time you spend on comment triage, the less time you spend making content, improving offers, or following up with warm leads who are actually ready to buy.

It adds up fast. Here’s where it usually breaks down.

  • Real comments get delayed because you’re sifting through low-effort spam and bot replies first.
  • Replies come out inconsistent when multiple people jump in, which means more edits and occasional “that doesn’t sound like us” moments.
  • You end up replying without context, so questions get answered wrong or you miss the nuance of the post caption.
  • If you reply to your own account’s comments by accident, you can trigger awkward loops and messy threads.

The Fix: Auto-Reply to Instagram Comments With Context and Control

This workflow turns Instagram comments into a clean, repeatable process. When a new comment arrives through Instagram’s webhook, n8n verifies the webhook handshake (so you’re not accepting random calls), then maps the incoming payload into tidy fields like username, comment text, media ID, and the reply endpoint. Next, it fetches the post details from the Instagram Graph API, including the caption, so the AI isn’t replying blind. After that, the workflow filters out self-comments to prevent loops, and sends the comment, username, and caption into an AI agent with a system prompt built around your brand voice. The agent returns either a ready-to-post reply or a simple “[IGNORE]” for spam and irrelevant noise. If it’s a real comment, n8n publishes the reply directly into the comment thread.

The workflow starts with Instagram webhooks for “new comment” events. It enriches each comment by pulling the original post caption via HTTP request, then the AI agent generates (or rejects) the response. Finally, the automation posts the reply back through the Graph API, right where your audience expects it.

What Changes: Before vs. After

Real-World Impact

Say you get about 30 comments a day across a few posts. If you spend roughly 2 minutes per comment to open the thread, reread the caption, decide if it’s spam, and type a reply, that’s about 1 hour daily. With this workflow, you’re mostly just letting it run: the webhook triggers instantly, the AI drafts the reply in under a minute, and only the weird edge cases need a human look. That’s around 5 hours back in a typical week.

Requirements

  • n8n instance (try n8n Cloud free)
  • Self-hosting option if you prefer (Hostinger works well)
  • Instagram Graph API access to read and reply to comments.
  • OpenAI or OpenRouter-compatible key to generate replies via the AI agent.
  • Instagram access token (get it from Meta developer app credentials).

Skill level: Intermediate. You’ll connect API credentials, set webhook URLs, and tweak an AI prompt without writing code.

Need help implementing this? Talk to an automation expert (free 15-minute consultation).

The Workflow Flow

Webhook verification and event intake. Instagram calls your n8n webhook when you set up the subscription, and the workflow replies with the required challenge to confirm it’s legitimate. Once verified, incoming “new comment” events start flowing in.

Comment fields get structured. The workflow maps the payload into clean variables (username, comment text, comment ID, media ID, and the correct endpoint), so later steps don’t rely on brittle nested JSON.

Post context is pulled in. Using an HTTP request to the Instagram Graph API (v22.0), it fetches the post’s ID and caption. That caption is what makes replies feel “aware” instead of generic.

AI decides: reply or ignore. A filter removes self-comments first. Then the AI agent uses your system prompt to classify the comment (spam, praise, question, vague) and returns either a reply or “[IGNORE]”.

The reply gets posted under the comment. If the output is a real response, the workflow posts it back via the replies endpoint, directly into the thread.

You can easily modify the system prompt to match your exact brand voice, language, and “when to ignore” rules based on your needs. See the full implementation guide below for customization options.

Step-by-Step Implementation Guide

Step 1: Configure the Webhook Trigger

This workflow uses two webhook nodes to receive Instagram events and respond to the verification challenge.

  1. Open Incoming Webhook Trigger and set Path to ea7d37ac-9e82-40d7-bbb3-e9b7ce180fc9.
  2. Set Response Mode to responseNode so n8n can reply through Return Webhook Reply.
  3. Open Return Webhook Reply and set Respond With to text.
  4. Set Response Body to ={{ $json.query['hub.challenge'] }} for Instagram’s verification handshake.
  5. Open Receive New Comments and set Path to ea7d37ac-9e82-40d7-bbb3-e9b7ce180fc9 and HTTP Method to POST.

If Instagram verification fails, confirm the webhook URL matches the Incoming Webhook Trigger URL exactly and that the workflow is active.

Step 2: Connect Instagram Data Mapping and Post Lookup

This step maps incoming webhook payload fields and fetches the post caption for context.

  1. Open Map Incoming Fields and ensure the following assignments exist:
    • endpointhttps://graph.instagram.com/v22.0
    • conta.id={{ $json.body.entry[0].id }}
    • usuario.id={{ $json.body.entry[0].changes[0].value.from.id }}
    • usuario.name={{ $json.body.entry[0].changes[0].value.from.username }}
    • usuario.message.id={{ $json.body.entry[0].changes[0].value.id }}
    • usuario.message.text={{ $json.body.entry[0].changes[0].value.text }}
    • usuario.media.id={{ $json.body.entry[0].changes[0].value.media.id }}
  2. Open Fetch Post Details and set URL to =https://graph.instagram.com/v22.0/{{ $json.usuario.media.id }}?fields=id,caption.
  3. Set Authentication to genericCredentialType and Generic Auth Type to httpHeaderAuth.
  4. Credential Required: Connect your httpHeaderAuth credentials in Fetch Post Details.
  5. Credential Required: Connect your facebookGraphApi credentials in Fetch Post Details.

⚠️ Common Pitfall: If the Instagram Graph API token lacks the correct permissions, Fetch Post Details will fail even when the webhook is valid.

Step 3: Validate Incoming Users

The filter prevents your own account from responding to itself.

  1. Open Validate External User and confirm the condition checks that the account ID and user ID are not equal.
  2. Set the Left Value to ={{ $('Map Incoming Fields').item.json.conta.id }} and the Right Value to ={{ $('Map Incoming Fields').item.json.usuario.id }}.
  3. Ensure the operator is notEquals so only external commenters pass through.

Step 4: Set Up AI Response Generation

This workflow uses an AI agent with OpenRouter to craft replies in Portuguese and return [IGNORE] for spam.

  1. Open AI Response Orchestrator and keep Prompt Type set to define.
  2. Confirm the Text prompt includes the dynamic fields:
    • {{ $('Map Incoming Fields').item.json.usuario.name }}
    • {{ $('Map Incoming Fields').item.json.usuario.message.text }}
  3. Open OpenRouter Chat Engine and set Model to google/gemini-2.0-flash-exp:free.
  4. Credential Required: Connect your openRouterApi credentials in OpenRouter Chat Engine.
  5. Confirm OpenRouter Chat Engine is connected as the language model for AI Response Orchestrator (credentials should be added to OpenRouter Chat Engine, not the agent node).

If you see empty AI outputs, test OpenRouter Chat Engine credentials first, then re-run from AI Response Orchestrator.

Step 5: Configure Comment Reply Publishing

This step posts the AI response back as a reply to the original Instagram comment.

  1. Open Publish Comment Reply and set URL to ={{ $('Map Incoming Fields').item.json.endpoint }}/{{ $('Map Incoming Fields').item.json.usuario.message.id }}/replies.
  2. Set Method to POST and enable Send Body.
  3. In Body Parameters, set message to ={{ $json.output }}.
  4. Set Authentication to genericCredentialType and Generic Auth Type to httpHeaderAuth.
  5. Credential Required: Connect your httpHeaderAuth credentials in Publish Comment Reply.

⚠️ Common Pitfall: If the AI returns [IGNORE], ensure your logic does not post it as a public reply. Consider adding a conditional check if you want to skip replies.

Step 6: Test and Activate Your Workflow

Validate the full flow from webhook receipt to comment reply before enabling production.

  1. Use Receive New Comments to send a test webhook payload and verify Map Incoming Fields outputs the correct user and comment data.
  2. Run the workflow from Fetch Post Details and confirm Validate External User passes external commenters only.
  3. Check that AI Response Orchestrator returns a Portuguese reply or [IGNORE] as expected.
  4. Verify Publish Comment Reply posts the reply to the correct comment ID.
  5. When everything works, switch the workflow to Active to enable automated responses.
🔒

Unlock Full Step-by-Step Guide

Get the complete implementation guide + downloadable template

Watch Out For

  • Instagram Graph API credentials can expire or lack the right scopes. If things break, check the token validity and granted permissions in your Meta developer app first.
  • If you’re using Wait nodes or external rendering, processing times vary. Bump up the wait duration if downstream nodes fail on empty responses.
  • Default prompts in AI nodes are generic. Add your brand voice early or you’ll be editing outputs forever.

Common Questions

How quickly can I implement this Instagram comment automation automation?

About 30 minutes if your Instagram API access is already approved.

Can non-technical teams implement this comment automation?

Yes, but someone needs to handle the Meta app setup once. After that, it’s mostly connecting credentials and editing the reply prompt.

Is n8n free to use for this Instagram comment automation workflow?

Yes. n8n has a free self-hosted option and a free trial on n8n Cloud. Cloud plans start at $20/month for higher volume. You’ll also need to factor in OpenAI/OpenRouter API usage costs, which depend on how many comments you process.

Where can I host n8n to run this automation?

Two options: n8n Cloud (managed, easiest setup) or self-hosting on a VPS. For self-hosting, Hostinger VPS is affordable and handles n8n well. Self-hosting gives you unlimited executions but requires basic server management.

How do I adapt this Instagram comment automation solution to my specific challenges?

Start by editing the AI Response Orchestrator prompt so it matches your tone and your “ignore rules.” You can tighten spam filtering (for example, ignore giveaway bait and repeated emojis), add a “send to human review” path for pricing questions, or change reply length for different post types. If you want logging, add a Google Sheets node after Map Incoming Fields or after the agent output so you capture comment text, caption, and the final reply.

Why is my Instagram connection failing in this workflow?

Usually it’s an expired access token or missing scopes like instagram_manage_comments. Regenerate the token in your Meta app, confirm the correct permissions were granted, then update the credential used by the HTTP Request nodes. If it fails only during busy periods, you may be hitting rate limits, so add retry logic or slow down processing.

What’s the capacity of this Instagram comment automation solution?

It scales to hundreds of comments a day on a typical small-business setup.

Is this Instagram comment automation automation better than using Zapier or Make?

Often, yes. This workflow relies on webhook verification, multiple HTTP calls to the Graph API, filtering logic (self-comment checks and “[IGNORE]” handling), plus an AI agent step that benefits from more flexible branching. n8n is simply more comfortable when the automation is more than two steps, and self-hosting keeps costs predictable when volume spikes. Zapier or Make can still work for basic comment alerts, but full “reply with context” setups tend to get fiddly fast. If you want a second opinion on which platform fits your comment volume and risk tolerance, Talk to an automation expert.

Fast, on-brand replies without living in your notifications is a real upgrade. Set this up once, tune the prompt, and let the workflow handle the repetitive part while you focus on the comments that actually deserve your time.

Need Help Setting This Up?

Our automation experts can build and customize this workflow for your specific needs. Free 15-minute consultation—no commitment required.

Lisa Granqvist

Workflow Automation Expert

Expert in workflow automation and no-code tools.

×

Use template

Get instant access to this n8n workflow Json file

💬
Get a free quote today!
Get a free quote today!

Tell us what you need and we'll get back to you within one working day.

Get a free quote today!
Get a free quote today!

Tell us what you need and we'll get back to you within one working day.

Launch login modal Launch register modal