提示 #3:重试/延迟超过 5 秒/5 次尝试

中级

这是一个Engineering领域的自动化工作流,包含 8 个节点。主要使用 If、Set、Wait、HttpRequest、StopAndError 等节点。 提示 #3:重试/延迟超过 5 秒/5 次尝试

前置要求
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "2OIJjgh9dop5IF6f",
  "meta": {
    "instanceId": "8981479cb588889c05b145eaed421551d37a4fff11ab279d3f4744a6577c6002"
  },
  "name": "提示 #3:重试/延迟超过 5 秒/5 次尝试",
  "tags": [],
  "nodes": [
    {
      "id": "885f5632-f4f1-4efd-a5a6-b5d39a180f86",
      "name": "当点击\"执行工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        0,
        45
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "c4ccc06f-0cb7-4aac-a195-dc8b6dae87e5",
      "name": "HTTP 请求",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "maxTries": 5,
      "position": [
        440,
        45
      ],
      "parameters": {
        "url": "https://example.com/1",
        "options": {}
      },
      "retryOnFail": false,
      "typeVersion": 4.2,
      "waitBetweenTries": 5000
    },
    {
      "id": "4be525c2-5b5c-4d1a-b7f0-363faa63d522",
      "name": "设置字段",
      "type": "n8n-nodes-base.set",
      "position": [
        220,
        45
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "509eb34a-731a-42cb-82d8-8b8172e35719",
              "name": "delay_seconds",
              "type": "number",
              "value": 30
            },
            {
              "id": "3c241ef0-eb4e-4c92-93c6-696949db1170",
              "name": "max_tries",
              "type": "string",
              "value": "6"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "6280a197-72bb-4cc2-8530-b4cc922180f1",
      "name": "编辑字段",
      "type": "n8n-nodes-base.set",
      "position": [
        660,
        -30
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "1edaa212-dd5e-4368-9394-97e18ff19578",
              "name": "delay_seconds",
              "type": "string",
              "value": "={{ $json.delay_seconds }}"
            },
            {
              "id": "fa20c333-5d70-4cb4-9403-3c0c8633512d",
              "name": "max_tries",
              "type": "number",
              "value": "={{ $json.max_tries - 1 }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "3273bc42-46e6-4d26-9f1b-c3cf456f27eb",
      "name": "条件判断",
      "type": "n8n-nodes-base.if",
      "position": [
        880,
        -30
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "43ba9e9c-70ce-4a6d-93cb-c39984911994",
              "operator": {
                "type": "number",
                "operation": "lte"
              },
              "leftValue": "={{ $json.max_tries }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "62460f30-3329-4392-919e-09da442a0bbd",
      "name": "停止并报错",
      "type": "n8n-nodes-base.stopAndError",
      "position": [
        1100,
        -80
      ],
      "parameters": {
        "errorMessage": "=Service unavailable after {{ $('Set Fields').item.json.max_tries }} tries"
      },
      "typeVersion": 1
    },
    {
      "id": "3c918a29-2b14-42e7-9e97-9cd92bc62a79",
      "name": "等待",
      "type": "n8n-nodes-base.wait",
      "position": [
        1100,
        145
      ],
      "webhookId": "4fb44836-a76d-4886-a7c3-993bdc49b7f5",
      "parameters": {
        "amount": "={{ $json.delay_seconds }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "3ddbc2a4-519c-4623-9098-312b1f14c9af",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        -200
      ],
      "parameters": {
        "width": 360,
        "height": 180,
        "content": "## 提示 #3:重试/延迟超过 5 秒/5 次尝试"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "85e44a66-f18e-43cf-a9fa-e2486f6a76b8",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Stop and Error",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Fields": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [],
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Set Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

这是一个中级难度的工作流,适用于Engineering等场景。适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

需要付费吗?

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

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

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

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

分享此工作流