8
n8n 中文网amn8n.com

n8n异步工作流与Wait节点概念验证

中级

这是一个Miscellaneous, Multimodal AI领域的自动化工作流,包含 12 个节点。主要使用 Wait, Merge, Summarize, HttpRequest, ManualTrigger 等节点。 使用异步处理和Webhook并行运行多个任务

前置要求
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "B816jIs5yNH8NM34",
  "meta": {
    "instanceId": "8981479cb588889c05b145eaed421551d37a4fff11ab279d3f4744a6577c6002"
  },
  "name": "n8n 异步工作流与 Wait 节点概念验证",
  "tags": [],
  "nodes": [
    {
      "id": "5d6a7a8c-4f53-4a4a-8dc7-d4ef6aacc6ec",
      "name": "开始",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "ffea6870-e3db-45bb-82a8-7df03d8e3d82",
      "name": "调用入口点",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        0,
        256
      ],
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "wait",
              "type": "number"
            },
            {
              "name": "webhook"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "886285f8-0f90-4f1d-8b26-837c9181e4a0",
      "name": "等待秒数",
      "type": "n8n-nodes-base.wait",
      "position": [
        224,
        256
      ],
      "webhookId": "dbe5ecd1-9158-4a01-8297-c7971ab9f891",
      "parameters": {
        "amount": "={{ $('Call Entry Point').item.json.wait }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "8e26a389-1284-4008-a608-14531676db92",
      "name": "调用1",
      "type": "n8n-nodes-base.executeWorkflow",
      "position": [
        224,
        0
      ],
      "parameters": {
        "options": {
          "waitForSubWorkflow": false
        },
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "B816jIs5yNH8NM34",
          "cachedResultName": "Async Calls"
        },
        "workflowInputs": {
          "value": {
            "wait": 5,
            "webhook": "={{ $execution.resumeUrl }}/call1"
          },
          "schema": [
            {
              "id": "wait",
              "type": "number",
              "display": true,
              "required": false,
              "displayName": "wait",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "webhook",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "webhook",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "cad29345-1977-439a-b867-8153fc077c8b",
      "name": "请求 Webhook",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        448,
        256
      ],
      "parameters": {
        "url": "={{ $('Call Entry Point').item.json.webhook }}",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "result",
              "value": "={{ $('Call Entry Point').item.json.wait * 2 }}"
            }
          ]
        }
      },
      "retryOnFail": false,
      "typeVersion": 4.2
    },
    {
      "id": "86342836-185e-4303-bc3d-e7dff689f2bb",
      "name": "等待 Webhook 1",
      "type": "n8n-nodes-base.wait",
      "position": [
        672,
        -96
      ],
      "webhookId": "5dc5c78d-ff81-4418-84ac-7521000687cc",
      "parameters": {
        "resume": "webhook",
        "options": {
          "webhookSuffix": "call1"
        },
        "resumeUnit": "minutes",
        "limitWaitTime": true
      },
      "typeVersion": 1.1
    },
    {
      "id": "27ee493d-4ad7-4add-92b7-1931d7349b22",
      "name": "等待 Webhook 2",
      "type": "n8n-nodes-base.wait",
      "position": [
        672,
        96
      ],
      "webhookId": "5dc5c78d-ff81-4418-84ac-7521000687cc",
      "parameters": {
        "resume": "webhook",
        "options": {
          "webhookSuffix": "call2"
        },
        "resumeUnit": "minutes",
        "limitWaitTime": true
      },
      "typeVersion": 1.1
    },
    {
      "id": "c12a5a75-2bd9-4912-aba6-113c58bc3bde",
      "name": "等待1秒",
      "type": "n8n-nodes-base.wait",
      "position": [
        672,
        352
      ],
      "webhookId": "d7bf4ec1-1c40-4878-aa5f-c18f69312a63",
      "parameters": {
        "amount": 1
      },
      "typeVersion": 1.1
    },
    {
      "id": "9b9d24f4-cbee-43ad-9f08-38369208e8c1",
      "name": "调用2",
      "type": "n8n-nodes-base.executeWorkflow",
      "position": [
        448,
        0
      ],
      "parameters": {
        "options": {
          "waitForSubWorkflow": false
        },
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "B816jIs5yNH8NM34",
          "cachedResultName": "Async Calls"
        },
        "workflowInputs": {
          "value": {
            "wait": 3,
            "webhook": "={{ $execution.resumeUrl }}/call2"
          },
          "schema": [
            {
              "id": "wait",
              "type": "number",
              "display": true,
              "required": false,
              "displayName": "wait",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "webhook",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "webhook",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "1e9947e7-db1e-4efe-8eef-a9e0c78da843",
      "name": "合并",
      "type": "n8n-nodes-base.merge",
      "position": [
        896,
        0
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "9b3bc469-fb9d-4642-bd9b-a638a9b47eec",
      "name": "求和",
      "type": "n8n-nodes-base.summarize",
      "position": [
        1104,
        0
      ],
      "parameters": {
        "options": {},
        "fieldsToSummarize": {
          "values": [
            {
              "field": "body.result",
              "aggregation": "sum"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "6a8f11f4-8d10-4a82-9f08-a0831618d5a3",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -656,
        -96
      ],
      "parameters": {
        "width": 592,
        "height": 624,
        "content": "## n8n 异步工作流与 Wait 节点概念验证"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "078e5c9f-a3d7-4cc8-9696-d2db7d298c1c",
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Sum",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start": {
      "main": [
        [
          {
            "node": "Call 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call 1": {
      "main": [
        [
          {
            "node": "Call 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call 2": {
      "main": [
        [
          {
            "node": "Wait for Webhook 1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Wait for Webhook 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait Seconds": {
      "main": [
        [
          {
            "node": "Request Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 1 Second": {
      "main": [
        [
          {
            "node": "Request Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Request Webhook": {
      "main": [
        [],
        [
          {
            "node": "Wait 1 Second",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call Entry Point": {
      "main": [
        [
          {
            "node": "Wait Seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Webhook 1": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Webhook 2": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 杂项, 多模态 AI

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流