Skip to main content

EP03Season 1

Auto-Reply to Instagram Comments

When someone comments a keyword on your Instagram Reel, they automatically get a private DM with your links, a public reply, and are saved as a lead. Free n8n template plus a step-by-step setup docs.

Setup time
60–90 min
Level
Intermediate
Cost
Free

Free n8n template · valerie-ep03-comment-to-dm.json

The Ep03 workflow on the n8n canvas: a Meta Verify webhook returns the challenge, and New Comment feeds Read Comment, the keyword check, Get Reel Caption, Find Season, Get Season Templates, Build DM, Send Private DM, Public Reply and Save Lead to Sheet.
Finished workflow in n8nOpen full size

What it does

Someone comments your keyword (e.g. VALERIE) on a Reel, and within seconds:

  1. 📩 They get a private DM with links (all templates from that Reel's season)
  2. 💬 Their comment gets a public reply: "Sent! Check your DMs @user ⚡"
  3. 📊 They're saved as a lead in Google Sheets

Flow: Instagram comment → Meta webhook → n8n → keyword check → read the Reel caption → find the season → get links from the Sheet → DM → public reply → save lead

Why it matters: every comment becomes a conversation and a lead, and Instagram shows Reels with more comments to more people.

What you need

ToolWhyCost
n8nRuns the automationFree trial / paid
Instagram Professional account (Business or Creator)Required by the APIFree
A Facebook Page linked to that Instagram accountRequired for the tokenFree
Meta developer appWebhooks + API accessFree
Google SheetsLinks + leadsFree

⚠️ This is the most technical episode. Set aside an hour and follow the steps in order.

Import the template

  1. Download the template (button above)
  2. n8n → Workflows → Create workflow → ⋯ → Import from File
  3. Choose valerie-ep03-comment-to-dm.json → Save

You'll see two starting points:

  • Meta Verify (GET): Meta uses this once to confirm the URL belongs to you
  • New Comment (POST): receives every new comment

Prepare your accounts

Instagram

  1. Switch to a Professional account (Settings → Account type)
  2. Link it to a Facebook Page (Instagram → Settings → Accounts Center, or Page settings → Linked accounts)
  3. Allow message access: Settings → Messages and story replies → Message controls → Connected tools → Allow access to messages ✅
    • Without this, DMs fail

Google Sheet: two tabs

Tab TEMPLATES, with one row per episode:

Season | Episode | Title | Link
1      | 1       | Reply in 5 Seconds | yourwebsite.com/s1e1
1      | 2       | AI Lead Scoring    | yourwebsite.com/s1e2

Tab LEADS:

Username | Comment | CommentID | MediaID | Season | Sent | Time | Status

💡 Use short links. A DM has a 1,000-character limit, and short links let 8 episodes fit easily.

Meta app

  1. Go to developers.facebook.com → My Apps → Create App → type Business
  2. Add the products Instagram (choose the option that uses Facebook Login / unified login) and Webhooks
  3. In App settings → Basic, add a Privacy Policy URL (needed to go Live)

Access token

  1. Open Graph API Explorer (developers.facebook.com/tools/explorer)
  2. Select your app → Get User Access Token with these permissions:
    • instagram_basic
    • instagram_manage_comments
    • instagram_manage_messages
    • pages_show_list
    • pages_read_engagement
    • pages_manage_metadata
  3. Turn it into a long-lived token (Access Token Debugger → Extend), or create a system user token in Business Settings so it doesn't expire
  4. The token starts with EAA…
    • 🔒 Never share it or show it on screen

Your Instagram account ID

In Graph API Explorer, run:

me/accounts?fields=name,instagram_business_account

Copy the instagram_business_account.id (a long number starting with 178…).

Connect the nodes

Header Auth credential (used 3 times)

Create a new Header Auth credential:

  • Name: Authorization
  • Value: Bearer YOUR_TOKEN

Select it in Get Reel Caption, Send Private DM and Public Reply.

Return Challenge

Replace PASTE_YOUR_VERIFY_TOKEN (it appears twice) with any secret word you choose, e.g. mybrand_verify_2026. You'll type the same word in Meta.

Says VALERIE?

Change valerie to your keyword in lowercase. Matching ignores capitals, so "Valerie", "VALERIE" and "valerie" all work.

Get Reel Caption → Find Season

Nothing to change. These read the Reel's caption and look for "Season 1" or "S1E3" to decide which links to send.

✏️ Put "Season 1, Episode 3" (or S1E3) in every Reel caption.

Get Season Templates

  1. Google credential → paste your Sheet URL → tab TEMPLATES
  2. Make sure the filter is set: column Season = {{ $json.Season }}

Build DM

Edit the 3 lines at the top:

const KEYWORD = 'VALERIE';                    // shown in the fallback DM
const HUB_LINK = 'yourwebsite.com/templates'; // sent when no season is found
const FOOT = '\nNeed help setting it up? Just reply here ⬇️\nA new automation every day 🚀';

Send Private DM

Replace YOUR_IG_ACCOUNT_ID in the URL with your ID from step 4.5.

Save Lead to Sheet

Google credential → Sheet URL → tab LEADS.

Save → Publish. The webhook must be published before Meta can verify it.

Connect the Meta webhook

  1. Copy the Production URL of the webhook (both nodes share the path valerie-ig)
  2. Meta app → Webhooks → choose the Instagram object → Subscribe to this object
    • Callback URL: your Production URL
    • Verify token: your secret word
  3. Click Verify and save. You should see a green tick ✅
  4. Subscribe to the comments field
  5. Switch the app to Live (top of the app dashboard)
    • In Development mode, real comments are not delivered

Test it

  1. From a different Instagram account, comment your keyword on a Reel whose caption contains "Season 1"
  2. Within a few seconds:
    • ✅ A DM arrives with the season's links (check Requests if you don't follow each other)
    • ✅ A public reply appears under the comment
    • ✅ A new row appears in LEADS
  3. In n8n, open Executions to watch it run

Comments from your own account are ignored on purpose, which prevents reply loops.

Common errors

ProblemFix
Webhook won't verifyPublish the workflow first; use the Production URL; the verify token must match exactly
Nothing happens on a real commentApp must be Live; subscribe to comments; check that the Page is subscribed to your app
DM error: "Cannot message users"Turn on Allow access to messages (step 4.1)
DM sent but no public replyCheck the instagram_manage_comments permission and the Public Reply credential
Fallback DM sent instead of the season linksThe caption has no "Season 1" / "S1E3", or the TEMPLATES tab has no rows for that season
Get Season Templates returns nothingRe-add the Season filter; the column name must be exactly Season
Error 190 token expiredCreate a long-lived or system user token
Second comment from the same person gets no DMInstagram allows one private reply per comment, so this is expected
Red error in a node previewOften old test data. Check the latest run under Executions.

Customise it

  • Use a different keyword per Reel ("GUIDE", "PRICE", "LINK") with a Switch node
  • Send one link instead of a whole season
  • Add a follow-up DM to people who reply
  • Send leads to your CRM instead of Sheets

Want it done for you?

We'll connect your Instagram, write your DMs and set up your keywords for you.

👉 Get it set up

Want this done for you?

Let's talk