8
n8n 中文网amn8n.com

使用Google表格和CRM跟踪自动化Instagram评论回复

中级

这是一个Social Media领域的自动化工作流,包含 11 个节点。主要使用 If, Switch, Webhook, HttpRequest, GoogleSheets 等节点。 使用Google表格和CRM跟踪自动化Instagram评论回复

前置要求
  • HTTP Webhook 端点(n8n 会自动生成)
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "40e2ddc17723de14c7d0537f9006dd246a3f4df33df6ca7f746ccb612d5f27b9"
  },
  "nodes": [
    {
      "id": "b6b07e6a-5605-4991-bc5d-bd108ee503e5",
      "name": "Instagram 更新",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -100,
        900
      ],
      "webhookId": "eae5550b-f362-46d8-9b51-79aaaefd8d7b",
      "parameters": {
        "path": "instagram",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2
    },
    {
      "id": "ac3030e7-adda-4432-9846-fc214bfdda4a",
      "name": "发送评论消息",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        860,
        900
      ],
      "parameters": {
        "url": "=https://graph.instagram.com/v23.0/{{ $('Check if update is of comment?').item.json.body.entry[0].id }}/messages",
        "method": "POST",
        "options": {
          "redirect": {
            "redirect": {}
          }
        },
        "jsonBody": "={\n  \"recipient\": {\n    \"id\": \"{{ $('Check if update is of comment?').item.json.body.entry[0].changes[0].value.from.id }}\"\n  },\n  \"message\": {\n    \"text\": \"{{ $json.Message }}\"\n  }\n} ",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "0SD8qdsV8SjyC0bo",
          "name": "IG Access Token"
        }
      },
      "retryOnFail": false,
      "typeVersion": 4.2,
      "waitBetweenTries": 3000
    },
    {
      "id": "800da6b1-b7e4-4939-8d3c-5af3a55fffca",
      "name": "评论列表",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        640,
        900
      ],
      "parameters": {
        "options": {
          "returnFirstMatch": true
        },
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json.body.entry[0].changes[0].value.text.split()[0].toLowerCase() }}",
              "lookupColumn": "Comment"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1tQwit0eRrR5N-EoLX4dyXurjEDtthsr97Vny9kaIRdA/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1tQwit0eRrR5N-EoLX4dyXurjEDtthsr97Vny9kaIRdA",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1tQwit0eRrR5N-EoLX4dyXurjEDtthsr97Vny9kaIRdA/edit?usp=drivesdk",
          "cachedResultName": "IG Comment Reply"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "9NL9w5d9bKz7xt16",
          "name": "Akash Google Sheet Account"
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.6,
      "waitBetweenTries": 3000
    },
    {
      "id": "c7877403-33f3-4e3c-a490-6a4e6844ecf9",
      "name": "获取验证",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -100,
        600
      ],
      "webhookId": "eae5550b-f362-46d8-9b51-79aaaefd8d7b",
      "parameters": {
        "path": "instagram",
        "options": {},
        "responseMode": "responseNode"
      },
      "typeVersion": 2
    },
    {
      "id": "5cddd607-4639-48eb-922a-a743736de52b",
      "name": "响应验证消息",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        120,
        600
      ],
      "parameters": {
        "options": {},
        "respondWith": "text",
        "responseBody": "={{ $json.query[\"hub.challenge\"] }}"
      },
      "typeVersion": 1.4
    },
    {
      "id": "c87053c2-8508-4199-9c87-49d19b3b9cb1",
      "name": "在表格中添加互动记录(CRM)",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1120,
        900
      ],
      "parameters": {
        "columns": {
          "value": {
            "Note": "={{ $json?.error.message }}",
            "Time": "={{ $('Check if update is of comment?').item.json.body.entry[0].time }}",
            "User Id": "={{ $('Check if update is of comment?').item.json.body.entry[0].changes[0].value.from.id }}",
            "Username": "={{ $('Check if update is of comment?').item.json.body.entry[0].changes[0].value.from.username }}"
          },
          "schema": [
            {
              "id": "Time",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "User Id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "User Id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Username",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Username",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Note",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Note",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "useAppend": true
        },
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 76673878,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1tQwit0eRrR5N-EoLX4dyXurjEDtthsr97Vny9kaIRdA/edit#gid=76673878",
          "cachedResultName": "Interation List"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1tQwit0eRrR5N-EoLX4dyXurjEDtthsr97Vny9kaIRdA",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1tQwit0eRrR5N-EoLX4dyXurjEDtthsr97Vny9kaIRdA/edit?usp=drivesdk",
          "cachedResultName": "IG Comment Reply"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "9NL9w5d9bKz7xt16",
          "name": "Akash Google Sheet Account"
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.6,
      "waitBetweenTries": 3000
    },
    {
      "id": "45da4261-9d50-43e7-b76a-7abc49bb05c6",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        500
      ],
      "parameters": {
        "color": 3,
        "width": 520,
        "height": 280,
        "content": "## 第一部分"
      },
      "typeVersion": 1
    },
    {
      "id": "466854cc-015e-45e1-9df9-719b1c85f756",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        820
      ],
      "parameters": {
        "color": 5,
        "width": 1480,
        "height": 300,
        "content": "## 第二部分"
      },
      "typeVersion": 1
    },
    {
      "id": "96d3b6a2-7c39-4df1-8320-c9112c9ce91b",
      "name": "检查更新是否为评论?",
      "type": "n8n-nodes-base.switch",
      "position": [
        120,
        900
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Comment",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "46743704-1feb-42f4-ad31-586c7867bb8f",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.body.entry[0].changes[0].field }}",
                    "rightValue": "comments"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "5cf8ac8a-5158-488b-9e75-3e1fcda4a96f",
      "name": "如果是其他用户的评论",
      "type": "n8n-nodes-base.if",
      "position": [
        380,
        900
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "7ab85299-8fa9-4538-ab1f-a513e1f1fcc3",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json.body.entry[0].id }}",
              "rightValue": "={{ $json.body.entry[0].changes[0].value.from.id }}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "63188fa2-cdbe-4434-8950-0397651f3681",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1180,
        -160
      ],
      "parameters": {
        "color": 4,
        "width": 2600,
        "height": 2020,
        "content": "## 🎯 概述"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {
    "Insta Update": [
      {
        "body": {
          "entry": [
            {
              "id": "17841475948546607",
              "time": 1753014148,
              "changes": [
                {
                  "field": "comments",
                  "value": {
                    "id": "18017840360549208",
                    "from": {
                      "id": "711657468441200",
                      "username": "akashkankariya25"
                    },
                    "text": "auto",
                    "media": {
                      "id": "18068356241122012",
                      "media_product_type": "FEED"
                    }
                  }
                }
              ]
            }
          ],
          "object": "instagram"
        },
        "query": {},
        "params": {},
        "headers": {
          "host": "127.0.0.1:8443",
          "accept": "*/*",
          "connection": "upgrade",
          "user-agent": "Webhooks/1.0 (https://fb.me/webhooks)",
          "content-type": "application/json",
          "content-length": "308",
          "x-hub-signature": "sha1=6982132362cedd6e84a1da29d13ed2e80a559671",
          "x-hub-signature-256": "sha256=e51ccecc586e1e26646d04214cc68c5f9113da8afb9d06a98514b95ea7c502dc"
        },
        "webhookUrl": "https://n8n.algowiz.in:8443/webhook/instagram",
        "executionMode": "production"
      }
    ],
    "Get Verification": [
      {
        "body": {},
        "query": {
          "hub.mode": "subscribe",
          "hub.challenge": "1283172776",
          "hub.verify_token": "test"
        },
        "params": {},
        "headers": {
          "host": "127.0.0.1:8443",
          "accept": "*/*",
          "connection": "upgrade",
          "user-agent": "facebookplatform/1.0 (+http://developers.facebook.com)",
          "accept-encoding": "deflate, gzip"
        },
        "webhookUrl": "https://n8n.algowiz.in:8443/webhook/instagram",
        "executionMode": "production"
      }
    ]
  },
  "connections": {
    "Comment List": {
      "main": [
        [
          {
            "node": "Send Message for Comment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insta Update": {
      "main": [
        [
          {
            "node": "Check if update is of comment?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Verification": {
      "main": [
        [
          {
            "node": "Respond to Verfication Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Comment if of other user": {
      "main": [
        [
          {
            "node": "Comment List",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Message for Comment": {
      "main": [
        [
          {
            "node": "Add Interation in Sheet (CRM)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if update is of comment?": {
      "main": [
        [
          {
            "node": "Comment if of other user",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 社交媒体

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量11
分类1
节点类型7
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Akash Kankariya

Akash Kankariya

@akash25

I'm a developer with 5 years of experience in Python and Node.js. Over the past year, I've been building workflows to streamline operations for my team. I have also developed RAG chatbots, AI agents, and WhatsApp automation. If you need any help with N8N workflows, let's connect over a call and solve it together!

外部链接
在 n8n.io 查看

分享此工作流