Want Instagram DM automation without paying for another SaaS tool? Here's how to wire up a keyword-based auto-reply flow in n8n, step by step.
Instagram DM automation sounds complicated, but at its core it's pretty simple: a message comes in, your system checks what it says, and it sends the right reply. That's it. You can build that with n8n, the open-source workflow tool, in an afternoon. This guide walks you through the full setup, from connecting Instagram to routing messages by keyword.
TL;DR
- Connect Instagram to n8n using a webhook or the Instagram trigger node.
- Route incoming messages with a keyword-based router (n8n's Switch or IF nodes work great).
- Send replies back through the Instagram node.
- Test everything on a second account before it touches real followers.
- Respect Instagram's rules: official API only, no spam patterns, honor the messaging window.
What This Flow Actually Does
Every workflow has the same skeleton: listen → decide → reply. In n8n that looks like:
- An Instagram trigger fires when someone DMs you or comments with a keyword.
- A Switch node checks the message text for keywords like "price", "book", or "hours".
- An Instagram send-message node replies with the right answer for each keyword.
- A fallback path sends a generic "thanks for reaching out, here's how we can help" reply when no keyword matches.
You can build this entire thing with zero custom code. That's the real appeal of n8n for this job.
What You Need Before You Start
- An Instagram account switched to a Professional (Business or Creator) account. This is non-negotiable: the official Instagram API only works with professional accounts, and any automation that ignores this is either scraping or begging to be banned.
- A Meta app with the Instagram messaging permissions, connected through OAuth. Keep the flow inside Instagram's official API. Third-party hacks that log in with your password are exactly how accounts get flagged.
- n8n running somewhere: their cloud trial, a VPS, or self-hosted with Docker. If self-hosted, make sure it's reachable over HTTPS so Meta can send webhooks to it.
Honestly, the Meta app setup is the fiddliest part. The actual n8n flow takes maybe 30 minutes once webhooks are flowing.
Step 1: Connect Instagram to n8n
Create a workflow in n8n and add an Instagram trigger as the first node. You'll authenticate with your Meta app credentials through OAuth. Set the trigger to listen for new direct messages.
A quick sanity check: send yourself a DM from another account and confirm the execution fires in n8n. If it does, the plumbing works and everything after this is logic.
Step 2: Add the Keyword Router
This is the heart of the flow. Add a Switch node after the trigger and create rules based on the incoming message text. A simple version looks like this:
- Rule 1: message contains "price" or "cost" → send the pricing reply
- Rule 2: message contains "book" or "appointment" → send the booking link reply
- Rule 3: message contains "hours" or "open" → send the opening hours reply
- Rule 4 (default): everything else → send a friendly fallback reply that lists what people can ask about
Keep keywords lowercase and use "contains" matching so "What are your PRICES?" still hits. Don't over-engineer this. Four to six keyword buckets cover most small-business inboxes.
Step 3: Write the Replies
Connect an Instagram send-message node to each rule output. A few rules for replies that don't feel like a robot:
- One job per message. Answer the question and add at most one next step, like a link. Nobody wants a wall of text in a DM.
- Sound like a person. "Hey! Here's our price list 👇" beats "Thank you for your inquiry. Please find attached pricing information."
- Include a fallback offer. Every reply should tell the person what to do if that wasn't what they meant. Something like "not what you were after? just type 'help' and we'll sort it out."
Step 4: Add Guardrails
A router without guardrails is how you end up spamming people. Add these before you go live:
- A per-user message cap. Track who you've replied to and don't send more than one or two automated replies per person per day.
- A "human takeover" path. If the same person messages three times without a keyword match, stop replying automatically and flag the conversation for a human.
- The 24-hour window. Instagram's messaging rules limit promotional messages to people who contacted you recently. Keep automated replies conversational, not sales blasts, and you stay on the right side of it.
Step 5: Test on a Second Account First
This one is boring and absolutely essential. Get a second Instagram account, DM your business account with each keyword, and watch the flow run. Check for:
- Keywords matching when they should (and not when they shouldn't)
- Replies landing in the right order
- The fallback firing on nonsense input like "asdfgh"
Only point it at real followers when the test account works cleanly three times in a row.
FAQ
What is the safest way to do Instagram DM automation?
The safest approach is automation that runs on Instagram's official API, authenticates with OAuth through Facebook Login, and never touches your password. Tools that log in as you or scrape the site get accounts flagged. If a tool can't tell you exactly how it connects to Instagram, that's your answer.
Is building my own flow with n8n better than using a dedicated tool?
It depends on what you value. Building it yourself in n8n gives you full control and can be cheaper, but you're now the one maintaining webhooks, handling API changes, and fixing things at midnight when Meta ships an update. A dedicated platform handles all of that for you. The trade-off is control versus maintenance.
Will Instagram ban my account for using n8n?
Instagram doesn't ban tools; it bans behavior. Automation through the official API that replies to people who messaged you first, at sane volumes, is how thousands of businesses run their inboxes. What gets accounts restricted is spam behavior: blasting cold DMs, replying to the same person ten times a day, or using unofficial apps that scrape.
If You'd Rather Not Self-Host
Building this in n8n is fun and cheap, but it's also a weekend project that becomes an ongoing maintenance job. If you'd rather have the whole thing managed, here's the short version: Zextra is an Instagram DM automation platform and official Meta tech partner, so it runs comment-to-DM, keyword auto-replies, and follow-ups through the official API without you touching webhooks or servers. That's the one option I'd point at if DIY isn't your thing.
Final Thoughts
The best Instagram DM automation is the kind nobody notices. A keyword router built in n8n gets you 90% of the way there: listen for messages, match keywords, reply like a human, and stay quiet when you're not sure. The tool matters less than the discipline. Official API, sensible volumes, tested replies, and a human watching the edge cases will beat the fanciest setup with none of those.

Top comments (0)