8
n8n 中文网amn8n.com

简单工作流

中级

这是一个AI, IT Ops领域的自动化工作流,包含 11 个节点。主要使用 Code, Slack, Webhook, Aggregate, GoogleDrive 等节点,结合人工智能技术实现智能自动化。 使用 Straker、Google Drive 和 Slack 的自动化文档翻译质量验证

前置要求
  • Slack Bot Token 或 Webhook URL
  • HTTP Webhook 端点(n8n 会自动生成)
  • Google Drive API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "UlhQJ6EtKLNQ0D0B",
  "meta": {
    "instanceId": "80505302fd25f9874da713d840f99df997e6fbacf51f09d5b5fa57decd258ea9",
    "templateCredsSetupCompleted": true
  },
  "name": "简单工作流",
  "tags": [],
  "nodes": [
    {
      "id": "3686255e-4eee-41aa-9046-76ef2d0159f5",
      "name": "扁平化",
      "type": "n8n-nodes-base.code",
      "position": [
        200,
        740
      ],
      "parameters": {
        "jsCode": "/**\n * n8n “Function” node — Run Once for All Items\n * ──> emits one item per target-file URL, with\n *      • filename tagged <base>_<site_shortname>.<ext>\n *      • original language_uuid preserved\n */\nreturn items.flatMap(({ json: { data } }) => {\n  if (!data?.source_files) {\n    throw new Error('No source_files array found in job payload');\n  }\n\n  // uuid → site_shortname\n  const shortCode = Object.fromEntries(\n    (data.target_languages ?? []).map(l => [\n      l.uuid.toLowerCase(),\n      l.site_shortname ?? l.code,\n    ]),\n  );\n\n  return data.source_files.flatMap(sf =>\n    (sf.target_files ?? []).map(tf => {\n      const short = shortCode[tf.language_uuid.toLowerCase()] || tf.language_uuid;\n      const [name, ext = ''] = sf.filename.split(/(?=\\.[^\\.]+$)/); // split at last dot\n\n      return {\n        json: {\n          url: tf.url,\n          filename: `${name}_${short}${ext}`,\n          source_file_uuid: sf.file_uuid,\n          target_file_uuid: tf.target_file_uuid,\n          language_uuid: tf.language_uuid,\n          status: tf.status,\n        },\n      };\n    }),\n  );\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "f8a3825e-2091-4359-ad1a-9ac9ed4423a0",
      "name": "监视输入文件夹",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -240,
        480
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1jS3LMLVuHbsKFmtTRiRmUPUBO-CKqsfb",
          "cachedResultUrl": "",
          "cachedResultName": ""
        }
      },
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "53ab19cd-4abc-463c-9c98-00e4fe843ef1",
      "name": "下载文件",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -20,
        480
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "on4yFmHCAe4A3uke",
          "name": "Google Drive account"
        }
      },
      "notesInFlow": true,
      "typeVersion": 3
    },
    {
      "id": "a29304d4-4d30-4d36-9db1-0c0412c946a9",
      "name": "等待完成",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -240,
        740
      ],
      "webhookId": "6540f764-161d-4627-b7c2-a78a992daf1d",
      "parameters": {
        "path": "6540f764-161d-4627-b7c2-a78a992daf1d",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2
    },
    {
      "id": "0e4c0d6c-db2d-4625-9f57-235342ce791e",
      "name": "保存到输出文件夹",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        640,
        740
      ],
      "parameters": {
        "name": "={{ $('Flatten').item.json.filename }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "16Ke3E8wSbTVfuOUXrex-ueNLuyIRhK95",
          "cachedResultUrl": "",
          "cachedResultName": ""
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "on4yFmHCAe4A3uke",
          "name": "Google Drive account"
        }
      },
      "notesInFlow": true,
      "typeVersion": 3
    },
    {
      "id": "5152a976-9ea9-48f6-bbe1-3bbbff90f13b",
      "name": "通知",
      "type": "n8n-nodes-base.slack",
      "position": [
        1080,
        740
      ],
      "webhookId": "516ba7f2-c441-4cf9-a045-ef8842b273fb",
      "parameters": {
        "text": "={{ $('Fetch Job Info').first().json.data.title }} {{ $('Fetch Job Info').first().json.data.status }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C08NJCEJS8Y",
          "cachedResultName": "slack-bots"
        },
        "otherOptions": {}
      },
      "notesInFlow": true,
      "typeVersion": 2.3
    },
    {
      "id": "e9cac943-64d4-4a3e-99cb-e4f1ac8cbfaf",
      "name": "聚合",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        860,
        740
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "21827824-54e7-458a-bab7-8fb3f83421ab",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1100,
        260
      ],
      "parameters": {
        "width": 720,
        "height": 840,
        "content": "# Straker Verify n8n 节点"
      },
      "typeVersion": 1
    },
    {
      "id": "5f4e70ca-2db9-4f52-94b3-f65c2c67bbe5",
      "name": "获取作业信息",
      "type": "n8n-nodes-straker-verify.strakerVerify",
      "position": [
        -20,
        740
      ],
      "parameters": {
        "operation": "get",
        "projectId": "={{ $json.body.job_uuid }}"
      },
      "credentials": {
        "strakerVerifyApi": {
          "id": "iRfa1PqR7RY6GKtJ",
          "name": "Straker Verify account"
        }
      },
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "180231a6-563a-4843-a450-98f67cda6215",
      "name": "抓取翻译",
      "type": "n8n-nodes-straker-verify.strakerVerify",
      "position": [
        420,
        740
      ],
      "parameters": {
        "fileId": "={{ $json.target_file_uuid }}",
        "resource": "file"
      },
      "credentials": {
        "strakerVerifyApi": {
          "id": "iRfa1PqR7RY6GKtJ",
          "name": "Straker Verify account"
        }
      },
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "b0cd4ece-949b-43d1-8229-2c6988dac15e",
      "name": "开始翻译",
      "type": "n8n-nodes-straker-verify.strakerVerify",
      "position": [
        200,
        480
      ],
      "parameters": {
        "title": "TEST 12",
        "languages": [],
        "operation": "create",
        "workflowId": "78ed818e-3655-4bd2-b347-dcce14e58c1c"
      },
      "notesInFlow": true,
      "typeVersion": 1
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "173445a9-d8f0-4f31-a46d-8671eabf98a8",
  "connections": {
    "Flatten": {
      "main": [
        [
          {
            "node": "Grab Translation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "Notify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Files": {
      "main": [
        [
          {
            "node": "Start Translation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Job Info": {
      "main": [
        [
          {
            "node": "Flatten",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Grab Translation": {
      "main": [
        [
          {
            "node": "Save to Output Folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Watch Input Folder": {
      "main": [
        [
          {
            "node": "Download Files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Completion": {
      "main": [
        [
          {
            "node": "Fetch Job Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save to Output Folder": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 人工智能, IT 运维

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流