AutomationFlowsSocial Media › Send Instagram Auto Dms to Post Commenters Using Meta Graph API

Send Instagram Auto Dms to Post Commenters Using Meta Graph API

BySalman Mehboob @salmanmehboob on n8n.io

Automate the most popular growth hack on Instagram: "Comment 'DM' to get the link!"

Webhook trigger★★★★☆ complexity9 nodesHTTP Request
Social Media Trigger: Webhook Nodes: 9 Complexity: ★★★★☆ Added:

This workflow corresponds to n8n.io template #15206 — we link there as the canonical source.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "nodes": [
    {
      "id": "a9845bc8-c7fc-4e17-91c2-ca008222a59f",
      "name": "Trigger on Instagram Comment",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1312,
        480
      ],
      "parameters": {
        "path": "ecc03c31-5ab4-4261-84fb-c774e06fd579",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2.1
    },
    {
      "id": "26c4519f-c884-4d38-aa24-860610c3a47b",
      "name": "Match Comment Text",
      "type": "n8n-nodes-base.filter",
      "position": [
        -848,
        464
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "3fc908dc-bef7-4a0e-875d-90e7a48f3fc8",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.body.entry[0].changes[0].value.text }}",
              "rightValue": "DM"
            },
            {
              "id": "811261e0-c0df-4503-97a8-41ce4ca7ceaa",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.body.entry[0].changes[0].value.text }}",
              "rightValue": "dm"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "ac153128-12c5-4dd6-a2e6-5f37e801dff4",
      "name": "Data",
      "type": "n8n-nodes-base.set",
      "position": [
        -640,
        464
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a9c31aa4-afde-4532-be16-4650d907e0da",
              "name": "comment_id",
              "type": "string",
              "value": "={{ $json.body.entry[0].changes[0].value.id }}"
            },
            {
              "id": "2cf8ff04-4305-46be-b745-82f59d7570c9",
              "name": "my_ig_id",
              "type": "string",
              "value": "={{ $json.body.entry[0].id }}"
            },
            {
              "id": "48481d57-2485-4c87-aa1b-7d5780fb8d3d",
              "name": "message",
              "type": "string",
              "value": "Your-Message-Here"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "fdd71ec5-f058-4c03-82cd-a39f686f1873",
      "name": "Send DM",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -400,
        464
      ],
      "parameters": {
        "url": "=https://graph.facebook.com/v25.0/{{ $json.my_ig_id }}/messages",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"recipient\": {\n    \"comment_id\": \"{{ $json.comment_id }}\"\n  },\n  \"message\": {\n    \"text\": \"{{ $json.message }}\"\n  }\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth"
      },
      "credentials": {
        "httpBasicAuth": {
          "name": "<your credential>"
        },
        "httpQueryAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "a65b590e-2259-4aaa-b4b1-3035eef22786",
      "name": "Match Post ID",
      "type": "n8n-nodes-base.if",
      "position": [
        -1104,
        480
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "5bad8129-a374-4957-9762-5413b48850c3",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.body.entry[0].id }}",
              "rightValue": "Your-Instagram-Post-ID"
            },
            {
              "id": "327ce172-bd11-4a03-9c5a-60bd5c569eac",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json.body.entry[0].changes[0].value.from.id }}",
              "rightValue": "Your-Instagram-Account-ID"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "21bc1730-3c77-469f-b7e8-916f45e696a2",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1904,
        288
      ],
      "parameters": {
        "width": 512,
        "height": 512,
        "content": "## \ud83d\ude80 Instagram Auto-DM Lead Magnet\n\n### How it works\n\n1. Listens for live comment payloads via the Meta/Instagram Webhook.\n2. Verifies the comment is on a specific promotional post (and ignores your own replies).\n3. Checks if the commenter typed the exact trigger keyword.\n4. Automatically sends a direct message to the user with the requested document or link.\n\n### \u26a0\ufe0f CRITICAL SETUP STEPS \u26a0\ufe0f\n\n- [ ] **Webhook:** Connect your Meta Developer App and subscribe to Instagram `comments`.\n- [ ] **Target Post:** Open the `Match Post ID` node. Paste your **Instagram Post ID** and your **Instagram Account ID** to prevent self-looping.\n- [ ] **Trigger Word:** Open the `Match Comment Text` node. Set your exact trigger words (e.g., \"DM\", \"Send it\").\n- [ ] **The Message:** Open the `Data` node. Replace \"Your-Message-Here\" with your custom message and link!\n- [ ] **Auth:** Add your Graph API credentials in the `Send DM` node."
      },
      "typeVersion": 1
    },
    {
      "id": "731cf544-0075-4914-bbe4-b9bb1911c438",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1376,
        320
      ],
      "parameters": {
        "color": 7,
        "width": 208,
        "height": 304,
        "content": "## 1. \ud83d\udce5 Receive Comment\n\nListens for comment payloads pushed from the Meta Webhook."
      },
      "typeVersion": 1
    },
    {
      "id": "cdc60ccf-3140-45e5-af3d-5b15474d53df",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1152,
        304
      ],
      "parameters": {
        "color": 7,
        "width": 448,
        "height": 352,
        "content": "## 2. \ud83c\udfaf Filter & Validate\n\n\u26a0\ufe0f **ACTION REQUIRED:**\n1. Open **Match Post ID** to add your Post ID & Account ID.\n2. Open **Match Comment Text** to define your trigger keyword."
      },
      "typeVersion": 1
    },
    {
      "id": "01163d2a-6321-4a2d-a893-82bce72cdd75",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -672,
        304
      ],
      "parameters": {
        "color": 7,
        "width": 432,
        "height": 352,
        "content": "## 3. \ud83d\udcac Prepare & Send DM\n\n\u26a0\ufe0f **ACTION REQUIRED:**\nOpen the **Data** node to type the custom message and link you want to send to your followers! (The API handles the rest)."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Data": {
      "main": [
        [
          {
            "node": "Send DM",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Match Post ID": {
      "main": [
        [
          {
            "node": "Match Comment Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Match Comment Text": {
      "main": [
        [
          {
            "node": "Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger on Instagram Comment": {
      "main": [
        [
          {
            "node": "Match Post ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Automate the most popular growth hack on Instagram: "Comment 'DM' to get the link!"

Source: https://n8n.io/workflows/15206/ — original creator credit. Request a take-down →

More Social Media workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Social Media

Automate your entire Instagram carousel publishing pipeline from a single webhook call. This workflow receives a product collection payload, loops through each slide image, uploads every asset via Upl

HTTP Request, N8N Nodes Uploadtourl, Slack
Social Media

This workflow leverages n8n to automate LinkedIn content creation from start to finish. Upload an image and quote through a web form, and get a professionally designed post with AI-generated captions,

HTTP Request, LinkedIn, Edit Image
Social Media

📦 Automated Instagram Product Drop via uploadtourl

HTTP Request, Airtable, Slack +1
Social Media

Automate LinkedIn profile enrichment and transform raw URLs into beautifully formatted candidate profile pages using n8n and the Apollo.io API 🔍. This workflow receives a LinkedIn URL via webhook, fet

HTTP Request
Social Media

This workflow contains a webhook that receives updates from Reply.io when one of your connections sends you a message via either Email or LinkedIn. The workflow also includes utility nodes to create t

HTTP Request, Telegram