8
n8n 中文网amn8n.com

代码注释转FAQ同步 (GitHub)

高级

这是一个Engineering, AI Chatbot领域的自动化工作流,包含 18 个节点。主要使用 If, Code, Slack, Notion, GoogleSheets 等节点。 使用GPT-4o、Notion和Slack为开发团队自动回答GitHub PR问题

前置要求
  • Slack Bot Token 或 Webhook URL
  • Notion API Key
  • Google Sheets API 凭证
  • GitHub Personal Access Token
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "ZtkkWwiBICaiGc4g",
  "meta": {
    "instanceId": "8443f10082278c46aa5cf3acf8ff0f70061a2c58bce76efac814b16290845177",
    "templateCredsSetupCompleted": true
  },
  "name": "代码注释转 FAQ 同步 (GitHub)",
  "tags": [],
  "nodes": [
    {
      "id": "5b60a73e-3918-4730-b195-ac429b2f5acf",
      "name": "配置 GPT-4o 模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatAzureOpenAi",
      "position": [
        144,
        144
      ],
      "parameters": {
        "model": "gpt-4o",
        "options": {}
      },
      "credentials": {
        "azureOpenAiApi": {
          "id": "C3WzT18XqF8OdVM6",
          "name": "Azure Open AI account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2b63fa67-e389-43a5-ab07-0a54a890dd57",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -944,
        -400
      ],
      "parameters": {
        "height": 448,
        "content": "## 节点名称:GitHub PR 评论触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "49031929-9cdb-4a5e-97e4-cfbcaa93fd1f",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -496,
        144
      ],
      "parameters": {
        "height": 368,
        "content": "## 节点名称:验证 GitHub Webhook 负载"
      },
      "typeVersion": 1
    },
    {
      "id": "7df85bda-9810-4dc0-97c6-4280bffcf513",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        448
      ],
      "parameters": {
        "height": 384,
        "content": "## 节点名称:在 Google Sheets 中记录错误"
      },
      "typeVersion": 1
    },
    {
      "id": "9eae3668-e27a-46ec-925b-e187ebb38d39",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        -528
      ],
      "parameters": {
        "height": 432,
        "content": "## 节点名称:为开发者问题生成 AI 回复"
      },
      "typeVersion": 1
    },
    {
      "id": "7298a7db-60d9-4891-99d4-17ab86e2eb26",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        464,
        -512
      ],
      "parameters": {
        "height": 416,
        "content": "## 节点名称:提取 GitHub 评论元数据"
      },
      "typeVersion": 1
    },
    {
      "id": "b149f1f2-65a2-4a0b-8736-e556a6caf632",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        704,
        160
      ],
      "parameters": {
        "height": 432,
        "content": "## 节点名称:保存评论洞察到 Notion 数据库"
      },
      "typeVersion": 1
    },
    {
      "id": "5d286fc7-9919-4102-8afc-c6f12933c510",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        224,
        272
      ],
      "parameters": {
        "height": 352,
        "content": "## 节点名称:配置 GPT-4o 模型"
      },
      "typeVersion": 1
    },
    {
      "id": "f035aa9a-2f76-4de6-a451-84a00dbb690e",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -176,
        -464
      ],
      "parameters": {
        "height": 400,
        "content": "## Node Name: Detect Developer Question in PR Comment\n**Action**: Evaluates whether a PR comment contains a question like “how do I…” or “how to…”.\n**Description**:\nThis conditional node scans the text of the GitHub comment for help-related keywords.  \nIf the comment is a technical query, it routes the flow to the AI assistant for generating a concise answer. Otherwise, the workflow ends silently.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "c6e89357-de32-4be6-bbe0-f486751ead92",
      "name": " GitHub PR Comment Trigger",
      "type": "n8n-nodes-base.githubTrigger",
      "position": [
        -672,
        -32
      ],
      "webhookId": "1114ba07-d98e-4751-80f2-119a9394f666",
      "parameters": {
        "owner": {
          "__rl": true,
          "mode": "name",
          "value": "saurabhg97"
        },
        "events": [
          "pull_request_review_comment"
        ],
        "options": {},
        "repository": {
          "__rl": true,
          "mode": "name",
          "value": "weather-app"
        },
        "authentication": "oAuth2"
      },
      "credentials": {
        "githubOAuth2Api": {
          "id": "rnLgyYy9XPnp6GZ9",
          "name": "saurabh github"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c4f82baa-ca82-4858-8d2f-2e9dd7febe3c",
      "name": "Validate GitHub Webhook Payload",
      "type": "n8n-nodes-base.if",
      "position": [
        -400,
        -32
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "e2adb005-2b3c-4d1e-8445-442df1fe925a",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.body.comment.url }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "a739f228-5357-4ab7-bee6-62b7929d08df",
      "name": "Detect Developer Question in PR Comment",
      "type": "n8n-nodes-base.if",
      "position": [
        -112,
        -48
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "2ad8bc15-beaa-4606-9a8d-ecfd38e446cb",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ \n  (\n    $json[\"body\"][\"comment\"][\"body\"].toLowerCase().includes(\"how do i\") ||\n    $json[\"body\"][\"comment\"][\"body\"].toLowerCase().includes(\"how to\")\n  ).toString()\n}}\n",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "5b0d7c5e-cc2d-44fd-9cf2-b6edfc5e08bc",
      "name": "Generate AI Response for Developer Question",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        192,
        -64
      ],
      "parameters": {
        "text": "={{ \n`Question: ${$json[\"body\"][\"comment\"][\"body\"]}\n\nContext: PR Link - ${$json[\"body\"][\"comment\"][\"html_url\"]}\nRepository: ${$json[\"body\"][\"repository\"][\"full_name\"]}\n` \n}}\n",
        "options": {
          "systemMessage": "=You are a helpful developer assistant. \nProvide short, clear, and technically correct answers (2–3 lines max) to developer questions found in GitHub PR comments.\n"
        },
        "promptType": "define"
      },
      "typeVersion": 2.1
    },
    {
      "id": "433930c9-f10d-4db5-b419-9ed8a1adb5d0",
      "name": "Extract GitHub Comment Metadata",
      "type": "n8n-nodes-base.code",
      "position": [
        544,
        -64
      ],
      "parameters": {
        "jsCode": "// Access the original webhook data\nconst webhookData = $(' GitHub PR Comment Trigger').first().json;\n\nreturn [\n  {\n    json: {\n      repository: webhookData.body.repository.full_name,\n      comment: webhookData.body.comment.body,\n      username: webhookData.body.comment.user.login,\n      file_path: webhookData.body.comment.path,\n      pr_number: webhookData.body.pull_request.number\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "3c1ef780-1b15-4932-9aa9-99cb89f4195b",
      "name": "Save Comment Insight to Notion Database",
      "type": "n8n-nodes-base.notion",
      "position": [
        784,
        -64
      ],
      "parameters": {
        "title": "={{ $json.repository }}",
        "simple": false,
        "options": {},
        "resource": "databasePage",
        "databaseId": {
          "__rl": true,
          "mode": "list",
          "value": "265802b9-1fa0-806f-a52a-e6d71d9ff2e0",
          "cachedResultUrl": "https://www.notion.so/265802b91fa0806fa52ae6d71d9ff2e0",
          "cachedResultName": "test db"
        },
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Name|title",
              "title": "={{ $json.comment }}"
            },
            {
              "key": "Name|title",
              "title": "={{ $json.username }}"
            },
            {
              "key": "Name|title",
              "title": "={{ $now }}"
            },
            {
              "key": "Name|title",
              "title": "={{ $json.file_path }}"
            },
            {
              "key": "Name|title",
              "title": "={{ String($json.pr_number) }}\n"
            }
          ]
        }
      },
      "credentials": {
        "notionApi": {
          "id": "iDjtgSTYG9ECVBtT",
          "name": "Notion account 2"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "828abb32-ab14-4a13-aaf8-2d0723df639d",
      "name": "Log Errors in Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -128,
        256
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [
            {
              "id": "error_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "error_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "error",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "error",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "error_id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1338537721,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Uldk_4BxWbdZTDZxFUeohIfeBmGHHqVEl9Ogb0l6R8Y/edit#gid=1338537721",
          "cachedResultName": "error log sheet"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1Uldk_4BxWbdZTDZxFUeohIfeBmGHHqVEl9Ogb0l6R8Y",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Uldk_4BxWbdZTDZxFUeohIfeBmGHHqVEl9Ogb0l6R8Y/edit?usp=drivesdk",
          "cachedResultName": "Interviewer Brief Pack "
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "kpPEOLCGn963qpoh",
          "name": "automations@techdome.ai"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "5f0bdf64-2400-416f-a2b0-5b8a19bba710",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1024,
        160
      ],
      "parameters": {
        "height": 576,
        "content": "## Node Name: Post AI Answer & PR Link to Slack\n**Action**: Sends the generated AI response and the GitHub PR comment link to a Slack channel or user.\n**Description**:\nThis node posts the AI-generated technical answer (from “Generate AI Response for Developer Question”) directly to Slack, followed by the original GitHub PR comment link for quick context.  \nIt ensures that the internal team (or reviewer) is instantly notified whenever a developer’s query is processed by the AI system — allowing faster review and collaboration inside Slack.  \nTypically used to streamline developer feedback loops and keep AI-assisted responses visible to the engineering team in real time.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "945e97e6-b51a-4771-931b-02ab81ef902b",
      "name": " Post AI Answer & PR Link to Slack",
      "type": "n8n-nodes-base.slack",
      "position": [
        1056,
        -64
      ],
      "webhookId": "ddaa7632-9e35-4bd3-82d6-572d5cae84cc",
      "parameters": {
        "text": "={{ $('Generate AI Response for Developer Question').item.json.output }}{{ $('Detect Developer Question in PR Comment').item.json.body.comment.url }}",
        "user": {
          "__rl": true,
          "mode": "list",
          "value": "U09HMPVD466",
          "cachedResultName": "newscctv22"
        },
        "select": "user",
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "id": "rNqvWj9TfChPVRYY",
          "name": "Slack account vivek"
        }
      },
      "typeVersion": 2.3
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "9f9ae9c5-9555-4e6d-94e6-2891348064ae",
  "connections": {
    "Configure GPT-4o Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate AI Response for Developer Question",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    " GitHub PR Comment Trigger": {
      "main": [
        [
          {
            "node": "Validate GitHub Webhook Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract GitHub Comment Metadata": {
      "main": [
        [
          {
            "node": "Save Comment Insight to Notion Database",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate GitHub Webhook Payload": {
      "main": [
        [
          {
            "node": "Detect Developer Question in PR Comment",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log Errors in Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Detect Developer Question in PR Comment": {
      "main": [
        [
          {
            "node": "Generate AI Response for Developer Question",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Comment Insight to Notion Database": {
      "main": [
        [
          {
            "node": " Post AI Answer & PR Link to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate AI Response for Developer Question": {
      "main": [
        [
          {
            "node": "Extract GitHub Comment Metadata",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 工程, AI 聊天机器人

需要付费吗?

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

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

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

作者
Rahul Joshi

Rahul Joshi

@rahul08

Rahul Joshi is a seasoned technology leader specializing in the n8n automation tool and AI-driven workflow automation. With deep expertise in building open-source workflow automation and self-hosted automation platforms, he helps organizations eliminate manual processes through intelligent n8n ai agent automation solutions.

外部链接
在 n8n.io 查看

分享此工作流