Downloads
Download the n8n workflow (JSON)
instagram-dm-lead-agent-n8n-claude.json · n8n workflow · 22 steps · starts with Meta verify (GET) · uses Google Sheets, Anthropic, Slack · 32 KB
Import into n8n: Create Workflow, then the menu, then Import from File.
How to import it into n8n
- In n8n, create a new workflow.
- Open the ⋯ menu at the top right and choose Import from File, then pick the downloaded .json. (Or open the file, copy everything and paste it on the canvas.)
- Open each node with a warning and connect your own account: the file carries no passwords or keys.
- Run it once with Test workflow, check the result, then switch it to Active.
What this workflow does
You post a reel that says "Comment PLAN and I'll DM you the plan". This workflow does the DMing. Every comment with your keyword gets a private DM with the link within seconds, plus a short public reply under the comment. When people write back with questions, Claude answers from your FAQ sheet. Anything about fees, refunds or complaints is drafted and sent to Slack, and it only goes out when you tap Approve. Every person ends up as one row in a Leads sheet.
Who it is for
Creators, coaches, consultants and D2C brands who use "comment a keyword" posts and get more comments than they can answer by hand.
What you need
- An n8n account with a public URL (n8n Cloud or self-hosted with HTTPS)
- An Instagram professional (business or creator) account
- A Meta developer app using the Instagram API with Instagram Login, with messaging and comment permissions
- An Anthropic API key for Claude
- A Google Sheet and a Slack workspace
The workflow, step by step
Step 1 · Catch every comment and DM
Meta verify (GET) and Return challenge answer Meta's one-time check when you save the webhook URL. After that, Instagram webhook receives every new comment and DM. Clean up event turns Meta's batch into one item each, and drops your own replies and message echoes. Skip repeats remembers event ids, because Meta retries when it does not hear back fast. Comment or DM? sends comments one way and DMs the other.
Step 2 · Keyword comment, instant DM
Get keyword list reads your Keywords tab. Match keyword looks for a keyword as a whole word (so "PLAN please!!" matches PLAN) and builds the DM text from your template. Send resource DM sends a private reply tied to the comment. Reply to comment posts "Sent! Check your DMs" under it, and Log lead from comment adds the person to Leads.
Step 3 · Claude answers the follow-ups
DMs go to DM agent, powered by Claude, with Chat memory (last 10 messages per person) and Look up FAQ as its only source of facts. Reply format forces a fixed answer: reply, intent, safe to send, name, need.
Step 4 · Fees and complaints wait for you
Send or ask you? auto-sends safe answers, sends fee, refund, complaint and unsure answers to Approve reply on Slack, and drops spam. Approved? lets only approved drafts through to Send DM reply.
Step 5 · Every lead in one sheet
Update lead writes name, need, last message and status, matched on Instagram ID. If Instagram refuses a send, Send failed alert posts in Slack so you can reply by hand.
Setup
- Import the JSON into n8n.
- In your Meta app, add the Instagram product, connect your professional account and generate a long-lived access token.
- Create one Header Auth credential in n8n: name
Authorization, valueBearer YOUR_TOKEN. Select it on Send resource DM, Reply to comment and Send DM reply. - Activate the workflow, copy the production URL of Instagram webhook into the Meta app's webhook settings with your verify token, and subscribe to
commentsandmessages. Put the same token in Return challenge. - Create the Sheet tabs
Keywords,FAQandLeads(columns in the Setup sticky note), connect Google Sheets, Anthropic and Slack. - Comment your keyword from a second account and check the DM, the public reply and the new row.
How to customise
- Several keywords: one row per keyword in
Keywords, each with its own link and DM text. - Only on one post: add a Post ID column and compare it with
media_idin Match keyword. - Ask for email first: change the DM text to ask for their email, and add an email field to Reply format.
- Signature check: for extra safety, verify the
X-Hub-Signature-256header with your app secret in a Code node before Clean up event.
Guardrails
- Claude answers only from your FAQ sheet and never invents prices, discounts or results.
- Fees, refunds, complaints and unsure answers need your Approve in Slack.
- One DM per comment and per event id, so nobody gets the link twice from a retry.
Troubleshooting
- Meta says the callback URL could not be verified: the workflow must be active and the verify token in Return challenge must match exactly.
- Private reply error: the comment is older than 7 days, or a private reply was already sent for it.
- DM replies fail after a day: Instagram only allows replies within 24 hours of the person's last message.
- No events arrive: check the app is in Live mode and the account has the messaging permissions approved.
Want the members-only resources too?
A free account unlocks them all, including the ones shared in DMs.

