8
n8n 中文网amn8n.com

Facebook评论审核器

高级

这是一个AI Chatbot, Multimodal AI领域的自动化工作流,包含 23 个节点。主要使用 If, Code, Merge, Notion, HttpRequest 等节点。 使用Notion和Gemini的Facebook评论AI审核器

前置要求
  • Notion API Key
  • 可能需要目标 API 的认证凭证
  • Facebook Graph API 凭证
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "oWTmtu5Euv0y5n13",
  "meta": {
    "instanceId": "7f1a0694161455be3a7e71f1e0dea04908b0376a1a81e3a0c1e5ac879d48f83a"
  },
  "name": "Facebook 评论审核器",
  "tags": [],
  "nodes": [
    {
      "id": "01df470c-f637-4065-af99-291dc56f4796",
      "name": "AI 代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1312,
        224
      ],
      "parameters": {
        "text": "=You are a helpful, friendly, and empathetic customer support agent for [COMPANY_NAME], a [COMPANY_TYPE] company in [COUNTRY].  \n\nYour job is to read the customer's comment and reply in [TARGET_LANGUAGE] in a natural, unisex, and humanized way that feels warm and personal.  \n\nGuidelines for your replies:\n- Always reply as if you are a [NATIONALITY] person talking naturally.  \n- Keep the tone friendly, respectful, and caring.  \n- Use short, conversational sentences (don't sound like a machine).  \n- Mention [COMPANY_NAME] naturally when relevant.  \n- Always write in a *unisex style*.  \n- Match the *tone of the customer's comment*.  \n- Never use [FORBIDDEN_EXPRESSIONS]. Always use [PREFERRED_EXPRESSIONS] instead. \n- The word \"[SPECIFIC_FORBIDDEN_WORD]\" is strictly forbidden. Never use it in replies. Always use \"[PREFERRED_ALTERNATIVE]\" or another [TARGET_LANGUAGE] greeting instead.\n\n Whenever the customer asks about products, prices, or descriptions, use the Knowledge Base \"\" {{ $('KB Arrange').item.json.knowledgeContext }}\"\" to look up the correct information **before replying**.  \n If the Knowledge Base does not contain the answer, reply politely and naturally without inventing details.  \n\nHere is the customer's comment:  \n\"\"{{ \n  $('Last Post Fetcher').first().json.data\n    .sort((a, b) => new Date(b.created_time) - new Date(a.created_time))[0].message || \"\"\n}}\n\"\"  \n\nNow generate a reply in [TARGET_LANGUAGE] only.\n",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2.1
    },
    {
      "id": "6c83bfa2-e7b6-4846-97c5-c21f62a6f56e",
      "name": "AI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1232,
        464
      ],
      "parameters": {
        "options": {
          "temperature": 0.2
        },
        "modelName": "[AI_MODEL_NAME]"
      },
      "typeVersion": 1
    },
    {
      "id": "189eb862-ad36-4ea4-992e-e5111a0767f3",
      "name": "定时触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -656,
        224
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "seconds",
              "secondsInterval": 10
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "27f33e5c-06ac-44f0-a6e0-44c6f376ba82",
      "name": "合并",
      "type": "n8n-nodes-base.merge",
      "position": [
        336,
        224
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "7a18fcb5-df50-46f6-a8aa-de653b070786",
      "name": "知识库",
      "type": "n8n-nodes-base.notion",
      "position": [
        80,
        368
      ],
      "parameters": {
        "options": {},
        "resource": "databasePage",
        "operation": "getAll",
        "returnAll": true,
        "databaseId": {
          "__rl": true,
          "mode": "list",
          "value": "[KNOWLEDGE_BASE_DATABASE_ID]",
          "cachedResultUrl": "[KNOWLEDGE_BASE_URL]",
          "cachedResultName": "Knowledge Base"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "829dd83a-58f8-44cd-a961-a1a0e2bd5c6e",
      "name": "最新帖子获取器",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -240,
        224
      ],
      "parameters": {
        "url": "=https://graph.facebook.com/v21.0/{{$json[\"data\"][0].id}}/comments?access_token=[FACEBOOK_ACCESS_TOKEN]",
        "options": {},
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "facebookGraphApi"
      },
      "typeVersion": 4.2
    },
    {
      "id": "eb84d700-a32e-43a3-b4a9-781274635bab",
      "name": "评论ID检查器",
      "type": "n8n-nodes-base.notion",
      "position": [
        80,
        96
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "key": "Comment ID|rich_text",
              "condition": "equals",
              "richTextValue": "={{    $('Last Post Fetcher').first().json.data     .sort((a, b) => new Date(b.created_time) - new Date(a.created_time))[0].id  }}"
            }
          ]
        },
        "options": {},
        "resource": "databasePage",
        "operation": "getAll",
        "databaseId": {
          "__rl": true,
          "mode": "list",
          "value": "[PROCESSED_COMMENTS_DATABASE_ID]",
          "cachedResultUrl": "[PROCESSED_COMMENTS_DATABASE_URL]",
          "cachedResultName": "Processed Facebook Comments"
        },
        "filterType": "manual"
      },
      "typeVersion": 2.2,
      "alwaysOutputData": true
    },
    {
      "id": "b81bc886-a42c-4c7d-9e99-844340dc205d",
      "name": "知识库整理",
      "type": "n8n-nodes-base.code",
      "position": [
        544,
        224
      ],
      "parameters": {
        "jsCode": "// Get the Knowledge Base data from the Notion node\nconst kbPages = $input.all().map(item => item.json);\n\n// Helper function to extract text from Notion properties\nfunction extractText(property) {\n  if (!property) return '';\n  \n  // Handle rich_text properties\n  if (property.rich_text && property.rich_text.length > 0) {\n    return property.rich_text[0].plain_text || '';\n  }\n  \n  // Handle title properties\n  if (property.title && property.title.length > 0) {\n    return property.title[0].plain_text || '';\n  }\n  \n  // Handle select properties\n  if (property.select) {\n    return property.select.name || '';\n  }\n  \n  // Handle number properties\n  if (property.number) {\n    return property.number.toString();\n  }\n  \n  return '';\n}\n\n// Create a linear array of knowledge base entries\nconst knowledgeArray = kbPages.map(page => {\n  const properties = page.properties || {};\n  \n  // Extract information based on your actual Notion properties\n  const productName = page.property_products || '';\n  const price = page.property_prices || '';\n  const description = page.property_description || '';\n  const name = page.name || '';\n  \n  // Create a formatted knowledge entry\n  const knowledgeEntry = {\n    name: name,\n    product: productName,\n    price: price,\n    description: description,\n    // Create a searchable text string\n    searchableText: [name, productName, price, description]\n      .filter(Boolean)\n      .join(' | ')\n  };\n  \n  return knowledgeEntry;\n}).filter(entry => entry.name || entry.product); // Only include entries with names or products\n\n// Create a simple string array for easy searching\nconst knowledgeStrings = knowledgeArray.map(entry => \n  `NAME: ${entry.name || 'N/A'}` +\n  (entry.product ? ` | PRODUCT: ${entry.product}` : '') +\n  (entry.price ? ` | PRICE: ${entry.price}` : '') +\n  (entry.description ? ` | DESCRIPTION: ${entry.description}` : '')\n);\n\n// Output the processed data\nreturn [{\n  json: {\n    // Original data passthrough\n    ...($input.first()?.json || {}),\n    \n    // Structured knowledge base data\n    knowledgeBase: {\n      entries: knowledgeArray,\n      searchableStrings: knowledgeStrings,\n      totalProducts: knowledgeArray.length\n    },\n    \n    // Simple concatenated string for memory context\n    knowledgeContext: knowledgeStrings.join('\\n\\n'),\n    \n    // Alternative: Create a more concise version for memory\n    compactKnowledge: knowledgeArray.map(entry => \n      `${entry.name || entry.product}: ${entry.description || 'No description'} (${entry.price || 'Price not available'})`\n    ).join('\\n')\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "91e25c71-a594-4bdc-a33c-c66857b62751",
      "name": "新评论条件判断器",
      "type": "n8n-nodes-base.if",
      "position": [
        784,
        224
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "e566ada9-1a12-41b8-aa9a-55bb7e14a10c",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.property_comment_id }}",
              "rightValue": ""
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "83aa9b95-6671-4813-90e8-3820202324e6",
      "name": "最新评论",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        1024,
        240
      ],
      "parameters": {
        "edge": "comments",
        "node": "={{ \n  $('Last Post Fetcher').first().json.data\n    .sort((a, b) => new Date(b.created_time) - new Date(a.created_time))[0].id \n}}",
        "options": {},
        "graphApiVersion": "v23.0"
      },
      "typeVersion": 1
    },
    {
      "id": "c0420da3-170b-4741-a71d-69998b34b13b",
      "name": "回复撰写器",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        1712,
        224
      ],
      "parameters": {
        "edge": "comments",
        "node": "={{ \n  $('Last Post Fetcher').first().json.data\n    .sort((a, b) => new Date(b.created_time) - new Date(a.created_time))[0].id \n}}",
        "options": {
          "queryParameters": {
            "parameter": [
              {
                "name": "message",
                "value": "={{ $('AI Agent').first().json.output }}"
              }
            ]
          }
        },
        "graphApiVersion": "v23.0",
        "httpRequestMethod": "POST"
      },
      "typeVersion": 1
    },
    {
      "id": "15eb2020-9963-4ae8-adf4-445d5506ae07",
      "name": "评论ID存入数据库",
      "type": "n8n-nodes-base.notion",
      "position": [
        1968,
        224
      ],
      "parameters": {
        "options": {},
        "resource": "databasePage",
        "databaseId": {
          "__rl": true,
          "mode": "list",
          "value": "[PROCESSED_COMMENTS_DATABASE_ID]",
          "cachedResultUrl": "[PROCESSED_COMMENTS_DATABASE_URL]",
          "cachedResultName": "Processed Facebook Comments"
        },
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Comment ID|rich_text",
              "textContent": "={{    $('Last Post Fetcher').first().json.data     .sort((a, b) => new Date(b.created_time) - new Date(a.created_time))[0].id  }}"
            },
            {
              "key": "Response Status|status",
              "statusValue": "Done"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "1cbe6d39-f106-4320-b9a0-7520e7ea4a17",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -512,
        128
      ],
      "parameters": {
        "color": 4,
        "width": 214,
        "content": "通过 Graph API 从指定 Facebook 页面获取所有帖子,启动工作流。"
      },
      "typeVersion": 1
    },
    {
      "id": "db015463-5489-4b59-aca8-8f648a6dc40e",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -272,
        128
      ],
      "parameters": {
        "color": 5,
        "width": 176,
        "content": "处理帖子列表以分离出最近发布的帖子。"
      },
      "typeVersion": 1
    },
    {
      "id": "a3a44851-6263-47b0-bd4e-e1e931cd9033",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "color": 4,
        "width": 256,
        "content": "查询数据库以验证最新评论的唯一ID是否已处理,防止重复回复。"
      },
      "typeVersion": 1
    },
    {
      "id": "8d5f94d9-f8d1-44d5-baba-683c8d2d625e",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        16,
        288
      ],
      "parameters": {
        "color": 5,
        "width": 230,
        "height": 192,
        "content": "从连接的 Notion 数据库获取完整、最新的产品信息和知识库。"
      },
      "typeVersion": 1
    },
    {
      "id": "a7c140a5-42cb-4709-a761-077ea5aacf4c",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        448,
        144
      ],
      "parameters": {
        "color": 5,
        "content": "将原始知识库数据转换为结构化且易于 AI 模型搜索的格式。"
      },
      "typeVersion": 1
    },
    {
      "id": "2c1e6e91-6bf3-4b11-bc89-da414ee8709c",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        720,
        128
      ],
      "parameters": {
        "color": 4,
        "width": 224,
        "height": 192,
        "content": "条件门控;仅当评论为新评论时才允许工作流继续"
      },
      "typeVersion": 1
    },
    {
      "id": "2eee31fa-d437-4c18-9328-1f447b447d9a",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        976,
        144
      ],
      "parameters": {
        "color": 5,
        "width": 208,
        "content": "从最新帖子中提取最新评论的完整内容和元数据。"
      },
      "typeVersion": 1
    },
    {
      "id": "8ce9e8cb-b20f-4efa-97b2-eba6e3c47ede",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1280,
        112
      ],
      "parameters": {
        "color": 6,
        "width": 288,
        "height": 208,
        "content": "核心处理单元。分析客户评论,查阅知识库获取事实性回复,并以目标语言生成个性化、富有同理心的回复。"
      },
      "typeVersion": 1
    },
    {
      "id": "101a2030-dbd0-44af-8116-9bd1bf1a874d",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1616,
        144
      ],
      "parameters": {
        "color": 4,
        "content": "将 AI 生成的回复作为对客户 Facebook 评论的回复发布。"
      },
      "typeVersion": 1
    },
    {
      "id": "5104091f-7597-4413-a5b6-28da90821b66",
      "name": "### 替换 Airtable 连接",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1888,
        128
      ],
      "parameters": {
        "color": 5,
        "width": 272,
        "height": 208,
        "content": "将新处理评论的 ID 记录到数据库中,标记为已完成,防止未来重复处理。"
      },
      "typeVersion": 1
    },
    {
      "id": "c2a5a6cb-79a4-4c7b-9475-4681b45bd3d3",
      "name": "帖子获取器",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -432,
        224
      ],
      "parameters": {
        "url": "=https://graph.facebook.com/v21.0/[FACEBOOK_PAGE_ID]/posts?access_token=[FACEBOOK_ACCESS_TOKEN]\n",
        "options": {},
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "facebookGraphApi"
      },
      "credentials": {
        "facebookGraphApi": {
          "id": "C41mPQIciSciFLKJ",
          "name": "Facebook Graph account"
        }
      },
      "typeVersion": 4.2
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "0e48350f-f5ab-4cdd-83e8-5b4b16974fdd",
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "KB Arrange",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Reply Writer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "KB Arrange": {
      "main": [
        [
          {
            "node": "New Comment Conditioner",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reply Writer": {
      "main": [
        [
          {
            "node": "CommentID to DB",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Posts Fetcher": {
      "main": [
        [
          {
            "node": "Last Post Fetcher",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Knowledge Base": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Latest Comment": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Posts Fetcher",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CommentID Checker": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Last Post Fetcher": {
      "main": [
        [
          {
            "node": "CommentID Checker",
            "type": "main",
            "index": 0
          },
          {
            "node": "Knowledge Base",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "New Comment Conditioner": {
      "main": [
        [],
        [
          {
            "node": "Latest Comment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - AI 聊天机器人, 多模态 AI

需要付费吗?

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

工作流信息
难度等级
高级
节点数量23
分类2
节点类型10
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Abdullah Alshiekh

Abdullah Alshiekh

@abdullah01

🚀 Automation pro building AI-powered workflows with n8n. 💼 Special focus on real use cases 🔧 Love clean, flexible, and business-ready automations.

外部链接
在 n8n.io 查看

分享此工作流