8
n8n 中文网amn8n.com

UGC视频自动生成器

高级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 21 个节点。主要使用 If, Code, Wait, Webhook, GoogleDrive 等节点。 使用Gemini Images和SORA 2自动生成用户生成内容视频

前置要求
  • HTTP Webhook 端点(n8n 会自动生成)
  • Google Drive API 凭证
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "db30e8ae4100235addbd4638770997b7ef11878d049073c888ba440ca84c55fc",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "7fae5006-335a-4721-a2ea-16dc02ecaedb",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1120,
        96
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "path": "create-ugc-video",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "lastNode"
      },
      "typeVersion": 2
    },
    {
      "id": "de4fb004-b472-48c0-85f4-dd6b47962a0c",
      "name": "Nano Banana",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -896,
        96
      ],
      "parameters": {
        "url": "=https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image:generateContent?key={{ $json.body.geminiApiKey }}",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"contents\": [{\n    \"parts\": [{\n      \"text\": \"{{ $json.body.productPrompt }}\"\n    }]\n  }]\n}",
        "sendBody": true,
        "specifyBody": "json"
      },
      "typeVersion": 4.2
    },
    {
      "id": "977bca7d-e89f-4f80-9c9e-4fce547bd6dc",
      "name": "提取图像",
      "type": "n8n-nodes-base.code",
      "position": [
        -688,
        96
      ],
      "parameters": {
        "jsCode": "// Extract image from Nano Banana response\nconst data = $input.first().json;\nconst imageData = data.candidates[0].content.parts.find(p => p.inlineData);\n\nreturn {\n  imageBase64: imageData.inlineData.data,\n  productPrompt: $('Webhook').first().json.body.productPrompt,\n  videoPrompt: $('Webhook').first().json.body.videoPrompt,\n  openaiApiKey: $('Webhook').first().json.body.openaiApiKey\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "dac9378f-8080-435e-9574-296d4632c799",
      "name": "SORA 2",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -464,
        96
      ],
      "parameters": {
        "url": "https://api.openai.com/v1/videos",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"model\": \"sora-2\",\n  \"prompt\": \"{{ $json.videoPrompt }}\",\n  \"size\": \"720x1280\",\n  \"seconds\": \"8\"\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $json.openaiApiKey }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "61cda299-28ee-4e74-aac7-60aa52099dd1",
      "name": "获取视频",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -192,
        96
      ],
      "parameters": {
        "url": "=https://api.openai.com/v1/videos/{{ $('SORA 2').item.json.id }}",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Extract Image').item.json.openaiApiKey }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "281e0b7f-d9ed-438e-a6fd-e144feeb8642",
      "name": "视频完成?",
      "type": "n8n-nodes-base.if",
      "position": [
        208,
        96
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.status }}",
              "value2": "completed"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "08038d29-b87c-4348-ace9-e0f26326cbb4",
      "name": "等待并重试",
      "type": "n8n-nodes-base.wait",
      "position": [
        -16,
        272
      ],
      "webhookId": "YOUR_WAIT_WEBHOOK_ID",
      "parameters": {
        "unit": "minutes",
        "amount": 1
      },
      "typeVersion": 1.1
    },
    {
      "id": "8c7878e6-d8fa-42d5-b253-db967e841e94",
      "name": "添加到 Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        848,
        0
      ],
      "parameters": {
        "columns": {
          "value": {
            "Status": "={{ $json.status }}",
            "Created": "={{ new Date().toISOString() }}",
            "Product": "={{ $('Extract Image').item.json.productPrompt }}",
            "Video URL": "=={{ $('Upload file').item.json.webViewLink }}"
          },
          "schema": [
            {
              "id": "Product",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Product",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Video URL",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Video URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Created",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Created",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "YOUR_SHEET_URL",
          "cachedResultName": "All Videos"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_GOOGLE_SHEET_ID"
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "c15d9c80-ac8c-4e82-aa6a-417c9a157fe6",
      "name": "下载视频文件",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        416,
        0
      ],
      "parameters": {
        "url": "=https://api.openai.com/v1/videos/{{ $json.id }}/content",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Webhook').first().json.body.openaiApiKey }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "7522e1c7-1765-4419-9656-d2e855986913",
      "name": "上传文件",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        624,
        0
      ],
      "parameters": {
        "name": "=={{ $json.id }}.mp4",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "root",
          "cachedResultName": "/ (Root folder)"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "o6YjNioFDdE0IV8W",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "96429180-f0a6-469b-a32b-67aa1ae49392",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1600,
        -64
      ],
      "parameters": {
        "width": 416,
        "height": 448,
        "content": "# UGC 视频生成工作流"
      },
      "typeVersion": 1
    },
    {
      "id": "621ad50b-835a-4afe-808f-dc8e2a904111",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1152,
        -32
      ],
      "parameters": {
        "width": 176,
        "height": 96,
        "content": "接收包含提示和 API 密钥的 POST 请求"
      },
      "typeVersion": 1
    },
    {
      "id": "d28bf28b-13aa-4f85-9176-b3a2f2308ee9",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -928,
        -32
      ],
      "parameters": {
        "width": 176,
        "height": 96,
        "content": "使用 Gemini AI 根据提示生成产品图像"
      },
      "typeVersion": 1
    },
    {
      "id": "44258498-fac6-4fa4-96e4-f0ff518e9cf0",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        -32
      ],
      "parameters": {
        "width": 176,
        "height": 96,
        "content": "从 Gemini API 响应中提取 base64 图像数据"
      },
      "typeVersion": 1
    },
    {
      "id": "5a2c6614-795e-495f-bb49-7152d7e9fb50",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -496,
        -32
      ],
      "parameters": {
        "width": 176,
        "height": 96,
        "content": "使用 OpenAI SORA 模型根据提示创建视频"
      },
      "typeVersion": 1
    },
    {
      "id": "e4e9b154-31cc-4118-8d76-fa3540c22aea",
      "name": "便利贴5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -224,
        -32
      ],
      "parameters": {
        "width": 176,
        "height": 96,
        "content": "通过 API 调用检查 SORA 视频生成状态"
      },
      "typeVersion": 1
    },
    {
      "id": "cbd4ada0-1dbb-41a5-97de-ab2852585cca",
      "name": "便签 6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        -32
      ],
      "parameters": {
        "width": 176,
        "height": 96,
        "content": "确定视频渲染是否完成或待处理"
      },
      "typeVersion": 1
    },
    {
      "id": "86042fc7-7f4b-4306-86fb-4218bde7d5bb",
      "name": "便签 7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -208,
        336
      ],
      "parameters": {
        "width": 176,
        "height": 96,
        "content": "暂停 1 分钟然后再次检查视频状态"
      },
      "typeVersion": 1
    },
    {
      "id": "bc3c7746-3ebb-424f-aeb4-c78c341e81e6",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        384,
        -128
      ],
      "parameters": {
        "width": 176,
        "height": 96,
        "content": "从 OpenAI API 端点下载完成的视频文件"
      },
      "typeVersion": 1
    },
    {
      "id": "7a315df7-736c-4cf4-98b3-8a2a417173d6",
      "name": "便签 9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        592,
        -128
      ],
      "parameters": {
        "width": 176,
        "height": 96,
        "content": "将视频作为 MP4 文件保存到 Google Drive"
      },
      "typeVersion": 1
    },
    {
      "id": "2572eb1d-b20b-4fec-804e-d93e731b8e84",
      "name": "便签10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        816,
        -128
      ],
      "parameters": {
        "width": 176,
        "height": 96,
        "content": "记录视频详情:产品、URL、状态、时间戳"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "SORA 2": {
      "main": [
        [
          {
            "node": "Get Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Nano Banana",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Video": {
      "main": [
        [
          {
            "node": "Video Complete?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Nano Banana": {
      "main": [
        [
          {
            "node": "Extract Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload file": {
      "main": [
        [
          {
            "node": "Add to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait & Retry": {
      "main": [
        [
          {
            "node": "Get Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Image": {
      "main": [
        [
          {
            "node": "SORA 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Video Complete?": {
      "main": [
        [
          {
            "node": "Download Video File",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait & Retry",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Video File": {
      "main": [
        [
          {
            "node": "Upload file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 内容创作, 多模态 AI

需要付费吗?

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

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

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

作者
Daniel Shashko

Daniel Shashko

@tomax

AI automation specialist and a marketing enthusiast. More than 6 years of experience in SEO/GEO. Senior SEO at Bright Data.

外部链接
在 n8n.io 查看

分享此工作流