{
  "name": "Video Automation Workflow",
  "nodes": [
    {
      "parameters": {
        "sheetId": "YOUR_SHEET_ID",
        "range": "Sheet1!A2:G",
        "options": {
          "valueRenderOption": "RAW",
          "dataReturned": "allData"
        }
      },
      "name": "Google Sheets Trigger",
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "typeVersion": 1,
      "position": [
        250,
        300
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "videoIdea",
              "value": "={{$json['Title']}}"
            },
            {
              "name": "niche",
              "value": "={{$json['Niche']}}"
            },
            {
              "name": "hashtags",
              "value": "={{$json['Hashtags']}}"
            },
            {
              "name": "videoSize",
              "value": "={{$json['Size']}}"
            },
            {
              "name": "videoLength",
              "value": "={{$json['Length']}}"
            },
            {
              "name": "platform",
              "value": "={{$json['Platform']}}"
            },
            {
              "name": "imageUrl",
              "value": "={{$json['ImageURL']}}"
            }
          ]
        }
      },
      "name": "Set Idea & Context",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "operation": "chatCompletion",
        "model": "gpt-4o-mini",
        "messages": [
          {
            "role": "system",
            "content": "You are an expert video director. Use the idea, niche, hashtags, resolution, duration, and reference image to craft a detailed AI video-generation prompt with style, camera angles, lighting, character use, and shot breakdowns."
          },
          {
            "role": "user",
            "content": "Idea: {{$json['videoIdea']}}\nNiche: {{$json['niche']}}\nHashtags: {{$json['hashtags']}}\nSize: {{$json['videoSize']}}\nLength: {{$json['videoLength']}} seconds\nReference Image: {{$json['imageUrl']}}"
          }
        ]
      },
      "name": "OpenAI - Generate Video Prompt",
      "type": "n8n-nodes-base.openai",
      "typeVersion": 1,
      "position": [
        650,
        300
      ],
      "credentials": {
        "openAIApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "videoPrompt",
              "value": "={{$json['choices'][0].message.content}}"
            }
          ]
        }
      },
      "name": "Set Video Prompt",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        850,
        300
      ]
    },
    {
      "parameters": {
        "mode": "multiple",
        "rules": [
          {
            "operation": "equals",
            "value1": "={{$json['platform'].toLowerCase()}}",
            "value2": "veo3"
          },
          {
            "operation": "equals",
            "value1": "={{$json['platform'].toLowerCase()}}",
            "value2": "synthesia"
          },
          {
            "operation": "equals",
            "value1": "={{$json['platform'].toLowerCase()}}",
            "value2": "pictory"
          },
          {
            "operation": "equals",
            "value1": "={{$json['platform'].toLowerCase()}}",
            "value2": "runway"
          },
          {
            "operation": "equals",
            "value1": "={{$json['platform'].toLowerCase()}}",
            "value2": "lumen5"
          }
        ]
      },
      "name": "Switch - Choose AI Engine",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 1,
      "position": [
        1050,
        300
      ]
    },
    {
      "parameters": {
        "authentication": "headerAuth",
        "url": "https://api.veo3.ai/v1/generate",
        "method": "POST",
        "jsonParameters": true,
        "bodyParametersJson": {
          "prompt": "={{$json['videoPrompt']}}",
          "resolution": "={{$json['videoSize']}}",
          "duration": "={{$json['videoLength']}}",
          "reference_image": "={{$json['imageUrl']}}"
        }
      },
      "name": "Veo3 - Generate Video",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1250,
        200
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "authentication": "headerAuth",
        "url": "https://api.synthesia.io/v2/videos",
        "method": "POST",
        "jsonParameters": true,
        "bodyParametersJson": {
          "script": "={{$json['videoPrompt']}}",
          "resolution": "={{$json['videoSize']}}",
          "lengthSeconds": "={{$json['videoLength']}}",
          "avatarImageUrl": "={{$json['imageUrl']}}"
        }
      },
      "name": "Synthesia - Generate Video",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1250,
        300
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "authentication": "headerAuth",
        "url": "https://api.pictory.ai/v1/create-video",
        "method": "POST",
        "jsonParameters": true,
        "bodyParametersJson": {
          "text": "={{$json['videoPrompt']}}",
          "width": "={{$split($json['videoSize'], 'x')[0]}}",
          "height": "={{$split($json['videoSize'], 'x')[1]}}",
          "duration": "={{$json['videoLength']}}",
          "styleImage": "={{$json['imageUrl']}}"
        }
      },
      "name": "Pictory - Generate Video",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1250,
        400
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "authentication": "headerAuth",
        "url": "https://api.runwayml.com/v1/generate",
        "method": "POST",
        "jsonParameters": true,
        "bodyParametersJson": {
          "prompt": "={{$json['videoPrompt']}}",
          "size": "={{$json['videoSize']}}",
          "lengthSeconds": "={{$json['videoLength']}}",
          "source_image": "={{$json['imageUrl']}}"
        }
      },
      "name": "Runway - Generate Video",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1450,
        200
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "authentication": "headerAuth",
        "url": "https://api.lumen5.com/videos",
        "method": "POST",
        "jsonParameters": true,
        "bodyParametersJson": {
          "storyboard": "={{$json['videoPrompt']}}",
          "format": "={{$json['videoSize']}}",
          "duration": "={{$json['videoLength']}}",
          "avatar": "={{$json['imageUrl']}}"
        }
      },
      "name": "Lumen5 - Generate Video",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1450,
        400
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Google Sheets Trigger": {
      "main": [
        [
          {
            "node": "Set Idea & Context",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Idea & Context": {
      "main": [
        [
          {
            "node": "OpenAI - Generate Video Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI - Generate Video Prompt": {
      "main": [
        [
          {
            "node": "Set Video Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Video Prompt": {
      "main": [
        [
          {
            "node": "Switch - Choose AI Engine",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch - Choose AI Engine": {
      "main": [
        [
          {
            "node": "Veo3 - Generate Video",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Synthesia - Generate Video",
            "type": "main",
            "index": 1
          }
        ],
        [
          {
            "node": "Pictory - Generate Video",
            "type": "main",
            "index": 2
          }
        ],
        [
          {
            "node": "Runway - Generate Video",
            "type": "main",
            "index": 3
          }
        ],
        [
          {
            "node": "Lumen5 - Generate Video",
            "type": "main",
            "index": 4
          }
        ]
      ]
    }
  }
}