Back to Blog

n8n Instagram DM Automation: Step-by-Step Workflow (2026)

n8n Instagram DM Automation: Step-by-Step Workflow (2026)
J
Jan van MusscherFounder @ FlowGent

You can automate Instagram DMs with n8n, and this guide walks through the whole workflow: the Meta app, the webhook that delivers messages to n8n, the node that sends the reply, comment-to-DM, and the token refresh that most tutorials skip. It also covers where DIY setups tend to break, so you can decide whether to build it yourself or use a ready-made tool.

The short version: Instagram sends a webhook to n8n when someone messages your professional account, and n8n replies by calling Meta's messaging endpoint with the HTTP Request node. The workflow itself is small. The Meta setup around it is where the time goes.

Can You Automate Instagram DMs With n8n?

Yes, for Instagram professional accounts (business or creator), through Meta's official API. Three details shape what you can build:

  • n8n can receive Instagram events natively. The built-in Facebook Trigger node has an Instagram object with fields for messages, comments, mentions, and story insights.
  • Sending is done with the HTTP Request node. You call Meta's /messages endpoint yourself, so you handle the token, the recipient ID, and the error cases.
  • It is a reply API, not a broadcast API. Per Meta's documentation, your app can message a person only after they have messaged your account, and for commenters you get a single private reply. If you are asking whether you can automate DMs to people who never contacted you, the answer is no, with n8n or any other tool that follows the rules. Our Instagram DM limits guide covers the practical side.

For the full API background (permissions, access levels, error codes), see our Instagram Messaging API guide. This post focuses on wiring it into n8n.

Turn Instagram DMs into booked calls

AI that qualifies leads, handles objections, and follows up - so you don't have to.

Start Free Trial

What You Need Before You Start

  • An Instagram professional account. Switch a personal account to Business or Creator first.
  • A Meta developer account and a Business-type app. Meta's get-started guide says that if your app is not a Business type app, you need to create a new one.
  • An n8n instance reachable over public HTTPS. n8n Cloud works, and so does self-hosting behind a valid TLS certificate. Meta does not support self-signed certificates for webhook endpoints, and localhost will not work without a tunnel.
  • The right access level. Standard Access is enough when your app only serves Instagram accounts you own or manage. Serving other businesses requires Advanced Access, which means App Review and Business Verification.
  • A published (Live) Meta app. Meta's webhook setup guide says your app must be Live to receive notifications for app users.
  • Optional: an AI model credential such as OpenAI, if you want generated replies instead of fixed text.

Plan for the review step if you are building for other people's accounts. For your own account it is much lighter, which is why many n8n tutorials skip over it.

How the n8n Workflow Fits Together

Someone DMs your account
        |
Meta sends a webhook  ->  n8n trigger (Facebook Trigger or Webhook node)
        |
Filter: ignore your own echoes, keep text messages
        |
Decide the reply: keyword rules (Switch) or an AI Agent node
        |
HTTP Request: POST graph.instagram.com/v26.0/<IG_ID>/messages
        |
The person receives the reply in their Instagram inbox

The same shape handles comment-to-DM. Only the trigger field (comments instead of messages) and the recipient (a comment ID instead of a user ID) change.

Step 1: Create the Meta App and Get a Token

This guide uses the Instagram API with Instagram Login, because it does not require a linked Facebook Page. Meta also offers Instagram API with Facebook Login (Page-linked, graph.facebook.com), which suits setups that already run on Pages.

  1. In the Meta App Dashboard, create a Business-type app and add the Instagram product with API setup with Instagram login.
  2. Request the permissions instagram_business_basic and instagram_business_manage_messages. For comment-to-DM, also add instagram_business_manage_comments.
  3. In the dashboard, open Instagram > API setup with Instagram business login and click Generate token next to your account. Tokens generated this way are long-lived and valid for 60 days, per Meta's docs.
  4. Find your Instagram professional account ID (IG_ID) with a request to /me:
curl -i -X GET "https://graph.instagram.com/v26.0/me?fields=user_id,username&access_token=<TOKEN>"

Keep the token and the user_id value. You will use both in the HTTP Request node. If you are building a product for other people's accounts, you would use Business Login for Instagram to collect tokens instead of generating one by hand.

Step 2: Receive Instagram Messages in n8n

You have two ways to receive events. Pick one.

Option A: The Facebook Trigger node

This is the shorter path, because the node handles Meta's verification handshake for you.

  1. Add a Facebook Trigger node and create a Facebook App credential. n8n's credential guide has you generate an app access token from Meta's Graph API Explorer and paste it into the credential.
  2. Paste your Meta App ID into the node and set Object to Instagram.
  3. Under Field Names or IDs, remove the default * wildcard and select Messages (and Comments if you want comment-to-DM).
  4. Click Execute step so the node listens, then in your Meta app's Webhooks settings, paste n8n's webhook URL as the Callback URL and the access token as the Verify token, as n8n's credential docs describe. Verify and save fails if the node is not listening.

Option B: The generic Webhook node

Use this when you want full control over the request, or when the Facebook Trigger does not fit your setup. Meta first sends a GET request with hub.mode, hub.verify_token, and hub.challenge. Your endpoint must check the token and respond with the challenge value.

  1. Add a Webhook node for GET with Respond set to Using 'Respond to Webhook' node.
  2. Add an IF node that checks {{ $json.query['hub.verify_token'] }} against the verify token you chose.
  3. On the true branch, add a Respond to Webhook node that returns {{ $json.query['hub.challenge'] }} as text. n8n's docs note that Text responses default to HTML and that HTML responses are wrapped in an iframe since n8n 1.103.0, so set a Content-Type: text/plain response header and confirm the handshake succeeds in Meta's dashboard.
  4. Add a second Webhook node for POST to receive the actual events.

Whichever option you choose, validate event signatures. Meta signs each notification with an X-Hub-Signature-256 header (an SHA-256 signature generated with your app secret). Meta describes validation as optional but recommended. In n8n, turn on the Webhook node's Raw Body option and compare the header with an HMAC computed from your app secret using the Crypto node.

Use n8n's production webhook URL in Meta, not the test URL. The test URL only works while you are listening in the editor.

Step 3: Subscribe Your Instagram Account to Webhooks

Meta needs to know which fields your app wants and for which account.

In the App Dashboard, add the callback URL and verify token under Webhooks for your Instagram setup, then select the fields: messages for DMs, and comments for comment-to-DM. Then enable notifications for your account with a request to the /subscribed_apps edge:

curl -i -X POST "https://graph.instagram.com/v26.0/<IG_ID>/subscribed_apps?subscribed_fields=messages&access_token=<TOKEN>"

A successful call returns {"success": true}. Meta notes that you cannot select fields per account: every account connected to the app receives every field the app subscribes to.

Step 4: Filter Events and Choose a Reply

Message notifications arrive as an entry array containing a messaging array. The values you need are sender.id (the person's Instagram-scoped ID, or IGSID) and message.text.

Add an IF or Filter node that:

  • drops events where message.is_echo is true, otherwise your own replies come back through the webhook and can start a loop
  • keeps only events that contain message.text

Webhook deliveries are retried with decreasing frequency for up to 36 hours when they fail, and Meta recommends handling duplicates. Store the message ID (message.mid) and skip any you have already processed.

Then choose how to reply:

  • Keyword rules. A Switch node routes on words in the message (price, hours, shipping) to fixed replies. This is deterministic and easy to debug.
  • AI replies. n8n's AI Agent node can generate answers from your instructions. Give it clear boundaries, and send anything it cannot answer to a human.

Keep the data in the payload as your source of truth: the exact field paths depend on whether you used the Facebook Trigger or the Webhook node (the Webhook node nests the request under body), so check the first test execution's output before you write expressions.

Step 5: Send the Reply With the HTTP Request Node

Add an HTTP Request node:

  • Method: POST
  • URL: https://graph.instagram.com/v26.0/<IG_ID>/messages
  • Authentication: a generic Header Auth credential with the name Authorization and the value Bearer <TOKEN>
  • Body: JSON
{
  "recipient": { "id": "{{ $json.body.entry[0].messaging[0].sender.id }}" },
  "message": { "text": "Thanks for your message! Here is the info you asked for." }
}

This matches the request shape in Meta's Send Messages documentation. Message text must be UTF-8 and 1,000 bytes or less. A successful response includes recipient_id and message_id.

Two rules to design around: you can only send after the person has messaged you, and the standard window for most actions is 24 hours from their message. After a first message that follows a Click-to-Direct ad, Meta says the window may last up to 7 days. Where the law requires it, tell people they are talking to an automated service. Meta suggests doing so even where it is not required.

Step 6: Publish the Workflow and Test It

  1. Publish (activate) the workflow so n8n registers the production webhook.
  2. Make sure Meta's callback URL points at the production URL and that the app is Live.
  3. Send a DM to your professional account from a different Instagram account. Meta's docs say app testers need a role on your app and must grant it the required permissions.
  4. Open the Executions tab in n8n. Production runs are not displayed on the canvas, so use Executions to inspect each node's input and output.

If nothing arrives, the usual causes are an app that is not Live, a callback URL that does not return the verification challenge, a missing /subscribed_apps call, or a test URL pasted where the production URL belongs. Webhooks have no history, so an event you miss cannot be replayed.

Step 7: Refresh the Access Token Before It Expires

This is the step that makes a working workflow stop working two months later. Long-lived Instagram tokens last 60 days. Meta lets you refresh one for another 60 days if it is at least 24 hours old and has not expired. A token that goes 60 days without a refresh expires and cannot be refreshed.

Build a small second workflow: a Schedule Trigger (monthly is enough) that calls

GET https://graph.instagram.com/refresh_access_token?grant_type=ig_refresh_token&access_token=<TOKEN>

and then writes the new token somewhere your reply workflow reads it from, such as a database or secrets store. Updating the stored token is the fiddly part, because the HTTP Request credential from Step 5 will not update itself.

How to Build a Comment-to-DM Workflow in n8n

Comment-to-DM ("comment LINK and I will DM you the guide") uses the same pieces with a different trigger and recipient.

  1. Subscribe to the comments field (in the Facebook Trigger, select Comments). Meta states that comments and live_comments notifications require Advanced Access, and that private accounts do not receive comment notifications.
  2. The notification gives you the comment ID (value.id), the commenter's ID and username, the comment text (value.text), and the media ID.
  3. Add an IF node that checks the comment text for your trigger word.
  4. Send the DM with an HTTP Request node to the same /messages endpoint, but set the recipient to the comment instead of a user ID:
{
  "recipient": { "comment_id": "{{ $json.value.id }}" },
  "message": { "text": "Here is the link you asked for." }
}

Meta's private reply rules are strict. You can send only one message to the commenter, within 7 days of the comment. Follow-up messages are possible only if the person replies, and within 24 hours of that reply. The message lands in their inbox if they follow your account, or in Requests if they do not. Private replies to post and Reel comments are limited to 750 calls per hour per account, so a viral Reel can outrun a naive workflow: queue comments instead of dropping them.

Because only one message is allowed, end the first DM with a question or a button so the person can reply and reopen the conversation. Our comment-to-DM workflow page shows how that flow looks in FlowGent without any nodes to maintain.

What Breaks in n8n Instagram Workflows

Most failures are not n8n bugs. They are Meta setup and upkeep:

  • Expired tokens. Sixty days without a refresh and the token is dead (Step 7).
  • App not Live, or only Standard Access. Events stop arriving for accounts you do not own or manage.
  • Duplicate and echo events. Without the Step 4 filter, your workflow can reply to its own messages or process a retried delivery twice.
  • Slow responses. Return a 200 quickly and do heavy work (AI calls) after acknowledging, or Meta will retry.
  • Rate limits. Meta lists 100 calls per second for text sends and 10 per second for audio or video, per Instagram professional account.
  • Window rules. Sending outside the 24-hour window fails. Track the time of the person's last message.
  • Policy and API changes. Meta updates these docs often. The pages we checked for this guide were last revised in September 2026, and the API version in current examples is v26.0.

Be wary of workarounds that skip the official API, such as scraping or logging in with a password. They risk your Instagram account, and they are not what this guide covers. If you are comparing a general AI agent instead of n8n, see our breakdown of OpenClaw's Instagram API setup and limitations.

How Much Does Instagram DM Automation Cost?

With n8n and Meta's API, the costs are your hosting (or an n8n Cloud plan), the time to build and maintain the workflow, and AI model usage if you add a model. You do not buy a seat in an Instagram tool, but you are the one on call when a token expires or a field changes.

With a ready-made tool you pay a subscription instead. FlowGent's pricing starts at $19 per month for the Starter plan, which covers flows such as comment-to-DM and follow-up sequences with no AI. AI agent plans start at $49 per month on the Hobby plan, which includes 2,000 message credits per month. New accounts get a 7-day free trial.

What Is the Best Instagram DM Automation Tool?

It depends on what you value:

You wantGood fit
Custom logic, your own database or CRM wired in, full controln8n, if you have someone to maintain it
Comment-to-DM and keyword replies with no codeA ready-made tool
AI replies that answer questions from your own contentA ready-made AI agent tool
To own the Meta app, review, and token lifecyclen8n or a custom build
To avoid owning the Meta app, review, and token lifecycleA ready-made tool
↔ Scroll sideways

For a side-by-side of the options, read our Instagram DM automation tools roundup, the broader Instagram DM automation guide, or the best Instagram automation tools. If you only need keyword replies, an Instagram auto reply tool covers it without building a workflow. Coming from ManyChat? See our ManyChat alternative page.

Skip the Maintenance With FlowGent

If you came here to get Instagram DMs and comments automated rather than to run a workflow, FlowGent does this without code. You connect your Instagram professional account, build a comment-to-DM flow or turn on an AI agent, and FlowGent handles the Meta connection, webhooks, and token upkeep on its side.

FlowGent connects through Meta's official Instagram API, so the same rules apply: it replies to people who messaged you or commented, and it does not do cold outreach. What you skip is the Meta app setup, App Review, the n8n hosting, and the token refresh workflow.

Rather not maintain an n8n workflow? Start your 7-day free trial and set up your first Instagram automation without code.

Frequently Asked Questions

Can you automate DMs on Instagram?

Yes. For business and creator accounts, Meta's official Instagram API lets an app receive messages by webhook and reply through the /messages endpoint. You can build this yourself in n8n or use a tool that handles the API connection. Automation can only reply to people who messaged you, or send one private reply to a commenter.

Does n8n have an Instagram node?

n8n has a Facebook Trigger node with an Instagram object that can receive messages, comments, mentions, and story insights. For sending DMs, use the HTTP Request node against Meta's /messages endpoint, as shown in Step 5.

Do I need App Review to use n8n with Instagram?

Not if your app only serves Instagram accounts you own or manage, where Standard Access is enough. If it serves accounts you do not own or manage, Meta requires Advanced Access, which means App Review and Business Verification. Meta also says the app must be Live to receive notifications for app users.

Can n8n send the first DM to someone who never messaged me?

No. Meta's documentation says your app can message a person only after they have messaged your professional account. The one exception is a single private reply to someone who commented, within 7 days of the comment.

Why did my n8n Instagram workflow stop working?

The most common cause is an expired access token: long-lived tokens last 60 days and must be refreshed before they expire. Other causes are an app that is no longer Live, a changed or untested production webhook URL, missing webhook subscriptions, or replying outside the 24-hour window.

Is automating Instagram DMs with n8n allowed?

Yes, when you use Meta's official API, stay within the messaging window and private reply rules, and disclose automated chats where the law requires it. Scraping or password-based logins are not part of the official API and put your account at risk.

Can I customize AI responses inside n8n?

Yes. Add an AI Agent node or a model node such as OpenAI after the filter step, give it instructions and the incoming message, and pass its output into the HTTP Request body. Keep the 1,000-byte text limit in mind, and route questions it cannot answer to a human.

Can I automate Instagram posts using AI?

n8n can also publish content to Instagram through Meta's API and generate captions with an AI model. That is a separate workflow with different permissions from DM automation, and this guide covers messaging only.

Is there a simpler way than building this in n8n?

Yes. A ready-made tool handles the Meta app, webhooks, and tokens for you. FlowGent offers comment-to-DM flows and an AI agent for Instagram with a 7-day free trial, and our Instagram DM automation tools comparison shows how the options differ.

Sources checked in October 2026: Meta's Instagram Platform documentation (Send Messages, Instagram Webhooks setup and examples, Private Replies, Get Started, Business Login, Overview rate limits) and n8n's documentation for the Facebook Trigger node, Facebook App credentials, Webhook node, and Respond to Webhook node. Meta and n8n update these pages often, so treat them as the source of truth.

J
Written by Jan van Musscher

Founder @ FlowGent