AI驱动的Instagram评论自动回复
这是一个Social Media, Multimodal AI领域的自动化工作流,包含 27 个节点。主要使用 If, Code, Merge, Redis, SplitOut 等节点。 使用OpenAI和Redis跟踪自动化Instagram评论回复
- •Redis 服务器连接信息
- •可能需要目标 API 的认证凭证
- •OpenAI API Key
{
"id": "nqmmC4Z0cU9UFtVk",
"meta": {
"instanceId": "dd69efaf8212c74ad206700d104739d3329588a6f3f8381a46a481f34c9cc281",
"templateCredsSetupCompleted": true
},
"name": "AI 驱动的 Instagram 评论自动回复",
"tags": [],
"nodes": [
{
"id": "5683fa49-d9bf-48ea-b449-32b6b7ea8c9a",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2064,
-1024
],
"parameters": {
"color": 4,
"width": 386.9707535069169,
"height": 343.8950932756325,
"content": "## 🚀 工作流开始"
},
"typeVersion": 1
},
{
"id": "c4e05953-bd04-4c02-a615-634ba52ecd8f",
"name": "计划触发器",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-2784,
-304
],
"parameters": {
"rule": {
"interval": [
{}
]
}
},
"typeVersion": 1
},
{
"id": "7ceb7a5c-90bd-4cd3-8648-c85f590f611a",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2864,
-640
],
"parameters": {
"color": 5,
"width": 252,
"height": 490,
"content": "## ⏰ 触发器"
},
"typeVersion": 1
},
{
"id": "e354447a-b2ba-47cf-a0d9-7184d9364440",
"name": "获取最近帖子",
"type": "n8n-nodes-base.httpRequest",
"position": [
-2560,
-304
],
"parameters": {
"url": "https://graph.instagram.com/me/media",
"method": "POST",
"options": {},
"sendQuery": true,
"authentication": "predefinedCredentialType",
"queryParameters": {
"parameters": [
{
"name": "fields",
"value": "id,caption,media_type,media_url,timestamp"
},
{
"name": "limit",
"value": "10"
}
]
},
"nodeCredentialType": "instagramGraphApi"
},
"typeVersion": 4.1
},
{
"id": "8775e252-f86d-407d-ac28-4dc5bd1f7a6f",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2592,
-640
],
"parameters": {
"color": 6,
"width": 369,
"height": 485,
"content": "## 📸 获取帖子"
},
"typeVersion": 1
},
{
"id": "482867b5-c987-4189-ac71-a23fb13990b1",
"name": "拆分帖子",
"type": "n8n-nodes-base.splitOut",
"position": [
-2336,
-304
],
"parameters": {
"options": {},
"fieldToSplitOut": "data"
},
"typeVersion": 1
},
{
"id": "c7f4585f-5ca3-47d1-8488-9a6f42c14c33",
"name": "获取评论",
"type": "n8n-nodes-base.httpRequest",
"position": [
-2112,
-232
],
"parameters": {
"url": "=https://graph.instagram.com/{{ $json.id }}/comments",
"options": {},
"sendQuery": true,
"authentication": "predefinedCredentialType",
"queryParameters": {
"parameters": [
{
"name": "fields",
"value": "id,text,username,timestamp,like_count"
}
]
},
"nodeCredentialType": "instagramGraphApi"
},
"typeVersion": 4.1
},
{
"id": "04491271-b169-4d02-bec3-923b2d3a5b0d",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2160,
-640
],
"parameters": {
"color": 6,
"width": 225,
"height": 533,
"content": "## 💬 获取评论"
},
"typeVersion": 1
},
{
"id": "70bdb008-0d55-4b4f-9c35-4927fe944575",
"name": "拆分评论",
"type": "n8n-nodes-base.splitOut",
"position": [
-1888,
-232
],
"parameters": {
"options": {},
"fieldToSplitOut": "data"
},
"typeVersion": 1
},
{
"id": "60f13b8f-2627-4cfe-a0ab-2d1f73abb34f",
"name": "添加上下文",
"type": "n8n-nodes-base.merge",
"position": [
-1664,
-304
],
"parameters": {
"mode": "combine",
"options": {},
"combinationMode": "multiplex"
},
"typeVersion": 2.1
},
{
"id": "bb387325-4f62-4663-8ab3-b76827c9fe50",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1904,
-624
],
"parameters": {
"color": 7,
"width": 385,
"height": 508,
"content": "## 🔗 合并数据"
},
"typeVersion": 1
},
{
"id": "d7a6591d-f4f2-40b0-8d4e-fb7bdfd12e35",
"name": "检查是否已回复",
"type": "n8n-nodes-base.redis",
"position": [
-1440,
-304
],
"parameters": {
"key": "=replied_{{ $json.id }}",
"options": {},
"operation": "get"
},
"credentials": {
"redis": {
"id": "BjwucG92kWn0N0wC",
"name": "Redis account - test"
}
},
"typeVersion": 1
},
{
"id": "cf422c6c-ee36-4df6-be1b-307d788ed305",
"name": "便签5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1504,
-640
],
"parameters": {
"color": 3,
"width": 209,
"height": 506,
"content": "## ✅ 重复检查"
},
"typeVersion": 1
},
{
"id": "b1c8ba7e-85f2-4a91-8aaa-2457e520fd5f",
"name": "尚未回复?",
"type": "n8n-nodes-base.if",
"position": [
-1216,
-304
],
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $json.reply }}",
"operation": "isEmpty"
}
]
}
},
"typeVersion": 1
},
{
"id": "b81c50e5-50b2-413c-8cf3-b2090d5785ed",
"name": "便签 6",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1264,
-640
],
"parameters": {
"color": 3,
"width": 209,
"height": 502,
"content": "## 🚦 过滤器"
},
"typeVersion": 1
},
{
"id": "131dae48-de89-4580-8008-d0f922e7242a",
"name": "垃圾信息过滤器",
"type": "n8n-nodes-base.code",
"position": [
-992,
-304
],
"parameters": {
"jsCode": "// Spam detection keywords\nconst spamKeywords = ['buy now', 'click here', 'dm me', 'check bio', 'follow for follow', 'f4f', 'l4l', 'spam', 'bot'];\n\nconst commentText = $input.item.json.text.toLowerCase();\n\n// Check for spam\nconst isSpam = spamKeywords.some(keyword => commentText.includes(keyword));\n\n// Check if comment is too short (likely not genuine)\nconst isTooShort = commentText.length < 3;\n\n// Check if comment is just emojis\nconst isOnlyEmojis = /^[\\p{Emoji}\\s]+$/u.test(commentText);\n\nreturn {\n json: {\n ...($input.item.json),\n isSpam: isSpam,\n isTooShort: isTooShort,\n isOnlyEmojis: isOnlyEmojis,\n shouldReply: !isSpam && !isTooShort && !isOnlyEmojis\n }\n};"
},
"typeVersion": 2
},
{
"id": "fc683c62-62ae-4e5e-9239-1e4e41ef5e97",
"name": "便签7",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1024,
-640
],
"parameters": {
"color": 3,
"width": 209,
"height": 500,
"content": "## 🛡️ 垃圾信息检测"
},
"typeVersion": 1
},
{
"id": "26e242b0-222f-40de-99a3-fa93cd708fca",
"name": "应该回复?",
"type": "n8n-nodes-base.if",
"position": [
-768,
-304
],
"parameters": {
"conditions": {
"boolean": [
{
"value1": "={{ $json.shouldReply }}",
"value2": true
}
]
}
},
"typeVersion": 1
},
{
"id": "8030a81c-c057-40fb-a8cc-885a3d18dd31",
"name": "生成 AI 回复",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
-544,
-304
],
"parameters": {
"resource": "chat"
},
"credentials": {
"openAiApi": {
"id": "CDQ16eImh6D4tY15",
"name": "OpenAi account 2 - test"
}
},
"typeVersion": 1.3
},
{
"id": "45b050d2-f682-443d-a2ff-38cf0dca8b2a",
"name": "便签8",
"type": "n8n-nodes-base.stickyNote",
"position": [
-800,
-640
],
"parameters": {
"color": 2,
"width": 369,
"height": 486,
"content": "## 🤖 AI 生成"
},
"typeVersion": 1
},
{
"id": "c1873eb7-005f-4557-94ad-3a1d9f0c536c",
"name": "发布回复",
"type": "n8n-nodes-base.httpRequest",
"position": [
-320,
-304
],
"parameters": {
"url": "=https://graph.instagram.com/{{ $json.id }}/replies",
"method": "POST",
"options": {},
"sendBody": true,
"authentication": "predefinedCredentialType",
"bodyParameters": {
"parameters": [
{
"name": "message",
"value": "={{ $json.message.content }}"
}
]
},
"nodeCredentialType": "instagramGraphApi"
},
"typeVersion": 4.1
},
{
"id": "d325002a-7fe8-4af6-8792-7c57982d0a9f",
"name": "便签9",
"type": "n8n-nodes-base.stickyNote",
"position": [
-384,
-656
],
"parameters": {
"color": 6,
"width": 209,
"height": 516,
"content": "## 📤 发布回复"
},
"typeVersion": 1
},
{
"id": "dea7eafb-d657-42bf-b80c-53e52bc5892b",
"name": "标记为已回复",
"type": "n8n-nodes-base.redis",
"position": [
-96,
-304
],
"parameters": {
"key": "=replied_{{ $json.id }}",
"ttl": 2592000,
"value": "=true",
"expire": true,
"operation": "set"
},
"credentials": {
"redis": {
"id": "BjwucG92kWn0N0wC",
"name": "Redis account - test"
}
},
"typeVersion": 1
},
{
"id": "522eba11-6ac2-4d8f-b768-0f19fdee2319",
"name": "便签 10",
"type": "n8n-nodes-base.stickyNote",
"position": [
-144,
-656
],
"parameters": {
"color": 3,
"width": 225,
"height": 532,
"content": "## 💾 保存状态"
},
"typeVersion": 1
},
{
"id": "04242788-8791-4460-ad1a-c68de0cbecd8",
"name": "记录回复",
"type": "n8n-nodes-base.redis",
"position": [
128,
-304
],
"parameters": {
"list": "instagram_replies_log",
"operation": "push",
"messageData": "={{ JSON.stringify({\n commentId: $json.id,\n username: $json.username,\n comment: $json.text,\n reply: $json.message.content,\n postId: $json.postId,\n timestamp: new Date().toISOString()\n}) }}"
},
"credentials": {
"redis": {
"id": "BjwucG92kWn0N0wC",
"name": "Redis account - test"
}
},
"typeVersion": 1
},
{
"id": "8726c188-7840-4f50-8d48-5fc21f0a39b9",
"name": "便签11",
"type": "n8n-nodes-base.stickyNote",
"position": [
96,
-656
],
"parameters": {
"color": 4,
"width": 225,
"height": 526,
"content": "## 📊 分析"
},
"typeVersion": 1
},
{
"id": "aa73aa12-3b91-4812-83d9-d7e70139af17",
"name": "便签 13",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2592,
-1216
],
"parameters": {
"width": 440,
"height": 500,
"content": "## ⚙️ 所需设置"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "9c992c9f-45d1-4e53-bdb9-af3ebab17fff",
"connections": {
"Post Reply": {
"main": [
[
{
"node": "Mark As Replied",
"type": "main",
"index": 0
}
]
]
},
"Spam Filter": {
"main": [
[
{
"node": "Should Reply?",
"type": "main",
"index": 0
}
]
]
},
"Split Posts": {
"main": [
[
{
"node": "Get Comments",
"type": "main",
"index": 0
},
{
"node": "Add Post Context",
"type": "main",
"index": 0
}
]
]
},
"Get Comments": {
"main": [
[
{
"node": "Split Comments",
"type": "main",
"index": 0
}
]
]
},
"Should Reply?": {
"main": [
[
{
"node": "Generate AI Reply",
"type": "main",
"index": 0
}
]
]
},
"Split Comments": {
"main": [
[
{
"node": "Add Post Context",
"type": "main",
"index": 1
}
]
]
},
"Mark As Replied": {
"main": [
[
{
"node": "Log Reply",
"type": "main",
"index": 0
}
]
]
},
"Add Post Context": {
"main": [
[
{
"node": "Check If Replied",
"type": "main",
"index": 0
}
]
]
},
"Check If Replied": {
"main": [
[
{
"node": "Not Replied Yet?",
"type": "main",
"index": 0
}
]
]
},
"Get Recent Posts": {
"main": [
[
{
"node": "Split Posts",
"type": "main",
"index": 0
}
]
]
},
"Not Replied Yet?": {
"main": [
[
{
"node": "Spam Filter",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "Get Recent Posts",
"type": "main",
"index": 0
}
]
]
},
"Generate AI Reply": {
"main": [
[
{
"node": "Post Reply",
"type": "main",
"index": 0
}
]
]
}
}
}如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 社交媒体, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
Oneclick AI Squad
@oneclick-aiThe AI Squad Initiative is a pioneering effort to build, automate and scale AI-powered workflows using n8n.io. Our mission is to help individuals and businesses integrate AI agents seamlessly into their daily operations from automating tasks and enhancing productivity to creating innovative, intelligent solutions. We design modular, reusable AI workflow templates that empower creators, developers and teams to supercharge their automation with minimal effort and maximum impact.
分享此工作流