ChatGPT销售增长营收AI 评分 · 73/100AI 辅助编辑·未发现明显提示词注入风险n8n.io

用 n8n 自动把 Google Sheets 产品表转成 UGC 视频(DALL·E + GPT-4 Vision + Sora)

输入:Google Sheets 产品列表;处理:DALL·E 3 生成图像 → GPT-4 Vision 分析视觉风格 → Sora 生成视频 → 上传 Google Drive;输出:带公开链接的完成行。

经验丰富步骤流程提示词贴士
给谁
已有 n8n 实例、熟悉 OAuth 凭证配置的营销运营或自动化工程师
你会得到
自动为每个标记为 Pending 的产品生成 AI 图像与短视频,回写公开链接到表格
你需要
n8n · google-sheets · google-drive · dalle-3

硬约束

前置条件:n8n 实例;Google Sheets OAuth2、Google Drive OAuth2、OpenAI API 凭证;Google Sheet 需含 Product Name / Description / Target Audience / Status / Image URL / Video URL / Error Message 列;Sora API 访问可能受限。费用:DALL·E 3 与 Sora 按调用计费。

他们做了什么

作者 vonnairone 在 n8n 上发布了一个官方模板,展示如何以 Google Sheets 为数据源,自动为每个标记 Pending 的产品依次调用 DALL·E 3 生成图像、GPT-4 Vision 分析视觉风格、Sora 生成 8 秒 720x1280 视频,最后上传 Google Drive 并回写公开链接到表格。工作流含 37 个节点,包括定时触发、分批循环、异步轮询、错误处理等机制。

效果如何

模板声称可实现「完全免手动的 UGC 视频流水线」(author_report)。来源未提供具体成功率、生成时长分布或费用数据。

值得知道

Sora API 可能受地区或访问权限限制;视频生成异步,单次可能耗时数分钟;DALL·E 与 Sora 均按调用计费,费用取决于用量;模板 workflow.json 中硬编码了示例 Google Sheet ID 与 Drive Folder ID,必须替换为用户自有资源;生成图像的 URL 可能过期,模板通过回写到 Drive/Sheets 做持久化;本站未实测该工作流,reproduction=not_tested。

n8n 工作流模板

结构已检查 · 未实际运行

下载后在 n8n 选择“Import from File”,或复制 JSON 后粘贴到编辑器。先配置自己的账号,再用测试数据运行;模板默认未启用。

配置与测试清单

需要绑定的凭证

  • Update Sheet — Error 节点:绑定Google Sheets OAuth2 凭证。
  • Update Sheet — Done2 节点:绑定Google Sheets OAuth2 凭证。
  • Make File Public1 节点:绑定Google Drive OAuth2 凭证。
  • Upload Video to Google Drive1 节点:绑定Google Drive OAuth2 凭证。
  • Fetch Sora Video Content1 节点:绑定OpenAI API 凭证。
  • Poll Sora Status1 节点:绑定OpenAI API 凭证。
  • Sora Generate Video1 节点:绑定OpenAI API 凭证。
  • GPT-4 Vision Analysis1 节点:绑定OpenAI API 凭证。
  • DALL-E 3 Generate Image1 节点:绑定OpenAI API 凭证。
  • Read Product Sheet1 节点:绑定Google Sheets OAuth2 凭证。

需要替换的配置

  • 源模板来自 n8n 公开库 #14256(约 37 个节点)。导入后先保持未启用,核对触发器、表达式与外部 API 端点。
  • Sticky Note 中的说明仅供参考;按自己的账号、表结构或频道 ID 替换占位配置。

测试输入与预期结果

  • 在测试环境手动执行一次主路径,确认每个需凭证的节点已连接且无鉴权错误。
  • 用一条合成/脱敏样例数据跑通,核对输出字段与下游写入目标,再考虑生产启用。

模板处理说明

  • 已移除原作者凭证绑定、webhookId 与执行数据,工作流设为未启用;节点、连线与原文提示词保持原样。未在 n8n 中实际运行。
  • 未改业务逻辑;运行前请自行核对密钥、配额与隐私合规。

模板获取日期: 2026-10-25

步骤

  1. 触发与读取待处理产品

    在 n8n 中配置 Schedule Trigger 按设定间隔运行。添加 Google Sheets 节点读取 Products 工作表全部行,再用 Code 节点过滤出 Status = "Pending" 的行,并记录每行的 sheetRowNumber(i + 2,含表头偏移)。若无 Pending 行,工作流自然结束。

    搭建指导 · 来源原文。n8n Schedule Trigger + Google Sheets 节点配置说明

    ## Stage 1 — Trigger & data fetch. 
    
    A schedule trigger fires on a set interval. It reads all rows from a Google Sheets "Products" tab, then a code node filters down to only rows where Status = "Pending", tracking each row number for later updates.
  2. 用 DALL·E 3 生成产品图像

    对每个待处理产品,Code 节点(AI Prompt Builder1)拼接 UGC 风格提示词,调用 OpenAI Images Generations API(model: dall-e-3, size: 1024x1024, quality: hd, style: natural)。下游 Code 节点(Extract DALL-E URL1)从响应中提取 imageUrl 并携带全部产品数据继续传递。

    运行提示词 · 来源原文。n8n Code 节点 AI Prompt Builder1 的 JS Code 字段

    // Build a UGC-style image generation prompt from product data
    const item = $input.first().json;
    
    const productName = item.productName || 'product';
    const description = item.description || '';
    const targetAudience = item.targetAudience || 'young adults';
    
    // Construct a detailed DALL-E 3 prompt with UGC aesthetic
    const prompt = [
      `A lifestyle photograph of ${productName} being used by ${targetAudience}.`,
      description ? `The product is ${description}.` : '',
      'Shot on iPhone, natural window lighting, casual home or cafe setting.',
      'UGC aesthetic: authentic, unposed, relatable feel.',
      'Warm color grading, shallow depth of field, genuine emotion.',
      'No text overlays, no logos, no watermarks.',
      'Photorealistic, editorial quality, candid moment.'
    ].filter(Boolean).join(' ');
    
    return [{
      json: {
        ...item,
        imagePrompt: prompt
      }
    }];

    运行提示词 · 来源原文。n8n HTTP Request 节点 DALL-E 3 Generate Image1 的 JSON Body 字段

    ={{ JSON.stringify({
      model: "dall-e-3",
      prompt: $json.imagePrompt,
      n: 1,
      size: "1024x1024",
      quality: "hd",
      style: "natural"
    }) }}

    运行提示词 · 来源原文。n8n Code 节点 Extract DALL-E URL1 的 JS Code 字段

    // Extract the DALL-E image URL directly and carry forward all product data
    const response = $input.first().json;
    const prevData = $('AI Prompt Builder1').first().json;
    
    const imageUrl = response.data?.[0]?.url || response.data?.[0]?.revised_url || '';
    
    if (!imageUrl) {
      throw new Error('No image URL returned from DALL-E 3: ' + JSON.stringify(response));
    }
    
    return [{
      json: {
        ...prevData,
        imageUrl: imageUrl,
        dalleRevisedPrompt: response.data?.[0]?.revised_prompt || ''
      }
    }];
  3. GPT-4 Vision 分析图像并构建 Sora 视频脚本

    HTTP Request 节点调用 GPT-4o(model: gpt-4o)进行视觉分析:system 提示词要求返回 JSON(含 mood / dominantColors / composition / lighting / subjectExpression / settingDetails / suggestedCameraMovements / emotionalTone),user 消息携带产品名与 imageUrl(detail: high)。下游 Code 节点(Parse Vision Analysis1)清洗并解析 JSON,再传入 Video Script Builder1 拼接成 Sora 优化格式的视频提示词。

    运行提示词 · 来源原文。n8n HTTP Request 节点 GPT-4 Vision Analysis1 的 JSON Body 字段

    ={{ JSON.stringify({
      model: "gpt-4o",
      messages: [
        {
          role: "system",
          content: "You are a visual analyst for UGC video production. Analyze the image and return a JSON object with these fields: mood (string), dominantColors (array of strings), composition (string describing layout), lighting (string), subjectExpression (string), settingDetails (string), suggestedCameraMovements (array of strings for video), emotionalTone (string). Be specific and cinematic in your descriptions."
        },
        {
          role: "user",
          content: [
            {
              type: "text",
              text: "Analyze this UGC product image for video production planning. Product: " + $json.productName + ". Return structured JSON only, no markdown."
            },
            {
              type: "image_url",
              image_url: {
                url: $json.imageUrl,
                detail: "high"
              }
            }
          ]
        }
      ],
      max_tokens: 1000,
      temperature: 0.3
    }) }}

    运行提示词 · 来源原文。n8n Code 节点 Parse Vision Analysis1 的 JS Code 字段

    // Parse GPT-4 Vision analysis and carry forward
    const input = $input.first().json;
    const prevData = $('Extract DALL-E URL1').first().json;
    
    const content = input?.choices?.[0]?.message?.content || '{}';
    
    let visionAnalysis;
    try {
      // Strip markdown code fences if present
      const cleaned = content.replace(/```json\n?/g, '').replace(/```\n?/g, '').trim();
      visionAnalysis = JSON.parse(cleaned);
    } catch (e) {
      // If JSON parsing fails, use raw text
      visionAnalysis = {
        mood: 'warm and authentic',
        dominantColors: ['warm tones'],
        composition: content,
        lighting: 'natural',
        subjectExpression: 'genuine',
        settingDetails: 'casual setting',
        suggestedCameraMovements: ['slow zoom in', 'pan across product'],
        emotionalTone: 'relatable'
      };
    }
    
    return [{
      json: {
        ...prevData,
        visionAnalysis: visionAnalysis
      }
    }];

    运行提示词 · 来源原文。n8n Code 节点 Video Script Builder1 的 JS Code 字段

    // Build a structured UGC video script for OpenAI Sora
    const item = $input.first().json;
    
    const product = item.productName || 'this product';
    const description = item.description || '';
    const audience = item.targetAudience || 'young adults';
    const vision = item.visionAnalysis || {};
    
    const mood = vision.mood || 'warm and authentic';
    const colors = (vision.dominantColors || ['warm tones']).join(', ');
    const lighting = vision.lighting || 'natural lighting';
    const setting = vision.settingDetails || 'casual everyday setting';
    const emotion = vision.emotionalTone || 'relatable';
    const cameraMovements = (vision.suggestedCameraMovements || ['slow zoom in']).join(', ');
    
    // Build a concise video prompt optimized for Sora
    // Sora works best with clear, descriptive scene prompts rather than screenplay-style scripts
    const videoScript = [
      `UGC-style smartphone video of ${audience} authentically using ${product} in ${setting}.`,
      description ? `The product is ${description}.` : '',
      `Visual style: ${mood} mood, ${colors} color palette, ${lighting}.`,
      `Camera: ${cameraMovements}, handheld smartphone feel.`,
      `The person picks up ${product} with genuine curiosity, uses it naturally, and reacts with authentic satisfaction.`,
      `Emotional tone: ${emotion}, relatable, candid.`,
      'Natural ambient lighting, shallow depth of field, no text overlays or logos.'
    ].filter(Boolean).join(' ');
    
    return [{
      json: {
        ...item,
        videoScript: videoScript
      }
    }];
  4. Sora 异步生成视频并轮询结果

    先 Wait 60 秒限速,再 HTTP POST 到 https://api.openai.com/v1/videos(model: sora-2, seconds: 8, size: 720x1280)。Sora 返回 job ID 而非直接 URL。Code 节点提取 videoId 后进入轮询:Wait 30 秒 → GET /v1/videos/{videoId} → Check Sora Status1 判断 isDone(status === 'completed')。最多 40 次轮询(约 20 分钟超时)。完成后 Fetch Sora Video Content1 获取视频二进制。

    运行提示词 · 来源原文。n8n HTTP Request 节点 Sora Generate Video1 的 JSON Body 字段

    ={{ JSON.stringify({
      model: "sora-2",
      prompt: $json.videoScript,
      seconds: '8',
      size: "720x1280"
    }) }}

    运行提示词 · 来源原文。n8n Code 节点 Extract Sora Job ID1 的 JS Code 字段

    const raw = $input.first().json;
    const prevData = $('Video Script Builder1').first().json;
    const response = Array.isArray(raw) ? raw[0] : raw;
    
    if (!response || !response.id) {
      throw new Error('Could not extract video job ID from Sora response: ' + JSON.stringify(raw).substring(0, 500));
    }
    
    return [{
      json: {
        productName: prevData.productName,
        description: prevData.description,
        targetAudience: prevData.targetAudience,
        sheetRowNumber: prevData.sheetRowNumber,
        imageUrl: prevData.imageUrl,
        videoId: response.id,
        videoStatus: response.status,
        progress: response.progress || 0,
        pollCount: 0
      }
    }];

    运行提示词 · 来源原文。n8n Code 节点 Check Sora Status1 的 JS Code 字段

    const raw = $input.first().json;
    const response = Array.isArray(raw) ? raw[0] : raw;
    
    // Get carried data from the job ID node
    const carried = $('Extract Sora Job ID1').first().json;
    
    const status = response.status || '';
    const progress = response.progress || 0;
    const pollCount = (carried.pollCount || 0) + 1;
    const maxPolls = 40; // 20 minutes max
    
    if (response.error) {
      throw new Error('Sora video generation failed: ' + JSON.stringify(response.error));
    }
    
    if (pollCount >= maxPolls) {
      throw new Error('Sora video generation timed out after ' + maxPolls + ' polls (20 minutes)');
    }
    
    return [{
      json: {
        productName: carried.productName,
        description: carried.description,
        targetAudience: carried.targetAudience,
        sheetRowNumber: carried.sheetRowNumber,
        imageUrl: carried.imageUrl,
        videoId: carried.videoId,
        videoStatus: status,
        progress: progress,
        pollCount: pollCount,
        isDone: status === 'completed'
      }
    }];
  5. 上传视频到 Google Drive 并回写表格

    Fetch Sora Video Content1 获取 MP4 二进制,经 Google Drive 节点上传到指定文件夹,再 HTTP POST 设置 anyone/reader 公开权限。Code 节点(Build Public Drive URL1)构造分享链接,最后 Google Sheets 节点更新对应 row_number 的 Status=Done、Image URL、Video URL 等字段。Loop Over Items 处理下一行。

    运行提示词 · 来源原文。n8n Code 节点 Build Public Drive URL1 的 JS Code 字段

    const driveFile = $('Upload Video to Google Drive1').first().json;
    const carried = $('Check Sora Status1').first().json;
    
    const fileId = driveFile.id;
    // Direct shareable link format
    const videoUrl = `https://drive.google.com/file/d/${fileId}/view?usp=sharing`;
    
    return [{
      json: {
        productName: carried.productName,
        description: carried.description,
        targetAudience: carried.targetAudience,
        sheetRowNumber: carried.sheetRowNumber,
        imageUrl: carried.imageUrl,
        videoUrl: videoUrl,
        videoId: carried.videoId,
        driveFileId: fileId
      }
    }];
  6. 配置错误处理工作流

    主工作流失败时,Error Trigger 启动错误处理流:Parse Error Details 从执行数据中提取 sheetRowNumber 与错误信息;若已知行号则更新 Google Sheets Status=Error 并写入 Error Message;否则仅日志记录。需在主工作流设置中将此工作流设为 Error Workflow。

    搭建指导 · 来源原文。n8n 错误处理工作流 Sticky Note 说明;主工作流设置中绑定 Error Workflow

    ## ERROR HANDLER WORKFLOW
    This workflow is triggered when the main UGC pipeline fails.
    It extracts the error details and row number, then updates
    the Google Sheet with Status = "Error" and the error message.
    
    SETUP: In the main workflow settings, set this workflow
    as the "Error Workflow".

可复制提示词

搭建指导 · 本站建议版本。交给搭建助手,先确认输入和权限

这一段是提示词,页面不会在这里插入广告。

你是一个 n8n 工作流搭建助手。用户希望复现「从 Google Sheets 自动生成 UGC 视频」的模板。请按以下顺序协助:1) 确认用户已拥有 n8n 实例、Google Sheets/Drive OAuth 凭证、OpenAI API Key;2) 指导导入 workflow.json 并替换硬编码的 documentId、folderId;3) 解释每个 Code 节点的输入变量与输出格式;4) 建议先用单行 Pending 数据测试,观察 DALL·E → Vision → Sora 链路是否返回预期字段;5) 提醒 Sora 访问限制与按量计费风险。不要替用户执行 API 调用。

需要 n8n 实例 + Google OAuth + OpenAI API Key;硬编码的 Sheet ID 和 Drive Folder ID 必须替换。

来源

Generate UGC product videos from Google Sheets with DALL·E, GPT-4 and Sora · vonnairone · n8n.io · 2026-03-23

留言与反馈

试过这个方法吗?分享效果、遇到的问题或改进建议。留言审核后公开,请勿填写敏感信息。

正在加载…

    相关用例