8
n8n 中文网amn8n.com

n8n 工作流部署器

高级

这是一个Other领域的自动化工作流,包含 21 个节点。主要使用 Set, Code, GoogleDrive, HttpRequest, ManualTrigger 等节点。 从 Google Drive 部署工作流到 n8n 实例

前置要求
  • Google Drive API 凭证
  • 可能需要目标 API 的认证凭证

分类

工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "bhWsUxipJ9wuTA5K",
  "meta": {
    "instanceId": "fd11e31161384d7618b8c5580f01ec2285d2165d3df82195429972f6a3f814eb",
    "templateCredsSetupCompleted": true
  },
  "name": "n8n 工作流部署器",
  "tags": [],
  "nodes": [
    {
      "id": "8db6d045-5ef8-444a-ae3e-0f0611946008",
      "name": "获取现有工作流标签",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -580,
        -580
      ],
      "parameters": {
        "url": "={{ $json.N8N_Instance_URL }}api/v1/tags",
        "options": {},
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "accept",
              "value": "application/json"
            }
          ]
        },
        "nodeCredentialType": "n8nApi"
      },
      "credentials": {
        "n8nApi": {
          "id": "eOE2pATZyQiS1K4C",
          "name": "n8n account"
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2,
      "waitBetweenTries": 5000
    },
    {
      "id": "da4aeef3-05a4-48c9-ae5c-9038f07e3693",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -300,
        -1040
      ],
      "parameters": {
        "color": 3,
        "width": 1460,
        "height": 760,
        "content": "## 设置说明"
      },
      "typeVersion": 1
    },
    {
      "id": "520aa22e-0456-4383-ba6d-fd89fd77f193",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -680,
        -140
      ],
      "parameters": {
        "color": 4,
        "width": 260,
        "height": 280,
        "content": "### 设置变量:"
      },
      "typeVersion": 1
    },
    {
      "id": "2e0794eb-0213-48fd-a974-26301bfdfc8a",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        300,
        -120
      ],
      "parameters": {
        "color": 4,
        "width": 440,
        "height": 260,
        "content": "### 配置 n8n API 认证"
      },
      "typeVersion": 1
    },
    {
      "id": "f77ad2ef-32e3-4d24-b79b-9898152cbbac",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1100,
        -780
      ],
      "parameters": {
        "color": 5,
        "width": 740,
        "height": 420,
        "content": "## 1. 获取工作流标签"
      },
      "typeVersion": 1
    },
    {
      "id": "cf10c998-44fc-4f1a-8d61-9187a9eae82a",
      "name": "当点击\"测试工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1040,
        -580
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "206fffc1-d7ee-41eb-b6ad-55be8ae60526",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        -700
      ],
      "parameters": {
        "color": 4,
        "width": 220,
        "height": 280,
        "content": "### 设置变量:"
      },
      "typeVersion": 1
    },
    {
      "id": "2bbe9b3e-c302-497f-a724-e8c51ce673ef",
      "name": "从文件中提取 JSON 对象",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -80,
        -40
      ],
      "parameters": {
        "options": {},
        "operation": "fromJson"
      },
      "typeVersion": 1
    },
    {
      "id": "2f0acb18-86c4-4f94-8f76-b72174809643",
      "name": "清理 JSON 文件准备导入",
      "type": "n8n-nodes-base.code",
      "position": [
        140,
        -40
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const fullWorkflow = $json.data || $json;\n\n// Build settings with only allowed fields\nconst cleanSettings = {};\nif (fullWorkflow.settings?.executionOrder) {\n  cleanSettings.executionOrder = fullWorkflow.settings.executionOrder;\n}\nif (fullWorkflow.settings?.timezone) {\n  cleanSettings.timezone = fullWorkflow.settings.timezone;\n}\n\n// Construct clean workflow object\nconst cleanWorkflow = {\n  name: fullWorkflow.name,\n  nodes: fullWorkflow.nodes,\n  connections: fullWorkflow.connections,\n  settings: cleanSettings,\n};\n\nreturn { json: cleanWorkflow };\n"
      },
      "typeVersion": 2
    },
    {
      "id": "f0428a03-2194-4390-b14b-5149ea3a220b",
      "name": "设置 n8n API URL 和标签 ID 变量",
      "type": "n8n-nodes-base.set",
      "position": [
        -600,
        -40
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "41afa23f-bacf-4c2b-9630-68483acc9fe6",
              "name": "N8N_Instance_URL",
              "type": "string",
              "value": "https://SUB.DOMAINNAME.com/"
            },
            {
              "id": "c27f2d9d-ee1f-4ada-90cc-20177017b342",
              "name": "N8N_Instance_Tag",
              "type": "string",
              "value": "mIzqUB1qBwewiiX3"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "9f59cba9-9452-4e05-9d95-3e405ec195cf",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -980,
        -140
      ],
      "parameters": {
        "color": 4,
        "width": 260,
        "height": 280,
        "content": "### 更改 Google Drive 文件夹"
      },
      "typeVersion": 1
    },
    {
      "id": "87ce4868-407c-461f-92e2-6b3bf1dd616e",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -640,
        -760
      ],
      "parameters": {
        "color": 4,
        "height": 340,
        "content": "### 配置 n8n API 认证。"
      },
      "typeVersion": 1
    },
    {
      "id": "b1c3f693-a587-4928-a90a-8288eb84a879",
      "name": "创建 n8n 工作流",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        360,
        -40
      ],
      "parameters": {
        "url": "={{ $('Set n8n API URL & Tag ID variables').item.json.N8N_Instance_URL }}api/v1/workflows",
        "body": "={{ $json }}",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "raw",
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "rawContentType": "application/json",
        "headerParameters": {
          "parameters": [
            {
              "name": "accept",
              "value": "application/json"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "nodeCredentialType": "n8nApi"
      },
      "credentials": {
        "n8nApi": {
          "id": "eOE2pATZyQiS1K4C",
          "name": "n8n account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "70ff3b11-3664-4fec-a220-72696a6083c5",
      "name": "设置工作流标签",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        600,
        -40
      ],
      "parameters": {
        "url": "={{ $('Set n8n API URL & Tag ID variables').item.json.N8N_Instance_URL }}api/v1/workflows/{{ $json.id }}/tags",
        "method": "PUT",
        "options": {},
        "jsonBody": "=[\n  {\n    \"id\": \"{{ $('Set n8n API URL & Tag ID variables').item.json.N8N_Instance_Tag }}\"\n  }\n]",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "n8nApi"
      },
      "credentials": {
        "n8nApi": {
          "id": "eOE2pATZyQiS1K4C",
          "name": "n8n account"
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2,
      "waitBetweenTries": 5000
    },
    {
      "id": "55671121-7027-476b-8eff-9d9a16385cce",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        -120
      ],
      "parameters": {
        "color": 4,
        "width": 260,
        "height": 260,
        "content": "### 更改 Google Drive Deployed 文件夹"
      },
      "typeVersion": 1
    },
    {
      "id": "e8a9bbd8-a41d-4b82-931c-5570651d8583",
      "name": "如果创建工作流失败则捕获名称",
      "type": "n8n-nodes-base.code",
      "position": [
        600,
        160
      ],
      "parameters": {
        "jsCode": "return [{\n  json: {\n    workflowName:   $json.name,\n    errorMessage:   $json.error.message,\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "0fee0939-f3bd-4fd1-b444-40509f4b0f50",
      "name": "将 JSON 文件移动到 Deployed 文件夹",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        880,
        -40
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Google Drive Trigger -ToDeploy folder').item.json.id }}"
        },
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1nQb17Xf7ZTF75E-aettkFtBVKI_nOrsW",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1nQb17Xf7ZTF75E-aettkFtBVKI_nOrsW",
          "cachedResultName": "Deployed"
        },
        "operation": "move"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "SfLfcExz8PihKGNB",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "59567f07-4d69-4d30-a5ef-934198ff101d",
      "name": "下载 n8n JSON 文件",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -320,
        -40
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Google Drive Trigger -ToDeploy folder').item.json.id }}"
        },
        "options": {
          "binaryPropertyName": "data"
        },
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "SfLfcExz8PihKGNB",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "a5837765-9787-43a5-bbfe-44e5f3728aee",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1100,
        -260
      ],
      "parameters": {
        "color": 5,
        "width": 2260,
        "height": 620,
        "content": "## 2. 将 JSON 工作流导入 n8n 实例"
      },
      "typeVersion": 1
    },
    {
      "id": "bcb77b34-36c8-4839-b3e2-72f8e60871ba",
      "name": "设置 n8n URL 变量",
      "type": "n8n-nodes-base.set",
      "position": [
        -820,
        -580
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "41afa23f-bacf-4c2b-9630-68483acc9fe6",
              "name": "N8N_Instance_URL",
              "type": "string",
              "value": "https://SUB.DOMAINNAME.com/"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "7281ab81-d1e8-4a78-8e2f-e1049633d6e6",
      "name": "Google Drive 触发器 - ToDeploy 文件夹",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -880,
        -40
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1EPGHT5fBn0Hx_EVDixJiJMJgRbNNdB0I",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1EPGHT5fBn0Hx_EVDixJiJMJgRbNNdB0I",
          "cachedResultName": "toDeploy"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "SfLfcExz8PihKGNB",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "77325a25-51f0-441a-8750-fe6d1d5a266f",
  "connections": {
    "Set Workflow Tag": {
      "main": [
        [
          {
            "node": "Move JSON file to Deployed folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create n8n Workflow": {
      "main": [
        [
          {
            "node": "Set Workflow Tag",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Capture Name If Fails To Create Workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set n8n URL variable": {
      "main": [
        [
          {
            "node": "Get Existing Workflow Tags",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download n8n JSON File": {
      "main": [
        [
          {
            "node": "Extract JSON object from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract JSON object from File": {
      "main": [
        [
          {
            "node": "Clean JSON file ready for import",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean JSON file ready for import": {
      "main": [
        [
          {
            "node": "Create n8n Workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Set n8n URL variable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set n8n API URL & Tag ID variables": {
      "main": [
        [
          {
            "node": "Download n8n JSON File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger -ToDeploy folder": {
      "main": [
        [
          {
            "node": "Set n8n API URL & Tag ID variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 其他

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流