学习n8n第1课

高级

这是一个Miscellaneous领域的自动化工作流,包含 73 个节点。主要使用 Set、Code、Form、Merge、SplitOut 等节点。 交互式工作流教程:学习数据流、执行模式与调试基础

前置要求
  • 无特殊前置要求,导入即可使用
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "name": "学习n8n第1课",
  "nodes": [
    {
      "id": "ff2278e7-8006-48e9-84f1-20ad164d7a2e",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        740,
        840
      ],
      "parameters": {
        "width": 1100,
        "content": "## 开始之前..."
      },
      "typeVersion": 1
    },
    {
      "id": "68b20538-bac1-41d2-bfa5-f063f25e1ae9",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        740,
        300
      ],
      "parameters": {
        "color": 4,
        "width": 1100,
        "height": 520,
        "content": "# 让我们学习n8n!第1课"
      },
      "typeVersion": 1
    },
    {
      "id": "b35c197d-383f-4ec3-a9a9-1d62d8cff5b1",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        740,
        1020
      ],
      "parameters": {
        "color": 7,
        "width": 540,
        "height": 520,
        "content": "## 触发器(从这里开始)"
      },
      "typeVersion": 1
    },
    {
      "id": "0eedeb20-c10e-4c65-8004-3a4754d2c4dd",
      "name": "表单开始",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        940,
        1280
      ],
      "webhookId": "24e63036-9b31-41af-bc16-f86bfd922b7e",
      "parameters": {
        "options": {
          "buttonLabel": "Begin",
          "appendAttribution": false
        },
        "formTitle": "Let's Learn N8N! Lesson 1",
        "formFields": {
          "values": [
            {
              "html": "<strong>READ CAREFULLY:</strong>\n<ul>\n  <li>You will want to inspect how nodes are configured while going through the tutorial.</li>\n  <li>To see a node's settings, you will need to STOP EXECUTION of the tutorial, then double-click the node.</li>\n  <li>N8N doesn't like this and may bring up a spinner while it's trying to halt the execution.</li>\n  <li>It's <strong>SAFE</strong> to hit reload on the web browser instead of waiting, unless you have unsaved changes.</li>\n</ul>",
              "fieldType": "html",
              "elementName": "notes"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "ca85572d-10dd-4c86-a275-663e3afc236b",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1300,
        1020
      ],
      "parameters": {
        "color": 7,
        "width": 540,
        "height": 520,
        "content": "## 1.a 无操作节点"
      },
      "typeVersion": 1
    },
    {
      "id": "6c411304-753b-4366-9ff1-2e96196b7265",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1860,
        1020
      ],
      "parameters": {
        "color": 7,
        "width": 540,
        "height": 520,
        "content": "## 1.b 表单下一页"
      },
      "typeVersion": 1
    },
    {
      "id": "1e991481-5e32-4774-bc97-d0e25c2d28d3",
      "name": "下一页表单",
      "type": "n8n-nodes-base.form",
      "position": [
        2060,
        1280
      ],
      "webhookId": "7a36a95d-ef02-4d38-894e-21c8ce76d233",
      "parameters": {
        "options": {
          "formTitle": "Let's Begin...",
          "buttonLabel": "Continue",
          "formDescription": "Go look at the workspace, read the comments, then come back here to continue."
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2cea38ab-7c3f-4cde-9cab-f3921a2f9215",
      "name": "便利贴5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2420,
        1020
      ],
      "parameters": {
        "color": 7,
        "width": 540,
        "height": 520,
        "content": "## 1.c 流程控制"
      },
      "typeVersion": 1
    },
    {
      "id": "b7085944-2030-43e1-b29d-190a4661f930",
      "name": "执行操作1",
      "type": "n8n-nodes-base.form",
      "position": [
        2620,
        1160
      ],
      "webhookId": "7a36a95d-ef02-4d38-894e-21c8ce76d233",
      "parameters": {
        "options": {
          "formTitle": "Do Thing 1",
          "buttonLabel": "Continue",
          "formDescription": "This flow always happens first."
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6c551394-9bf0-425a-9512-90a61ec40ff6",
      "name": "执行操作2",
      "type": "n8n-nodes-base.form",
      "position": [
        2620,
        1380
      ],
      "webhookId": "7a36a95d-ef02-4d38-894e-21c8ce76d233",
      "parameters": {
        "options": {
          "formTitle": "Do Thing 2",
          "buttonLabel": "Continue",
          "formDescription": "This will always happen second."
        }
      },
      "typeVersion": 1
    },
    {
      "id": "69c57ad4-7041-419d-9f70-65d09e0cc353",
      "name": "便签 6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2980,
        1020
      ],
      "parameters": {
        "color": 7,
        "width": 540,
        "height": 520,
        "content": "## 1.e 数据"
      },
      "typeVersion": 1
    },
    {
      "id": "619ae4aa-9d11-4f38-9d51-c851a9df054b",
      "name": "值传递表单",
      "type": "n8n-nodes-base.form",
      "position": [
        3320,
        1380
      ],
      "webhookId": "8d366e88-9fcf-4ea5-b824-d8642e183b50",
      "parameters": {
        "options": {
          "formTitle": "Value Passed Example",
          "buttonLabel": "Continue",
          "formDescription": "=This form was passed a value:  {{ $json.my_value_1e }}"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "73e9382a-f2c4-4505-ab99-8801c1f54e4e",
      "name": "便签 7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3540,
        1020
      ],
      "parameters": {
        "color": 7,
        "width": 680,
        "height": 520,
        "content": "## 1.f 数据与流程"
      },
      "typeVersion": 1
    },
    {
      "id": "37da6ee6-0f24-4d77-8319-fc16d1ba2453",
      "name": "可以看到它",
      "type": "n8n-nodes-base.form",
      "position": [
        3900,
        1180
      ],
      "webhookId": "8d366e88-9fcf-4ea5-b824-d8642e183b50",
      "parameters": {
        "options": {
          "formTitle": "Can See It",
          "buttonLabel": "Continue",
          "formDescription": "=This form CAN see the data.\nmy_value_1f is:  {{ $json.my_value_1f }}"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "bf47aa50-003d-4a77-ab9d-c3f7baf30633",
      "name": "无法看到它",
      "type": "n8n-nodes-base.form",
      "position": [
        3720,
        1380
      ],
      "webhookId": "8d366e88-9fcf-4ea5-b824-d8642e183b50",
      "parameters": {
        "options": {
          "formTitle": "Cannot See It",
          "buttonLabel": "Continue",
          "formDescription": "=This form CANNOT see the data because it was set on a different branch.\nmy_value_1f is:  {{ $json.my_value_1f }}\n"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "57b861ab-338b-4b3f-8816-e5864446b95d",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4240,
        1020
      ],
      "parameters": {
        "color": 7,
        "width": 840,
        "height": 520,
        "content": "## 1.g 合并"
      },
      "typeVersion": 1
    },
    {
      "id": "37c740ad-b3a2-420a-9f29-a13529f2d71b",
      "name": "合并",
      "type": "n8n-nodes-base.merge",
      "position": [
        4580,
        1260
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3.2
    },
    {
      "id": "6186fae2-4e26-4f76-9d70-3de47db23375",
      "name": "让我们修复它...",
      "type": "n8n-nodes-base.noOp",
      "position": [
        4020,
        1380
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "1747a9eb-86d7-4ccd-aa47-ea33b70753b7",
      "name": "两者都能看到",
      "type": "n8n-nodes-base.form",
      "position": [
        4760,
        1260
      ],
      "webhookId": "8d366e88-9fcf-4ea5-b824-d8642e183b50",
      "parameters": {
        "options": {
          "formTitle": "Can See Both",
          "buttonLabel": "Continue",
          "formDescription": "=Thanks to the Merge node I can see both:\nmy_value_1g is:  {{ $json.my_value_1g }}\nmy_value_1g2 is:  {{ $json.my_value_1g2 }}\n"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "114390e2-5cb8-4c0a-b854-be4e22cfd4dd",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        4180,
        1820
      ],
      "parameters": {
        "options": {
          "reset": false
        }
      },
      "typeVersion": 3
    },
    {
      "id": "15c7c0f1-2536-472e-93e0-def860d91bcb",
      "name": "便签10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3920,
        1560
      ],
      "parameters": {
        "color": 7,
        "width": 860,
        "height": 740,
        "content": "## 2.d 循环"
      },
      "typeVersion": 1
    },
    {
      "id": "ca324b3f-9a00-4e0c-a07e-1561124dad99",
      "name": "便签11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        740,
        1560
      ],
      "parameters": {
        "color": 7,
        "width": 1100,
        "height": 740,
        "content": "## 2."
      },
      "typeVersion": 1
    },
    {
      "id": "18d2ed51-712f-4f0d-8f50-69ef506978cb",
      "name": "便签13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5100,
        1020
      ],
      "parameters": {
        "color": 7,
        "width": 780,
        "height": 520,
        "content": "## 1.h 来自先前节点的数据"
      },
      "typeVersion": 1
    },
    {
      "id": "2c2b0e3b-3a3b-4627-aa3a-aa0f5b7a840e",
      "name": "设置值1e",
      "type": "n8n-nodes-base.set",
      "position": [
        3060,
        1380
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "8bb46286-1b20-4319-bb8c-142ade5e6e89",
              "name": "my_value_1e",
              "type": "string",
              "value": "10"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "b1fef81b-c671-4033-8a87-915df72321f6",
      "name": "设置值1f",
      "type": "n8n-nodes-base.set",
      "position": [
        3720,
        1180
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "8bb46286-1b20-4319-bb8c-142ade5e6e89",
              "name": "my_value_1f",
              "type": "string",
              "value": "20"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "662cf64c-8e0e-401c-976d-b794b135abb0",
      "name": "设置值1g",
      "type": "n8n-nodes-base.set",
      "position": [
        4340,
        1180
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "8bb46286-1b20-4319-bb8c-142ade5e6e89",
              "name": "my_value_1g",
              "type": "string",
              "value": "100"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "044b741c-a604-4a26-9eff-31b737de471d",
      "name": "设置值1g2",
      "type": "n8n-nodes-base.set",
      "position": [
        4340,
        1380
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "8bb46286-1b20-4319-bb8c-142ade5e6e89",
              "name": "my_value_1g2",
              "type": "string",
              "value": "200"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "214aff8e-7620-46d1-ba3f-f916880cd95c",
      "name": "第一",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1500,
        1280
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "3b611737-473d-47a3-93e9-ef43cb2f8ecf",
      "name": "第二",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1500,
        1920
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "ccce50f6-17da-45f6-85c8-4a4b45e65417",
      "name": "便签15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5900,
        1020
      ],
      "parameters": {
        "color": 7,
        "width": 500,
        "height": 520,
        "content": "## 1.i 日志"
      },
      "typeVersion": 1
    },
    {
      "id": "c5a1a61f-2aa8-4015-8f18-251059e495aa",
      "name": "执行无关操作",
      "type": "n8n-nodes-base.set",
      "position": [
        5400,
        1340
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "d9676dde-4468-42bd-995e-cae9aaa565eb",
              "name": "city",
              "type": "string",
              "value": "seattle"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "5f3af10e-5391-4950-b1d1-7e2da8d006e6",
      "name": "设置值1h",
      "type": "n8n-nodes-base.set",
      "position": [
        5180,
        1340
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "75f23997-27e4-4fe2-9c10-1f6a24c74cf5",
              "name": "my_value_1h",
              "type": "string",
              "value": "1001"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "a7ce5b64-c460-4760-bcc2-7e30c94f443b",
      "name": "引用示例表单",
      "type": "n8n-nodes-base.form",
      "position": [
        5620,
        1340
      ],
      "webhookId": "2284fb96-b079-49bf-a759-8f77fab7bd59",
      "parameters": {
        "options": {
          "formTitle": "Reference Examples Form",
          "buttonLabel": "Continue",
          "formDescription": "=This won't work: {{ $json.my_value_1h }}\nThis will work: {{ $('Set Value 1h').item.json.my_value_1h }}"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6d781269-772e-47eb-8036-c69b451e63b8",
      "name": "便签16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2600,
        1560
      ],
      "parameters": {
        "color": 7,
        "width": 700,
        "height": 740,
        "content": "## 2.b 聚合"
      },
      "typeVersion": 1
    },
    {
      "id": "c5f36d5b-c316-4ca6-b879-e237650117bc",
      "name": "聚合项目",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        2880,
        2080
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "all_items"
      },
      "typeVersion": 1
    },
    {
      "id": "b55d3432-b67d-4bb4-91d9-6af1f3da8f47",
      "name": "获取此项目",
      "type": "n8n-nodes-base.set",
      "position": [
        4400,
        1980
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "fbeee64b-3911-4ba6-9097-b59a7d69c143",
              "name": "this_item_index",
              "type": "number",
              "value": "={{ $('Loop Over Items').context['currentRunIndex'] }}"
            },
            {
              "id": "c71c3b91-e946-4a83-86d7-84cfcc88fdd1",
              "name": "this_item",
              "type": "object",
              "value": "={{ $json }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "fcd7675b-0ec9-4d3d-bb4d-29a17fdaa72d",
      "name": "创建四个项目",
      "type": "n8n-nodes-base.code",
      "position": [
        3980,
        1820
      ],
      "parameters": {
        "jsCode": "const output = [];\n\nfor (let i = 1; i <= 4; i++) {\n  output.push({\n    json: {\n      id: i,\n      name: `User ${i}`,\n      email: `user${i}@example.com`,\n      active: i % 2 === 0,\n      createdAt: new Date().toISOString()\n    }\n  });\n}\n\nreturn output;"
      },
      "typeVersion": 2
    },
    {
      "id": "e206566a-4490-4afe-9a55-406abf9133d0",
      "name": "便签17",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1860,
        1560
      ],
      "parameters": {
        "color": 7,
        "width": 720,
        "height": 740,
        "content": "## 2.a 每个项目变为一次执行"
      },
      "typeVersion": 1
    },
    {
      "id": "1708c618-3c85-4897-a304-b50129a0c2a1",
      "name": "运行三次!",
      "type": "n8n-nodes-base.code",
      "position": [
        2220,
        1760
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// If you look at the Mode setting above, this node is set to run once for each item\n// This means we reference the one and only items passed in as follows:\nconsole.log(\"Running Once for each item: \" + $input.item.json.name);\n\n// We can return whatever we want, or nothing at all. \n// Here we just return the item passed in.\n\nreturn $input.item;"
      },
      "typeVersion": 2
    },
    {
      "id": "48542eda-8057-4360-9d91-ac034091199d",
      "name": "运行一次!",
      "type": "n8n-nodes-base.code",
      "position": [
        2220,
        1920
      ],
      "parameters": {
        "jsCode": "// If you look at the Mode setting above, this node is set to run once for ALL ITEMS PASSED IN.\n// That means n8n will wait to call us until all the data is ready, then run this node once.\n\n// This means we reference the data as an array, as follows:\n// (bad/example code for clarity... typically make a for loop)\nconsole.log(\"Running Once for all items: \" + $input.all()[0].json.name + \", \" + $input.all()[1].json.name + \", \" + $input.all()[2].json.name);\n\n// Now we if return ALL items, then we would cause the following node to get called 3 times also\n// Instead return a single empty item, so the next node would be called a single time\nreturn [{ json: {} }];"
      },
      "typeVersion": 2
    },
    {
      "id": "8d4e9817-31e7-4174-a7b4-12bbbf9412e1",
      "name": "2.a 注释",
      "type": "n8n-nodes-base.form",
      "position": [
        2220,
        2080
      ],
      "webhookId": "6417fe75-4076-4c38-81b2-52576220dcff",
      "parameters": {
        "options": {
          "formTitle": "2.a Notes",
          "buttonLabel": "Continue"
        },
        "formFields": {
          "values": [
            {
              "html": "<p>Notice that in the workflow, on the connectors it says \"3 items\" or \"1 item\". This tells you both how many data items are moving along it as well as how many times it executed.</p>\n\n<p>Now open your web browser's debug console (F12 in Windows Chrome).</p>\n\n<p>Notice three console log prints for the first path. The three items from Create Three Items caused that Code node to execute three times.</p>\n\n<p>Notice a single print from the second path. By changing the Code node setting, we asked N8N to first gather all the data together, and then execute the node once.</p>\n\n<p><strong>Mastering the flow of data is fundamental to building in N8N.</strong> Using Code nodes and console logs will help you.</p>\n\n<p>Before you continue, make sure to stop the workflow and examine the code in each of these Code nodes.</p>\n",
              "fieldType": "html",
              "elementName": "notes"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7fc22ad3-a112-42f3-865f-af42e0ab65ea",
      "name": "创建三个项目",
      "type": "n8n-nodes-base.code",
      "position": [
        1960,
        1920
      ],
      "parameters": {
        "jsCode": "// Code nodes can return an empty array or one or more items.\n\n// For this example we return 3 items. This will typically cause the following node to execute 3 times, once for each.\n\nreturn [\n  { json: { id: 1, name: \"Alice\", active: true } },\n  { json: { id: 2, name: \"Bob\", active: false } },\n  { json: { id: 3, name: \"Charlie\", active: true } }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "c5441c55-4bae-4c81-81de-956d033d4325",
      "name": "创建五个项目",
      "type": "n8n-nodes-base.code",
      "position": [
        2680,
        2080
      ],
      "parameters": {
        "jsCode": "const output = [];\n\n// Another method for creating test data to return.\nfor (let i = 1; i <= 5; i++) {\n  output.push({\n    json: {\n      id: i,\n      name: `User ${i}`,\n      email: `user${i}@example.com`,\n      active: i % 2 === 0,\n      createdAt: new Date().toISOString()\n    }\n  });\n}\n\nreturn output;"
      },
      "typeVersion": 2
    },
    {
      "id": "07337c9c-fc41-469e-8cc7-183d4c58891a",
      "name": "便签21",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3320,
        1560
      ],
      "parameters": {
        "color": 7,
        "width": 580,
        "height": 740,
        "content": "## 2.c 拆分"
      },
      "typeVersion": 1
    },
    {
      "id": "7567aacc-d3d2-44d0-80fb-781c3f73bda3",
      "name": "分离输出",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        3380,
        2080
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "all_items"
      },
      "typeVersion": 1
    },
    {
      "id": "b34f4e64-7038-478f-a7d1-7a34ea296af6",
      "name": "运行五次!",
      "type": "n8n-nodes-base.code",
      "position": [
        3620,
        1880
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// If you look at the Mode setting above, this node is set to run once for each item\n// This means we reference the one and only items passed in as follows:\nconsole.log(\"Running Once for each item: \" + $input.item.json.name);\n\n// We can return whatever we want, or nothing at all. \n// Here we just return the item passed in.\n\nreturn $input.item;"
      },
      "typeVersion": 2
    },
    {
      "id": "495b7519-c115-4207-b6ef-045b18ccc738",
      "name": "2.c 注释",
      "type": "n8n-nodes-base.form",
      "position": [
        3620,
        2080
      ],
      "webhookId": "96b27442-bcaf-4e9d-8ea5-8e8c4be9efa6",
      "parameters": {
        "options": {
          "formTitle": "2.c Notes",
          "buttonLabel": "Continue"
        },
        "formFields": {
          "values": [
            {
              "html": "Notice we again have 5 prints to the web browser's console log, one for each data item.",
              "fieldType": "html",
              "elementName": "2c_notes"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8e2bbca1-642f-409f-be90-db0c7806f6c8",
      "name": "2.b 注释",
      "type": "n8n-nodes-base.form",
      "position": [
        3120,
        1860
      ],
      "webhookId": "96b27442-bcaf-4e9d-8ea5-8e8c4be9efa6",
      "parameters": {
        "options": {
          "formTitle": "2.b Notes",
          "buttonLabel": "Continue"
        },
        "formFields": {
          "values": [
            {
              "html": "<p>Now we can operate on the entire aggregated array at once:</p>\n<p>{{ JSON.stringify($('Aggregate Items').item.json.all_items) }}</p>",
              "fieldType": "html"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "74ca982a-ff90-497d-b5cf-c9de11792686",
      "name": "仅一次",
      "type": "n8n-nodes-base.noOp",
      "position": [
        4900,
        1920
      ],
      "parameters": {},
      "executeOnce": true,
      "typeVersion": 1
    },
    {
      "id": "5f550dd8-5a04-4da9-9f10-e8dc82189e5c",
      "name": "便签22",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4800,
        1560
      ],
      "parameters": {
        "color": 7,
        "width": 540,
        "height": 740,
        "content": "## 2.e 仅一次"
      },
      "typeVersion": 1
    },
    {
      "id": "d50b22b8-5389-404e-bd03-ee54dde35cd5",
      "name": "2d 每个表单执行一次",
      "type": "n8n-nodes-base.form",
      "position": [
        4560,
        1980
      ],
      "webhookId": "a7dfc984-0a68-4c0b-9b6e-e7ffcdc459d2",
      "parameters": {
        "options": {
          "formTitle": "2.d Once For Each Form",
          "buttonLabel": "Continue"
        },
        "formFields": {
          "values": [
            {
              "html": "<p>You will see this same form pop up four times, one for each item.</p>\n<p>Make sure to stop the workflow and look at how the loop item is referenced in the Get This Item node.</p>\n<p>The current index is {{ $json.this_item_index }}</p>\n<p>The current item name is:  {{ $json.this_item.name }}</p>\n",
              "fieldType": "html",
              "elementName": "notes"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "aaf09884-bd8f-4267-b18c-d17302824d4e",
      "name": "2e 注释1",
      "type": "n8n-nodes-base.form",
      "position": [
        5120,
        1920
      ],
      "webhookId": "a7dfc984-0a68-4c0b-9b6e-e7ffcdc459d2",
      "parameters": {
        "options": {
          "formTitle": "2.e Notes",
          "buttonLabel": "Continue"
        },
        "formFields": {
          "values": [
            {
              "html": "<p>Inspect the settings on the No Op node to see it reduces execution to once.</p>\n",
              "fieldType": "html",
              "elementName": "notes"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5603cb9c-7a09-4cbd-b725-dc5c44db2792",
      "name": "便签23",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5360,
        1560
      ],
      "parameters": {
        "color": 7,
        "width": 2080,
        "height": 740,
        "content": "## 2.f 执行流不会合并"
      },
      "typeVersion": 1
    },
    {
      "id": "77b1feb5-b95d-448a-8538-5bad07e00902",
      "name": "NOP",
      "type": "n8n-nodes-base.noOp",
      "position": [
        5440,
        1920
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "4ca4bc58-f99c-4e9c-9ec0-5559194b374d",
      "name": "创建集合A1",
      "type": "n8n-nodes-base.code",
      "position": [
        5680,
        1800
      ],
      "parameters": {
        "jsCode": "const output = [];\n\nfor (let i = 0; i <= 4; i++) {\n  output.push({\n    json: {\n      id: i,\n      name: `User ${i}`,\n      email: `user${i}@example.com`,\n      active: i % 2 === 0,\n      createdAt: new Date().toISOString()\n    }\n  });\n}\n\nreturn output;"
      },
      "typeVersion": 2
    },
    {
      "id": "f9a320d8-f5a7-4cab-94b2-a1c9c74f293d",
      "name": "创建集合B1",
      "type": "n8n-nodes-base.code",
      "position": [
        5680,
        1960
      ],
      "parameters": {
        "jsCode": "const output = [];\n\nfor (let i = 5; i <= 10; i++) {\n  output.push({\n    json: {\n      id: i,\n      name: `User ${i}`,\n      email: `user${i}@example.com`,\n      active: i % 2 === 0,\n      createdAt: new Date().toISOString()\n    }\n  });\n}\n\nreturn output;"
      },
      "typeVersion": 2
    },
    {
      "id": "46454cda-b6dd-4b54-a53e-c583a93cfe9b",
      "name": "聚合集合",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        5920,
        1880
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "4b0e1b31-d259-414c-9abc-3df08c0ccf19",
      "name": "创建集合A",
      "type": "n8n-nodes-base.code",
      "position": [
        6560,
        1640
      ],
      "parameters": {
        "jsCode": "const output = [];\n\nfor (let i = 0; i <= 4; i++) {\n  output.push({\n    json: {\n      id: i,\n      name: `User ${i}`,\n      email: `user${i}@example.com`,\n      active: i % 2 === 0,\n      createdAt: new Date().toISOString()\n    }\n  });\n}\n\nreturn output;"
      },
      "typeVersion": 2
    },
    {
      "id": "9a96daad-5079-44ae-9a5e-b7d816bd7195",
      "name": "创建集合B",
      "type": "n8n-nodes-base.code",
      "position": [
        6560,
        1840
      ],
      "parameters": {
        "jsCode": "const output = [];\n\nfor (let i = 5; i <= 10; i++) {\n  output.push({\n    json: {\n      id: i,\n      name: `User ${i}`,\n      email: `user${i}@example.com`,\n      active: i % 2 === 0,\n      createdAt: new Date().toISOString()\n    }\n  });\n}\n\nreturn output;"
      },
      "typeVersion": 2
    },
    {
      "id": "1fc18394-1c43-423d-92c3-ba00fefd170e",
      "name": "合并1",
      "type": "n8n-nodes-base.merge",
      "position": [
        6800,
        1920
      ],
      "parameters": {
        "numberInputs": 3
      },
      "typeVersion": 3.2
    },
    {
      "id": "3ff48b4e-7ba9-4f59-9e43-5f4faed188ee",
      "name": "最后",
      "type": "n8n-nodes-base.noOp",
      "position": [
        6340,
        2040
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "2a5678c3-62c4-4b35-9104-e6cfb47fe85f",
      "name": "第二任务",
      "type": "n8n-nodes-base.noOp",
      "position": [
        6340,
        1840
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "b3b7bf85-356b-4803-9026-6280dfbad57a",
      "name": "第一任务",
      "type": "n8n-nodes-base.noOp",
      "position": [
        6340,
        1640
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "d1c18ac7-2ccb-44ed-976e-158776c1d474",
      "name": "聚合",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        6980,
        1920
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "b5cabacb-f180-4a09-8b02-f3950731cd3f",
      "name": "2f 注释1",
      "type": "n8n-nodes-base.form",
      "position": [
        5920,
        2140
      ],
      "webhookId": "a7dfc984-0a68-4c0b-9b6e-e7ffcdc459d2",
      "parameters": {
        "options": {
          "formTitle": "2f Notes",
          "buttonLabel": "Continue"
        },
        "formFields": {
          "values": [
            {
              "html": "<p>Execution flows can't be combined. Hit continue to see the solution.</p>\n",
              "fieldType": "html",
              "elementName": "notes"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d449ef29-f4e0-4892-9ada-92959d7b22a4",
      "name": "2f 注释2",
      "type": "n8n-nodes-base.form",
      "position": [
        7160,
        1920
      ],
      "webhookId": "a7dfc984-0a68-4c0b-9b6e-e7ffcdc459d2",
      "parameters": {
        "options": {
          "formTitle": "2f Notes",
          "buttonLabel": "Continue"
        },
        "formFields": {
          "values": [
            {
              "html": "<p>Now we get a final, correctly combined result we can work on.</p>\n<p>Combined all items for a final count of: {{ $json.data.length }}</p>\n",
              "fieldType": "html",
              "elementName": "notes"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "1224453e-2736-424b-a870-37b7a9763e9b",
      "name": "NOP2",
      "type": "n8n-nodes-base.noOp",
      "position": [
        5680,
        2140
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "c501d4a7-071a-4836-8400-b6b013a36ed4",
      "name": "便签12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        740,
        2320
      ],
      "parameters": {
        "color": 7,
        "width": 1100,
        "height": 420,
        "content": "## 3."
      },
      "typeVersion": 1
    },
    {
      "id": "6d5048ed-0823-4ba8-ac05-04e8cce5b0bc",
      "name": "第三",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1500,
        2500
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "ce898745-4de9-4b04-8f0b-33c2695e1e7a",
      "name": "便签14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1860,
        2320
      ],
      "parameters": {
        "color": 7,
        "width": 600,
        "height": 420,
        "content": "## 完成第1课"
      },
      "typeVersion": 1
    },
    {
      "id": "2b2ea7a7-d5a6-4df2-b847-d8a28a543fbe",
      "name": "日志",
      "type": "n8n-nodes-base.form",
      "position": [
        6100,
        1340
      ],
      "webhookId": "ac5a7be0-8892-4632-9415-150ea271591d",
      "parameters": {
        "options": {
          "formTitle": "Logs",
          "buttonLabel": "Continue",
          "formDescription": "Follow the comments in the workflow to open and inspect the Logs."
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d3c9fa93-f142-49da-a34e-c69a91d1e0e0",
      "name": "恭喜",
      "type": "n8n-nodes-base.form",
      "position": [
        1960,
        2500
      ],
      "webhookId": "8e02c96b-a018-468d-a860-5722becc528d",
      "parameters": {
        "options": {
          "formTitle": "Lesson 1 Completed",
          "buttonLabel": "Continue"
        },
        "formFields": {
          "values": [
            {
              "html": "<p><strong>Congratulations!</strong></p>\n<p>Now use the nodes from this lesson to create your own workflows.</p>\n<p>Spend time with the Logs interface, and learning how to debug. This will really pay off.</p>\n<p>If you want to do something more rewarding, use the Form node to get messages from the user and send them to an AI agent -- It's easy in N8N.</p>\n<p>When you are ready for the next lesson, look for it <a href=\"https://n8n.io/creators/wyeth/\">here</a> along with other workflows showing solutions to common problems.</p>\n<p>Have fun!</p>",
              "fieldType": "html",
              "elementName": "notes"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5b6b8fe3-a214-4988-b3a4-85cbdbc1362b",
      "name": "结束",
      "type": "n8n-nodes-base.form",
      "position": [
        2200,
        2500
      ],
      "webhookId": "934e81ed-efef-425d-ad49-947196572908",
      "parameters": {
        "operation": "completion",
        "redirectUrl": "https://n8n.io/creators/wyeth/",
        "respondWith": "redirect"
      },
      "typeVersion": 1
    }
  ],
  "settings": {
    "executionOrder": "v1"
  },
  "connections": {
    "NOP": {
      "main": [
        [
          {
            "node": "Create Set A1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Create Set B1",
            "type": "main",
            "index": 0
          },
          {
            "node": "NOP2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "NOP2": {
      "main": [
        [
          {
            "node": "2f Notes 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FIRST": {
      "main": [
        [
          {
            "node": "Next Form",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Can See Both",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "THIRD": {
      "main": [
        [
          {
            "node": "Congrats",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SECOND": {
      "main": [
        [
          {
            "node": "Create Three Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FINALLY": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Congrats": {
      "main": [
        [
          {
            "node": "End",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2.a Notes": {
      "main": [
        [
          {
            "node": "Create Five Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2.c Notes": {
      "main": [
        [
          {
            "node": "Create Four Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2e Notes1": {
      "main": [
        [
          {
            "node": "NOP",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "2f Notes 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Next Form": {
      "main": [
        [
          {
            "node": "Do Thing 1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Do Thing 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Only Once": {
      "main": [
        [
          {
            "node": "2e Notes1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Runs Five Times!",
            "type": "main",
            "index": 0
          },
          {
            "node": "2.c Notes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2f Notes 1": {
      "main": [
        [
          {
            "node": "FIRST TASK",
            "type": "main",
            "index": 0
          },
          {
            "node": "SECOND TASK",
            "type": "main",
            "index": 0
          },
          {
            "node": "FINALLY",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Do Thing 2": {
      "main": [
        [
          {
            "node": "Set Value 1e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FIRST TASK": {
      "main": [
        [
          {
            "node": "Create Set A",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Form Start": {
      "main": [
        [
          {
            "node": "THIRD",
            "type": "main",
            "index": 0
          },
          {
            "node": "FIRST",
            "type": "main",
            "index": 0
          },
          {
            "node": "SECOND",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Cant See It": {
      "main": [
        [
          {
            "node": "Lets Fix It...",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SECOND TASK": {
      "main": [
        [
          {
            "node": "Create Set B",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Can See Both": {
      "main": [
        [
          {
            "node": "Set Value 1h",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Set A": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Set B": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Set Value 1e": {
      "main": [
        [
          {
            "node": "Value Passed Form",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Value 1f": {
      "main": [
        [
          {
            "node": "Can See It",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Value 1g": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Value 1h": {
      "main": [
        [
          {
            "node": "Do Something Unrelated",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Set A1": {
      "main": [
        [
          {
            "node": "Aggregate Sets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Set B1": {
      "main": [
        [
          {
            "node": "Aggregate Sets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get This Item": {
      "main": [
        [
          {
            "node": "2d Once for Each Form",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Value 1g2": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Lets Fix It...": {
      "main": [
        [
          {
            "node": "Set Value 1g2",
            "type": "main",
            "index": 0
          },
          {
            "node": "Set Value 1g",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Items": {
      "main": [
        [
          {
            "node": "2.b Notes",
            "type": "main",
            "index": 0
          },
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Only Once",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get This Item",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Five Items": {
      "main": [
        [
          {
            "node": "Aggregate Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Four Items": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Value Passed Form": {
      "main": [
        [
          {
            "node": "Set Value 1f",
            "type": "main",
            "index": 0
          },
          {
            "node": "Cant See It",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Three Items": {
      "main": [
        [
          {
            "node": "Runs Three Times!",
            "type": "main",
            "index": 0
          },
          {
            "node": "Runs Once!",
            "type": "main",
            "index": 0
          },
          {
            "node": "2.a Notes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2d Once for Each Form": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Do Something Unrelated": {
      "main": [
        [
          {
            "node": "Reference Examples Form",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reference Examples Form": {
      "main": [
        [
          {
            "node": "Logs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

这是一个高级难度的工作流,适用于Miscellaneous等场景。适合高级用户,包含 16+ 个节点的复杂工作流

需要付费吗?

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

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

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

外部链接
在 n8n.io 上查看 →

分享此工作流