Automated UGC Video Generator

    I built a pipeline centered on Google Sheets. Simply pasting a product image link triggers a chain: 'Nano Banana' (Gemini Flash Image) analyzes the product, OpenAI drafts a motion prompt, and Veo 3.1 generates a high-fidelity 8-second video which is automatically saved to Google Drive. Impact • Turned static product photos into 8s video ads automatically • Reduced creative production costs by ~90% vs hiring creators • Zero manual editing required from input to final render

    Shared 12/5/2025

    9 views

    Visual Workflow

    JSON Code

    {
      "id": "gV5jlXSGR4IZ9Iz1",
      "meta": {
        "instanceId": "385836472bd090bc0a4be4920feadaa2165e97fb24c24504ed3bad6ead56a071",
        "templateCredsSetupCompleted": true
      },
      "name": "UGC Video Automation",
      "tags": [],
      "nodes": [
        {
          "id": "09641de1-d850-45a7-930f-f4e06f1c72cb",
          "name": "OpenAI Chat Model",
          "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
          "position": [
            -80,
            -16
          ],
          "parameters": {
            "model": {
              "__rl": true,
              "mode": "list",
              "value": "gpt-4.1-mini"
            },
            "options": {},
            "builtInTools": {}
          },
          "credentials": {
            "openAiApi": {
              "id": "vx1qMfNTGKG59YUV",
              "name": "OpenAi account"
            }
          },
          "typeVersion": 1.3
        },
        {
          "id": "8a6ab779-b9d1-4fa3-bc3d-78419b19151c",
          "name": "Wait 30s",
          "type": "n8n-nodes-base.wait",
          "position": [
            1616,
            -288
          ],
          "webhookId": "508c3d38-2dbf-42ca-a208-d37c4dbfba83",
          "parameters": {
            "amount": 30
          },
          "typeVersion": 1.1
        },
        {
          "id": "1dc163b0-7fc4-44fd-86c2-6f0ed01b70a0",
          "name": "Wait 1m",
          "type": "n8n-nodes-base.wait",
          "position": [
            832,
            160
          ],
          "webhookId": "3f60e830-0272-497b-a130-8390db421696",
          "parameters": {
            "amount": 90
          },
          "typeVersion": 1.1
        },
        {
          "id": "47532f7b-e06a-476f-856e-5bb167220ec0",
          "name": "Schedule Trigger",
          "type": "n8n-nodes-base.scheduleTrigger",
          "position": [
            -528,
            -192
          ],
          "parameters": {
            "rule": {
              "interval": [
                {
                  "triggerAtHour": 16
                }
              ]
            }
          },
          "typeVersion": 1.2
        },
        {
          "id": "41290713-079e-46bb-8770-d14b45d31612",
          "name": "Fetch Pending Tasks",
          "type": "n8n-nodes-base.googleSheets",
          "position": [
            -304,
            -192
          ],
          "parameters": {
            "options": {},
            "filtersUI": {
              "values": [
                {
                  "lookupValue": "Pending",
                  "lookupColumn": "Status"
                }
              ]
            },
            "sheetName": {
              "__rl": true,
              "mode": "list",
              "value": "gid=0",
              "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Cm8TQgOsstveuQlHdRK2P-meAxK8wgwArHee8U7nZJ0/edit#gid=0",
              "cachedResultName": "Sheet1"
            },
            "documentId": {
              "__rl": true,
              "mode": "list",
              "value": "1Cm8TQgOsstveuQlHdRK2P-meAxK8wgwArHee8U7nZJ0",
              "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Cm8TQgOsstveuQlHdRK2P-meAxK8wgwArHee8U7nZJ0/edit?usp=drivesdk",
              "cachedResultName": "UGC Video Ad Automation"
            }
          },
          "credentials": {
            "googleSheetsOAuth2Api": {
              "id": "g1V1iZZmCnSWMa4h",
              "name": "Google Sheets account"
            }
          },
          "typeVersion": 4.7
        },
        {
          "id": "3b00cf5d-da90-4402-88e7-ee98c0653437",
          "name": "Generate Image Prompt",
          "type": "@n8n/n8n-nodes-langchain.agent",
          "position": [
            -80,
            -192
          ],
          "parameters": {
            "text": "=Target Audience: {{ $json['Target Audience'] }}\nProduct Description: {{ $json['Product Description'] }}\nVideo Instructions: {{ $json['Video Instructions'] }}",
            "options": {
              "systemMessage": "You are an expert in hyper-realistic user-generated content (UGC) photography.\nYour task is to generate ONE highly detailed image-generation prompt based on the user’s inputs.\n\nYou will receive:\n- Target audience\n- Product description\n- Product image (must remain unchanged)\n- Video or scene instructions\n\nOUTPUT REQUIREMENT:\nReturn ONE complete, detailed UGC-style image-generation prompt as plain text (not an array, not JSON).\n\n---------------------------------------\nPROMPT CREATION RULES\n---------------------------------------\n\nEach image-generation prompt must include:\n\n1. HUMAN REALISM\n   - Describe a realistic human influencer with natural skin details, slight asymmetry, visible pores.\n   - Hand details: nails, grip, soft wrinkles, natural hold.\n\n2. PRODUCT ACCURACY\n   - The product must appear EXACTLY as in the provided product image.\n   - No changes, no enhancements, no reinterpretations.\n\n3. COMPOSITION & PERSPECTIVE\n   - Selfie-style framing.\n   - Product held prominently in the foreground, angled slightly toward the camera.\n   - Person’s face visible with natural eye contact.\n   - Absolutely no phones, selfie sticks, or reflections visible.\n\n4. LIGHTING & ENVIRONMENT\n   - Use user-provided setting/scene.\n   - Natural lighting (daylight or golden hour).\n   - Background slightly blurred to achieve shallow depth of field.\n\n5. AUTHENTIC UGC DETAILS\n   - Stray hairs, casual clothing, natural posture.\n   - Candid moment or natural expression.\n   - Avoid artificial or overly edited look.\n\n6. TECHNICAL STYLE\n   - Sharp focus on product + person.\n   - Cinematic shallow depth of field.\n   - Clean, realistic tones.\n\n---------------------------------------\nOUTPUT FORMAT (MANDATORY)\n---------------------------------------\n\nReturn ONLY the prompt text. No brackets, no arrays, no JSON.\n\n---------------------------------------\nSAMPLE OUTPUT\n---------------------------------------\n\nHyper-realistic selfie-style UGC photo featuring a real human influencer holding the EXACT provided product unchanged and accurate. Natural skin texture, visible pores, candid expression, and a realistic hand grip. The product is angled toward the camera in the foreground. Warm daylight fills the scene inside a cozy room. Include stray hair, casual outfit, natural posture. No phone visible. Sharp focus on product and face, softly blurred background.\n\n---------------------------------------\nEND OF SYSTEM PROMPT\n---------------------------------------"
            },
            "promptType": "define"
          },
          "typeVersion": 3
        },
        {
          "id": "4d097e1d-c1d2-4728-af8a-c026395422ba",
          "name": "Download Image Reference",
          "type": "n8n-nodes-base.httpRequest",
          "onError": "continueErrorOutput",
          "position": [
            272,
            -192
          ],
          "parameters": {
            "url": "={{ $('Fetch Pending Tasks').item.json['Product Photo'] }}",
            "options": {
              "response": {
                "response": {
                  "responseFormat": "file"
                }
              }
            }
          },
          "retryOnFail": false,
          "typeVersion": 4.3
        },
        {
          "id": "3edb39ec-f115-4ef7-9dcb-59f6861144eb",
          "name": "Convert Image to Base64",
          "type": "n8n-nodes-base.extractFromFile",
          "position": [
            496,
            -288
          ],
          "parameters": {
            "options": {},
            "operation": "binaryToPropery"
          },
          "typeVersion": 1.1
        },
        {
          "id": "d8ab7e1b-2f90-4c5f-92f0-bc1586baec75",
          "name": "Mark Task as Incompatible",
          "type": "n8n-nodes-base.googleSheets",
          "position": [
            496,
            -96
          ],
          "parameters": {
            "columns": {
              "value": {
                "Status": "Error"
              },
              "schema": [
                {
                  "id": "Product",
                  "type": "string",
                  "display": true,
                  "removed": true,
                  "required": false,
                  "displayName": "Product",
                  "defaultMatch": false,
                  "canBeUsedToMatch": true
                },
                {
                  "id": "Product Photo",
                  "type": "string",
                  "display": true,
                  "removed": true,
                  "required": false,
                  "displayName": "Product Photo",
                  "defaultMatch": false,
                  "canBeUsedToMatch": true
                },
                {
                  "id": "Target Audience",
                  "type": "string",
                  "display": true,
                  "removed": true,
                  "required": false,
                  "displayName": "Target Audience",
                  "defaultMatch": false,
                  "canBeUsedToMatch": true
                },
                {
                  "id": "Product Description",
                  "type": "string",
                  "display": true,
                  "removed": true,
                  "required": false,
                  "displayName": "Product Description",
                  "defaultMatch": false,
                  "canBeUsedToMatch": true
                },
                {
                  "id": "Video Instructions",
                  "type": "string",
                  "display": true,
                  "removed": true,
                  "required": false,
                  "displayName": "Video Instructions",
                  "defaultMatch": false,
                  "canBeUsedToMatch": true
                },
                {
                  "id": "Status",
                  "type": "string",
                  "display": true,
                  "required": false,
                  "displayName": "Status",
                  "defaultMatch": false,
                  "canBeUsedToMatch": true
                },
                {
                  "id": "UGC Video",
                  "type": "string",
                  "display": true,
                  "removed": true,
                  "required": false,
                  "displayName": "UGC Video",
                  "defaultMatch": false,
                  "canBeUsedToMatch": true
                },
                {
                  "id": "Message",
                  "type": "string",
                  "display": true,
                  "removed": true,
                  "required": false,
                  "displayName": "Message",
                  "defaultMatch": false,
                  "canBeUsedToMatch": true
                },
                {
                  "id": "row_number",
                  "type": "number",
                  "display": true,
                  "removed": true,
                  "readOnly": true,
                  "required": false,
                  "displayName": "row_number",
                  "defaultMatch": false,
                  "canBeUsedToMatch": true
                }
              ],
              "mappingMode": "defineBelow",
              "matchingColumns": [],
              "attemptToConvertTypes": false,
              "convertFieldsToString": false
            },
            "options": {},
            "operation": "update",
            "sheetName": {
              "__rl": true,
              "mode": "list",
              "value": "gid=0",
              "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Cm8TQgOsstveuQlHdRK2P-meAxK8wgwArHee8U7nZJ0/edit#gid=0",
              "cachedResultName": "Sheet1"
            },
            "documentId": {
              "__rl": true,
              "mode": "list",
              "value": "1Cm8TQgOsstveuQlHdRK2P-meAxK8wgwArHee8U7nZJ0",
              "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Cm8TQgOsstveuQlHdRK2P-meAxK8wgwArHee8U7nZJ0/edit?usp=drivesdk",
              "cachedResultName": "UGC Video Ad Automation"
            }
          },
          "credentials": {
            "googleSheetsOAuth2Api": {
              "id": "g1V1iZZmCnSWMa4h",
              "name": "Google Sheets account"
            }
          },
          "typeVersion": 4.7
        },
        {
          "id": "a67b3869-bb05-47a7-ac2a-cee99090fc2e",
          "name": "Generate Image (AI)",
          "type": "n8n-nodes-base.httpRequest",
          "position": [
            720,
            -288
          ],
          "parameters": {
            "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image:generateContent",
            "method": "POST",
            "options": {},
            "jsonBody": "={\n  \"contents\": [\n    {\n      \"parts\": [\n        {\n          \"text\": \"{{ $('Generate Image Prompt').item.json.output.replace(/\\r?\\n|\\r/g, ' ') }} Return only the generated image. No text, no captions, no explanations, no descriptions, no metadata. Your entire output must be the image itself and nothing else. If you cannot comply, output a blank image instead.\"\n        },\n        {\n          \"inline_data\": {\n            \"mime_type\": \"image/jpeg\",\n            \"data\": \"{{ $json.data }}\"\n          }\n        }\n      ]\n    }\n  ]\n}",
            "sendBody": true,
            "sendHeaders": true,
            "specifyBody": "json",
            "headerParameters": {
              "parameters": [
                {
                  "name": "x-goog-api-key",
                  "value": "AIzaSyBDuWqZL4F0IT5Arfyy8JRwVP8GToJJVzE"
                },
                {
                  "name": "Content-Type",
                  "value": "application/json"
                }
              ]
            }
          },
          "retryOnFail": false,
          "typeVersion": 4.3,
          "alwaysOutputData": true
        },
        {
          "id": "3980e779-723d-4ca8-8db7-3d4e5df734af",
          "name": "Prepare Image Payload",
          "type": "n8n-nodes-base.set",
          "position": [
            944,
            -288
          ],
          "parameters": {
            "options": {},
            "assignments": {
              "assignments": [
                {
                  "id": "c7c17fe2-3bf7-41ae-90eb-47d59ddc448e",
                  "name": "base64.data",
                  "type": "string",
                  "value": "={{ $json.candidates[0].content.parts[1]?.inlineData?.data || $json.candidates[0].content.parts[0]?.inlineData?.data }}"
                }
              ]
            }
          },
          "typeVersion": 3.4
        },
        {
          "id": "3c4d03e0-68eb-43fd-8dbe-95cd1c444cd6",
          "name": "Convert Base64 to Image File",
          "type": "n8n-nodes-base.convertToFile",
          "onError": "continueRegularOutput",
          "position": [
            1168,
            -288
          ],
          "parameters": {
            "options": {},
            "operation": "toBinary",
            "sourceProperty": "base64.data"
          },
          "typeVersion": 1.1
        },
        {
          "id": "e4b58a04-d26f-4c10-80ab-bd282b81b191",
          "name": "Upload Image to ImageBB",
          "type": "n8n-nodes-base.httpRequest",
          "position": [
            1392,
            -288
          ],
          "parameters": {
            "url": "https://api.imgbb.com/1/upload",
            "method": "POST",
            "options": {},
            "sendBody": true,
            "contentType": "multipart-form-data",
            "authentication": "genericCredentialType",
            "bodyParameters": {
              "parameters": [
                {
                  "name": "image",
                  "parameterType": "formBinaryData",
                  "inputDataFieldName": "data"
                }
              ]
            },
            "genericAuthType": "httpQueryAuth"
          },
          "credentials": {
            "httpQueryAuth": {
              "id": "H420WiQQdUggL6V5",
              "name": "ImgBB Auth"
            }
          },
          "typeVersion": 4.3
        },
        {
          "id": "17136d52-4bdf-44f7-a289-84b55b8645b6",
          "name": "Analyze Generated Image",
          "type": "@n8n/n8n-nodes-langchain.openAi",
          "maxTries": 5,
          "position": [
            1616,
            -80
          ],
          "parameters": {
            "text": "Describe what is in the image. Describe the environment and the human who is the focus of the image, as well as what the human is holding.",
            "modelId": {
              "__rl": true,
              "mode": "list",
              "value": "chatgpt-4o-latest",
              "cachedResultName": "CHATGPT-4O-LATEST"
            },
            "options": {},
            "resource": "image",
            "imageUrls": "={{ $json.data.url }}",
            "operation": "analyze"
          },
          "credentials": {
            "openAiApi": {
              "id": "vx1qMfNTGKG59YUV",
              "name": "OpenAi account"
            }
          },
          "retryOnFail": true,
          "typeVersion": 2,
          "waitBetweenTries": 5000
        },
        {
          "id": "cba348ed-dcf7-4f0d-b8b4-d13eb3bc532e",
          "name": "Generate Video Prompt",
          "type": "@n8n/n8n-nodes-langchain.agent",
          "position": [
            -400,
            160
          ],
          "parameters": {
            "text": "=Product: {{ $('Fetch Pending Tasks').item.json.Product }}\nTarget Audience: {{ $('Fetch Pending Tasks').item.json['Target Audience'] }}\nProduct Description: {{ $('Fetch Pending Tasks').item.json['Product Description'] }}\nVideo Instructions: {{ $('Fetch Pending Tasks').item.json['Video Instructions'] }}\nReference Image Description: {{ $json['0'].content[0].text }}",
            "options": {
              "systemMessage": "# System Prompt Template: UGC Selfie Video Creation (8 Seconds)\n\n## Role\nYou are an **expert UGC video creator**.  \nYour task is to **generate a prompt for an AI video model** (such as *Veo 3.1*) based on:\n- The provided **product**\n- The **ideal customer profile (ICP)**\n- **Product features**\n- **Video setting**\n- A **reference image**\n\nYour goal is to create a **realistic, selfie-style video** that appears to be **filmed by an influencer** using one hand to hold the phone and the other to hold or interact with the product. The video should feel **authentic, spontaneous, and natural**, while maintaining **visual and style consistency with the provided reference image**.  \nThe phone itself must **never appear** in the shot.\n\n---\n\n## Requirements\n\n### Subject & Framing\n- The subject is the **ideal user** (from the ICP), **holding or using the product**.\n- The video is recorded **selfie-style** with the **camera held at arm’s length** in one hand and the product in the other.\n- The subject looks directly into the lens while speaking.\n- The video is in **vertical (9:16)** orientation, suitable for TikTok or Instagram Reels.\n\n### Visual Style\n- Use **natural lighting** and **casual, realistic backgrounds** (e.g., bedroom, gym, kitchen, car, office).\n- Include **slight camera shake**, **soft grain**, and **subtle imperfections** for realism.\n- The **product**, **user’s face**, and **interaction** must remain clearly visible.\n- Ensure **no phone, camera, overlays, subtitles, or logos** appear in the frame.\n- The **appearance, colors, and style** should closely **match the provided reference image** (do not include or link the image in the output).\n\n### Tone & Dialogue\n- The subject speaks **1–2 casual, unscripted sentences** about what they personally love about the product.\n- The dialogue should sound **personal, conversational, and genuine** (e.g., “I love how [feature] makes my mornings easier.”).\n- The delivery feels **spontaneous** and **relatable**, not like a polished ad.\n\n### Technical Specs\n- **Duration:** 8 seconds  \n- **Shot Type:** Handheld, selfie-style  \n- **Lighting:** Natural and realistic  \n- **Reference Image:** Used only for **style and consistency matching** (not shown or mentioned)\n\n---\n\n## Embedded Elements in the Prompt\nWhen generating the AI video prompt, include:\n\n- **ICP Persona** → Age, gender, attire, personality, and context  \n- **Product Feature** → One standout feature being praised  \n- **Setting & Lighting** → Realistic environment and lighting cues  \n- **Camera Style** → Handheld selfie, mild shake, natural imperfections  \n- **Reference Image Consistency** → Match appearance and tone  \n- **Tone** → Real, personal, unpolished, influencer-style delivery  \n\n---\n\n## Example Output Prompt\n> “A natural selfie-style 9:16 video filmed by a young woman in a bright kitchen, holding **[Product]** in one hand and her iPhone in the other to record. She smiles at the camera and says, ‘I seriously love how [Product] fits perfectly into my morning routine—it makes breakfast so much faster.’ The product and her face are clearly visible, with natural l"
            },
            "promptType": "define"
          },
          "typeVersion": 3
        },
        {
          "id": "36a17d3c-7aa4-4411-b27a-db9acc569970",
          "name": "Prepare Video Generation Request",
          "type": "n8n-nodes-base.set",
          "position": [
            -64,
            160
          ],
          "parameters": {
            "mode": "raw",
            "options": {},
            "jsonOutput": "  {\n  \"type\": \"service_account\",\n  \"project_id\": \"stoked-producer-471209-s0\",\n  \"private_key_id\": \"95e066c3ff31f7266859d3d9df8122cc2e315c83\",\n  \"client_email\": \"ai-automation@stoked-producer-471209-s0.iam.gserviceaccount.com\",\n  \"client_id\": \"111885195129837013785\",\n  \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n  \"token_uri\": \"https://oauth2.googleapis.com/token\",\n  \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\n  \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/ai-automation%40stoked-producer-471209-s0.iam.gserviceaccount.com\",\n  \"universe_domain\": \"googleapis.com\"\n}"
          },
          "typeVersion": 3.4
        },
        {
          "id": "a0b9644f-fd1a-4c15-8bee-4a4c41eb1155",
          "name": "Generate Google API Token",
          "type": "n8n-nodes-base.jwt",
          "position": [
            160,
            160
          ],
          "parameters": {
            "options": {},
            "useJson": true,
            "claimsJson": "={\n  \"iss\": \"{{ $json.client_email }}\",\n  \"scope\": \"https://www.googleapis.com/auth/cloud-platform\",\n  \"aud\": \"https://oauth2.googleapis.com/token\",\n  \"iat\": {{ Math.floor($now.toSeconds()) }},\n  \"exp\": {{ Math.floor($now.plus({ seconds: 3600 }).toSeconds()) }}\n}"
          },
          "credentials": {
            "jwtAuth": {
              "id": "pYmW2YdmNGBs7S6I",
              "name": "JWT Auth account"
            }
          },
          "typeVersion": 1
        },
        {
          "id": "7f842fdf-fa2e-4f9c-96c5-246b7583a3dd",
          "name": "Authenticate Video API Call",
          "type": "n8n-nodes-base.httpRequest",
          "position": [
            384,
            160
          ],
          "parameters": {
            "url": "https://oauth2.googleapis.com/token",
            "method": "POST",
            "options": {},
            "sendBody": true,
            "contentType": "form-urlencoded",
            "bodyParameters": {
              "parameters": [
                {
                  "name": "grant_type",
                  "value": "urn:ietf:params:oauth:grant-type:jwt-bearer"
                },
                {
                  "name": "assertion",
                  "value": "={{ $json.token }}"
                }
              ]
            }
          },
          "typeVersion": 4.2
        },
        {
          "id": "184017f6-e775-432d-b783-fc8140119ce9",
          "name": "Submit Video Generation",
          "type": "n8n-nodes-base.httpRequest",
          "position": [
            608,
            160
          ],
          "parameters": {
            "url": "https://us-central1-aiplatform.googleapis.com/v1/projects/stoked-producer-471209-s0/locations/us-central1/publishers/google/models/veo-3.1-generate-preview:predictLongRunning",
            "method": "POST",
            "options": {},
            "jsonBody": "={\n  \"instances\": [\n    {\n      \"prompt\": \"{{ $('Generate Video Prompt').item.json.output.replace(/\\\\r?\\\\n|\\\\r/g, ' ').replace(/\\\"/g, '').replace(/[“”]/g,'') }}\",\n      \"referenceImages\": [\n        {\n          \"image\": {\n            \"bytesBase64Encoded\": \" {{ $('Prepare Image Payload').item.json.base64.data }} \",\n            \"mimeType\": \"image/jpeg\"\n          },\n          \"referenceType\": \"asset\"\n        }\n      ]\n    }\n  ],\n  \"parameters\": {\n    \"durationSeconds\": 8,\n    \"generateAudio\": true,\n    \"negativePrompt\": \"UI, overlays, captions, on-screen buttons, phone interface, subtitles, mentions\"\n  }\n}",
            "sendBody": true,
            "sendHeaders": true,
            "specifyBody": "json",
            "headerParameters": {
              "parameters": [
                {
                  "name": "Content-Type",
                  "value": "application/json"
                },
                {
                  "name": "Authorization",
                  "value": "=Bearer {{ $json.access_token }}"
                }
              ]
            }
          },
          "typeVersion": 4.2
        },
        {
          "id": "194b54aa-ea3e-4efd-b3d2-368a3d794af6",
          "name": "Check Render Status",
          "type": "n8n-nodes-base.httpRequest",
          "position": [
            1056,
            160
          ],
          "parameters": {
            "url": "https://us-central1-aiplatform.googleapis.com/v1/projects/stoked-producer-471209-s0/locations/us-central1/publishers/google/models/veo-3.1-generate-preview:fetchPredictOperation",
            "method": "POST",
            "options": {
              "response": {
                "response": {
                  "fullResponse": true
                }
              }
            },
            "sendBody": true,
            "sendHeaders": true,
            "bodyParameters": {
              "parameters": [
                {
                  "name": "operationName",
                  "value": "={{ $json.name || $json.body.name }}"
                }
              ]
            },
            "headerParameters": {
              "parameters": [
                {
                  "name": "Content-Type",
                  "value": "application/json"
                },
                {
                  "name": "Authorization",
                  "value": "=Bearer {{ $('Authenticate Video API Call').item.json.access_token }}"
                }
              ]
            }
          },
          "typeVersion": 4.2
        },
        {
          "id": "4e58349e-4bd3-4570-a331-0d7cfc238a47",
          "name": "Is Video Ready?",
          "type": "n8n-nodes-base.if",
          "position": [
            1280,
            160
          ],
          "parameters": {
            "options": {},
            "conditions": {
              "options": {
                "version": 2,
                "leftValue": "",
                "caseSensitive": true,
                "typeValidation": "strict"
              },
              "combinator": "and",
              "conditions": [
                {
                  "id": "2dffde7d-7218-4660-a9c6-e5ba4436b5f2",
                  "operator": {
                    "type": "boolean",
                    "operation": "true",
                    "singleValue": true
                  },
                  "leftValue": "={{ $json.body.done }}",
                  "rightValue": ""
                }
              ]
            }
          },
          "typeVersion": 2.2
        },
        {
          "id": "39bc0f3a-ead4-4cbf-a326-7a85533b1064",
          "name": "Handle Render Error",
          "type": "n8n-nodes-base.if",
          "position": [
            1504,
            224
          ],
          "parameters": {
            "options": {},
            "conditions": {
              "options": {
                "version": 2,
                "leftValue": "",
                "caseSensitive": true,
                "typeValidation": "strict"
              },
              "combinator": "and",
              "conditions": [
                {
                  "id": "bdbd5885-0aec-4ae1-bf06-00a5a45b4d3d",
                  "operator": {
                    "type": "boolean",
                    "operation": "notExists",
                    "singleValue": true
                  },
                  "leftValue": "={{ $json.body.response.raiMediaFilteredReasons }}",
                  "rightValue": ""
                },
                {
                  "id": "4386a0b6-5a79-44a6-b24e-2841ec02111c",
                  "operator": {
                    "type": "string",
                    "operation": "notExists",
                    "singleValue": true
                  },
                  "leftValue": "={{ $json.body.error.message }}",
                  "rightValue": ""
                }
              ]
            }
          },
          "typeVersion": 2.2
        },
        {
          "id": "95e9ebd9-e565-4f4d-bd7f-575a88018c57",
          "name": "Convert Base64 to Video File",
          "type": "n8n-nodes-base.convertToFile",
          "position": [
            1728,
            160
          ],
          "parameters": {
            "options": {},
            "operation": "toBinary",
            "sourceProperty": "body.response.videos[0].bytesBase64Encoded"
          },
          "typeVersion": 1.1
        },
        {
          "id": "4954eed2-5c03-450f-b5c3-00d113e1c290",
          "name": "Upload Final Video File",
          "type": "n8n-nodes-base.googleDrive",
          "position": [
            1952,
            160
          ],
          "parameters": {
            "name": "={{ $('Fetch Pending Tasks').item.json.Product }}",
            "driveId": {
              "__rl": true,
              "mode": "list",
              "value": "My Drive"
            },
            "options": {},
            "folderId": {
              "__rl": true,
              "mode": "list",
              "value": "1xMiEE-z5HLMim8q4qGdaTCR8CHbcOtEx",
              "cachedResultUrl": "https://drive.google.com/drive/folders/1xMiEE-z5HLMim8q4qGdaTCR8CHbcOtEx",
              "cachedResultName": "UGC Video Ads"
            }
          },
          "credentials": {
            "googleDriveOAuth2Api": {
              "id": "7lBNSZTmU4sskPet",
              "name": "Google Drive account"
            }
          },
          "typeVersion": 3
        },
        {
          "id": "043de2fe-ec67-4366-b5c9-0bb3aecb2285",
          "name": "Update Task Status",
          "type": "n8n-nodes-base.googleSheets",
          "position": [
            2176,
            160
          ],
          "parameters": {
            "columns": {
              "value": {
                "No": "",
                "Status": "Completed",
                "UGC Video": "={{ $json.webViewLink }}",
                "row_number": "={{ $('Fetch Pending Tasks').item.json.row_number }}"
              },
              "schema": [
                {
                  "id": "No",
                  "type": "string",
                  "display": true,
                  "required": false,
                  "displayName": "No",
                  "defaultMatch": false,
                  "canBeUsedToMatch": true
                },
                {
                  "id": "Product",
                  "type": "string",
                  "display": true,
                  "required": false,
                  "displayName": "Product",
                  "defaultMatch": false,
                  "canBeUsedToMatch": true
                },
                {
                  "id": "Product Photo",
                  "type": "string",
                  "display": true,
                  "required": false,
                  "displayName": "Product Photo",
                  "defaultMatch": false,
                  "canBeUsedToMatch": true
                },
                {
                  "id": "Target Audience",
                  "type": "string",
                  "display": true,
                  "required": false,
                  "displayName": "Target Audience",
                  "defaultMatch": false,
                  "canBeUsedToMatch": true
                },
                {
                  "id": "Product Description",
                  "type": "string",
                  "display": true,
                  "required": false,
                  "displayName": "Product Description",
                  "defaultMatch": false,
                  "canBeUsedToMatch": true
                },
                {
                  "id": "Video Instructions",
                  "type": "string",
                  "display": true,
                  "required": false,
                  "displayName": "Video Instructions",
                  "defaultMatch": false,
                  "canBeUsedToMatch": true
                },
                {
                  "id": "Status",
                  "type": "string",
                  "display": true,
                  "required": false,
                  "displayName": "Status",
                  "defaultMatch": false,
                  "canBeUsedToMatch": true
                },
                {
                  "id": "UGC Video",
                  "type": "string",
                  "display": true,
                  "required": false,
                  "displayName": "UGC Video",
                  "defaultMatch": false,
                  "canBeUsedToMatch": true
                },
                {
                  "id": "row_number",
                  "type": "number",
                  "display": true,
                  "removed": false,
                  "readOnly": true,
                  "required": false,
                  "displayName": "row_number",
                  "defaultMatch": false,
                  "canBeUsedToMatch": true
                }
              ],
              "mappingMode": "defineBelow",
              "matchingColumns": [
                "row_number"
              ],
              "attemptToConvertTypes": false,
              "convertFieldsToString": false
            },
            "options": {},
            "operation": "update",
            "sheetName": {
              "__rl": true,
              "mode": "list",
              "value": "gid=0",
              "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Cm8TQgOsstveuQlHdRK2P-meAxK8wgwArHee8U7nZJ0/edit#gid=0",
              "cachedResultName": "Sheet1"
            },
            "documentId": {
              "__rl": true,
              "mode": "list",
              "value": "1Cm8TQgOsstveuQlHdRK2P-meAxK8wgwArHee8U7nZJ0",
              "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Cm8TQgOsstveuQlHdRK2P-meAxK8wgwArHee8U7nZJ0/edit?usp=drivesdk",
              "cachedResultName": "UGC Video Ad Automation"
            }
          },
          "credentials": {
            "googleSheetsOAuth2Api": {
              "id": "g1V1iZZmCnSWMa4h",
              "name": "Google Sheets account"
            }
          },
          "typeVersion": 4.7
        }
      ],
      "active": true,
      "pinData": {},
      "settings": {
        "callerPolicy": "workflowsFromSameOwner",
        "errorWorkflow": "9Y40hngg1PkXFs6I",
        "availableInMCP": false,
        "executionOrder": "v1"
      },
      "versionId": "e8c43dcc-8607-49e4-a1a2-f06f374b71c0",
      "connections": {
        "Wait 1m": {
          "main": [
            [
              {
                "node": "Check Render Status",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Wait 30s": {
          "main": [
            [
              {
                "node": "Analyze Generated Image",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Is Video Ready?": {
          "main": [
            [
              {
                "node": "Handle Render Error",
                "type": "main",
                "index": 0
              }
            ],
            [
              {
                "node": "Wait 1m",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Schedule Trigger": {
          "main": [
            [
              {
                "node": "Fetch Pending Tasks",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "OpenAI Chat Model": {
          "ai_languageModel": [
            [
              {
                "node": "Generate Image Prompt",
                "type": "ai_languageModel",
                "index": 0
              },
              {
                "node": "Generate Video Prompt",
                "type": "ai_languageModel",
                "index": 0
              }
            ]
          ]
        },
        "Check Render Status": {
          "main": [
            [
              {
                "node": "Is Video Ready?",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Fetch Pending Tasks": {
          "main": [
            [
              {
                "node": "Generate Image Prompt",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Generate Image (AI)": {
          "main": [
            [
              {
                "node": "Prepare Image Payload",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Handle Render Error": {
          "main": [
            [
              {
                "node": "Convert Base64 to Video File",
                "type": "main",
                "index": 0
              }
            ],
            [
              {
                "node": "Generate Video Prompt",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Generate Image Prompt": {
          "main": [
            [
              {
                "node": "Download Image Reference",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Generate Video Prompt": {
          "main": [
            [
              {
                "node": "Prepare Video Generation Request",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Prepare Image Payload": {
          "main": [
            [
              {
                "node": "Convert Base64 to Image File",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Analyze Generated Image": {
          "main": [
            [
              {
                "node": "Generate Video Prompt",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Convert Image to Base64": {
          "main": [
            [
              {
                "node": "Generate Image (AI)",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Submit Video Generation": {
          "main": [
            [
              {
                "node": "Wait 1m",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Upload Final Video File": {
          "main": [
            [
              {
                "node": "Update Task Status",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Upload Image to ImageBB": {
          "main": [
            [
              {
                "node": "Wait 30s",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Download Image Reference": {
          "main": [
            [
              {
                "node": "Convert Image to Base64",
                "type": "main",
                "index": 0
              }
            ],
            [
              {
                "node": "Mark Task as Incompatible",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Generate Google API Token": {
          "main": [
            [
              {
                "node": "Authenticate Video API Call",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Authenticate Video API Call": {
          "main": [
            [
              {
                "node": "Submit Video Generation",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Convert Base64 to Image File": {
          "main": [
            [
              {
                "node": "Upload Image to ImageBB",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Convert Base64 to Video File": {
          "main": [
            [
              {
                "node": "Upload Final Video File",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Prepare Video Generation Request": {
          "main": [
            [
              {
                "node": "Generate Google API Token",
                "type": "main",
                "index": 0
              }
            ]
          ]
        }
      }
    }