{
  "name": "Veo 3.1 \u2014 Finance Tip Auto Video (Gemini)",
  "nodes": [
    {
      "parameters": {},
      "id": "ManualTrigger",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -560,
        0
      ]
    },
    {
      "parameters": {
        "model": "gemini-1.5-pro",
        "messages": [
          {
            "role": "user",
            "content": "Write a concise 20-second script (max ~55 words) delivered in a soft, confident feminine voice giving one practical personal-finance tip. Keep it warm, non-preachy, and actionable. No emojis. Return only the spoken script, nothing else."
          }
        ],
        "simplifyOutput": true
      },
      "id": "GeminiScript",
      "name": "Gemini \u2014 Generate Script",
      "type": "n8n-nodes-base.googleGemini",
      "typeVersion": 1,
      "position": [
        -320,
        0
      ],
      "credentials": {
        "googleGeminiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "script",
              "value": "={{$json[\"message\"][0][\"content\"] || $json[\"message\"][\"content\"]}}"
            },
            {
              "name": "aspectRatio",
              "value": "9:16"
            },
            {
              "name": "durationSeconds",
              "value": "8"
            }
          ]
        }
      },
      "id": "NormalizeFields",
      "name": "Normalize Fields",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        -120,
        0
      ]
    },
    {
      "parameters": {
        "url": "https://generativelanguage.googleapis.com/v1beta/models/veo-3.1-generate-preview:predictLongRunning",
        "responseFormat": "json",
        "sendBody": true,
        "jsonParameters": true,
        "authentication": "none",
        "headerParametersJson": "{\n  \"x-goog-api-key\": \"YOUR_GEMINI_API_KEY_HERE\",\n  \"Content-Type\": \"application/json\"\n}",
        "bodyParametersJson": "{\n  \"instances\": [\n    {\n      \"prompt\": \"{{$json[\\\"script\\\"]}}\",\n      \"aspectRatio\": \"{{$json[\\\"aspectRatio\\\"]}}\",\n      \"durationSeconds\": {{$json[\"durationSeconds\"]}}\n    }\n  ],\n  \"parameters\": {\n    \"preset\": \"fast\",\n    \"negativePrompt\": \"nudity, explicit, low quality, glitch, distorted, disfigured\"\n  }\n}"
      },
      "id": "VeoCreate",
      "name": "Veo 3.1 \u2014 Create Job",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        100,
        0
      ]
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "operationName",
              "value": "={{$json[\"name\"]}}"
            },
            {
              "name": "script",
              "value": "={{$json[\"script\"]}}"
            }
          ]
        }
      },
      "id": "StoreOperation",
      "name": "Store Operation",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        300,
        0
      ]
    },
    {
      "parameters": {
        "seconds": 10
      },
      "id": "Wait10s",
      "name": "Wait 10s",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1,
      "position": [
        320,
        200
      ]
    },
    {
      "parameters": {
        "url": "={{\"https://generativelanguage.googleapis.com/v1beta/\" + $json[\"operationName\"]}}",
        "responseFormat": "json",
        "authentication": "none",
        "headerParametersJson": "{\n  \"x-goog-api-key\": \"YOUR_GEMINI_API_KEY_HERE\"\n}"
      },
      "id": "PollOperation",
      "name": "Poll Operation",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        520,
        80
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"done\"]}}",
              "operation": "equal",
              "value2": "true"
            }
          ]
        }
      },
      "id": "IfDone",
      "name": "IF done?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        720,
        80
      ]
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "videoUrl",
              "value": "={{$json[\"response\"][\"generateVideoResponse\"][\"generatedSamples\"][0][\"video\"][\"uri\"]}}"
            }
          ]
        }
      },
      "id": "ExtractURL",
      "name": "Extract Video URL",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        920,
        0
      ]
    }
  ],
  "connections": {
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Gemini \u2014 Generate Script",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini \u2014 Generate Script": {
      "main": [
        [
          {
            "node": "Normalize Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Fields": {
      "main": [
        [
          {
            "node": "Veo 3.1 \u2014 Create Job",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Veo 3.1 \u2014 Create Job": {
      "main": [
        [
          {
            "node": "Store Operation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store Operation": {
      "main": [
        [
          {
            "node": "Poll Operation",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 10s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 10s": {
      "main": [
        [
          {
            "node": "Poll Operation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Poll Operation": {
      "main": [
        [
          {
            "node": "IF done?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF done?": {
      "main": [
        [
          {
            "node": "Extract Video URL",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 10s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}