{
  "name": "GitHub Issue 分类工作流",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "github-issue",
        "responseMode": "onReceived",
        "options": {}
      },
      "name": "GitHub Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [0, 0],
      "webhookId": "github-issue-triage"
    },
    {
      "parameters": {
        "values": {
          "string": [
            { "name": "title", "value": "={{$json.issue.title}}" },
            { "name": "body", "value": "={{$json.issue.body}}" },
            { "name": "number", "value": "={{$json.issue.number}}" },
            { "name": "repo", "value": "={{$json.repository.full_name}}" }
          ]
        }
      },
      "name": "提取Issue字段",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [220, 0]
    },
    {
      "parameters": {
        "url": "https://api.moonshot.cn/v1/chat/completions",
        "method": "POST",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "Authorization", "value": "Bearer YOUR_LLM_API_KEY" },
            { "name": "Content-Type", "value": "application/json" }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"model\":\"moonshot-v1-8k\",\"messages\":[{\"role\":\"system\",\"content\":\"你是项目维护者。判断GitHub issue类型和优先级，仅输出JSON：type(bug/feature/documentation/question)+priority(P0/P1/P2/P3)+reason。正文空或无复现步骤P2起步\"},{\"role\":\"user\",\"content\":\"标题:{{$json.title}}\\n正文:{{$json.body}}\"}]}",
        "options": {}
      },
      "name": "LLM分类",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [440, 0]
    },
    {
      "parameters": {
        "url": "=https://api.github.com/repos/{{$node[\"提取Issue字段\"].json.repo}}/issues/{{$node[\"提取Issue字段\"].json.number}}",
        "method": "PATCH",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "Authorization", "value": "Bearer YOUR_GITHUB_TOKEN" },
            { "name": "Accept", "value": "application/vnd.github+json" }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"labels\":[\"{{JSON.parse($json.choices[0].message.content).type}}\",\"{{JSON.parse($json.choices[0].message.content).priority}}\"]}",
        "options": {}
      },
      "name": "打GitHub标签",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [660, 0]
    },
    {
      "parameters": {
        "url": "YOUR_NOTIFY_WEBHOOK",
        "method": "POST",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"msg_type\":\"text\",\"content\":{\"text\":\"新Issue分诊：{{$node[\"提取Issue字段\"].json.title}} -> {{JSON.parse($json.choices[0].message.content).type}} / {{JSON.parse($json.choices[0].message.content).priority}}\"}}",
        "options": {}
      },
      "name": "通知群",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [880, 0]
    }
  ],
  "connections": {
    "GitHub Webhook": { "main": [ [{ "node": "提取Issue字段", "type": "main", "index": 0 }] ] },
    "提取Issue字段": { "main": [ [{ "node": "LLM分类", "type": "main", "index": 0 }] ] },
    "LLM分类": { "main": [ [{ "node": "打GitHub标签", "type": "main", "index": 0 }] ] },
    "打GitHub标签": { "main": [ [{ "node": "通知群", "type": "main", "index": 0 }] ] }
  }
}
