{
  "name": "Vuesy: sheet topic -> video -> download link",
  "nodes": [
    {
      "parameters": {
        "content": "## Vuesy: topic in a sheet -> video -> download link\n1. Credentials: **Header Auth** named `Vuesy API key` (Name `Authorization`, Value `Bearer vuesy_...`) and your **Google Sheets** account.\n2. In the three Google Sheets nodes pick your sheet. Columns: `topic`, `channel_url`, `script`, `title`, `status`, `video_id`, `download_url`, `error`, `voice`.\n3. Each run takes the first row with an empty status. A row with a script goes straight to a video; a row with only a topic (and a `channel_url` for the style) gets an AI script first.\nIf the API refuses a row (no credits, limits...) the row gets status `failed` and the reason in `error`: clear `status` to try it again.\nDocs: https://vuesy.dev/docs/api.html",
        "height": 300,
        "width": 520
      },
      "id": "b81b7fb9-488a-564d-a5d8-0c355ee04e1e",
      "name": "Read me",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        -40
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 15
            }
          ]
        }
      },
      "id": "c1f30951-25ff-58ca-b42d-7aef4da4d571",
      "name": "Every 15 minutes",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        300
      ]
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID/edit",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1"
        },
        "options": {}
      },
      "id": "99c8463b-883d-5c15-a2ca-8dd6cdd31149",
      "name": "Read sheet",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        220,
        300
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "gSheetsCred01",
          "name": "Google Sheets account"
        }
      },
      "alwaysOutputData": false
    },
    {
      "parameters": {
        "jsCode": "// One row per run: the first row with a topic or a script and an empty status\nconst row = $input.all().find(i => !String(i.json.status || '').trim() &&\n  (String(i.json.topic || '').trim() || String(i.json.script || '').trim()));\nreturn row ? [row] : [];"
      },
      "id": "e49956d7-7495-56eb-90ee-4b9d30c5c26b",
      "name": "Next new row",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        440,
        300
      ]
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID/edit",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "row_number": "={{ $('Next new row').first().json.row_number }}",
            "status": "working"
          },
          "matchingColumns": [
            "row_number"
          ],
          "schema": [
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "topic",
              "displayName": "topic",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "channel_url",
              "displayName": "channel_url",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "script",
              "displayName": "script",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "title",
              "displayName": "title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "displayName": "status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "video_id",
              "displayName": "video_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "download_url",
              "displayName": "download_url",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "error",
              "displayName": "error",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "voice",
              "displayName": "voice",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ]
        },
        "options": {}
      },
      "id": "21b8a835-58d0-5d5f-9931-0e2d1e0be64d",
      "name": "Mark row: working",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        660,
        300
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "gSheetsCred01",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "8466f8df-0b07-5ee1-90c7-57fe02306fbc",
              "leftValue": "={{ $('Next new row').first().json.script }}",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "baf2d1f9-6877-511a-bc0a-7b39eaf30f54",
      "name": "Has script?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        880,
        300
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "5b8240b3-0b35-5374-8ee3-0b4754d7c931",
              "name": "script",
              "value": "={{ $('Next new row').first().json.script }}",
              "type": "string"
            },
            {
              "id": "cad121b9-600a-51c9-836e-9cd6c34e150a",
              "name": "title",
              "value": "={{ $('Next new row').first().json.title || $('Next new row').first().json.topic || 'Vuesy video' }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "1712b259-eb43-5480-b99b-4e118f185d52",
      "name": "Use sheet script",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1100,
        200
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://vuesy.dev/v1/scripts",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {
          "timeout": 60000
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Idempotency-Key",
              "value": "={{ 'n8n-script-' + $('Next new row').first().json.row_number + '-' + Math.abs([...String(($('Next new row').first().json.topic || '') + ($('Next new row').first().json.channel_url || '') + '|' + ($('Next new row').first().json.error || ''))].reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 7)).toString(36) }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ channel_url: $('Next new row').first().json.channel_url, topic: $('Next new row').first().json.topic, minutes: 2 }) }}"
      },
      "id": "1fabf396-eba7-57a4-8604-c21407663eac",
      "name": "Write script (AI)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1100,
        440
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "gmApiKeyCred01",
          "name": "Vuesy API key"
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000,
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "amount": 20
      },
      "id": "2f1e26a4-f459-5917-9610-19e8e1282527",
      "name": "Wait for script",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1320,
        440
      ],
      "webhookId": "4ea1edbd-f51d-5405-9c25-3cb07aaacddf"
    },
    {
      "parameters": {
        "method": "GET",
        "url": "=https://vuesy.dev/v1/scripts/{{ $('Write script (AI)').first().json.id }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {
          "timeout": 60000
        }
      },
      "id": "c9625449-d82c-56b1-a82f-464dc1ede811",
      "name": "Get script",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1540,
        440
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "gmApiKeyCred01",
          "name": "Vuesy API key"
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000,
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "ec2c746b-b230-5fb9-9904-98ced3158c6d",
              "leftValue": "={{ $json.status }}",
              "rightValue": "running",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "32ac875f-cac8-5020-bddf-679ac63116e2",
      "name": "Script still running?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        1760,
        440
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "9f258b74-e82f-5afc-94dd-42b9f84056d2",
              "name": "script",
              "value": "={{ $json.result.script }}",
              "type": "string"
            },
            {
              "id": "350fdb2d-83dc-5572-8e4d-dedba8a2d432",
              "name": "title",
              "value": "={{ $('Next new row').first().json.title || $json.result.title }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "a491965a-cc80-5afa-ac0d-6defdd5f484b",
      "name": "Use AI script",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1980,
        460
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://vuesy.dev/v1/videos",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {
          "timeout": 60000
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Idempotency-Key",
              "value": "={{ 'n8n-video-' + $('Next new row').first().json.row_number + '-' + Math.abs([...String($json.script + '|' + $json.title + '|' + ($('Next new row').first().json.voice || '') + '|' + ($('Next new row').first().json.error || ''))].reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 7)).toString(36) }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ script: $json.script, title: $json.title.slice(0, 150), voice: String($('Next new row').first().json.voice || '').trim() }) }}"
      },
      "id": "242f14ca-f09c-507e-b96f-92abb3f6aaab",
      "name": "Create video",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2200,
        300
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "gmApiKeyCred01",
          "name": "Vuesy API key"
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000,
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "amount": 30
      },
      "id": "747eadc5-71d5-53f4-9e8b-b105f40b01b0",
      "name": "Wait for video",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        2420,
        300
      ],
      "webhookId": "2448b1df-4c02-51f4-8dcd-5bf12bf49c89"
    },
    {
      "parameters": {
        "method": "GET",
        "url": "=https://vuesy.dev/v1/videos/{{ $('Create video').first().json.id }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {
          "timeout": 60000
        }
      },
      "id": "71a5c609-ffc5-57ec-89e8-c14ac9352b94",
      "name": "Get video",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2640,
        300
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "gmApiKeyCred01",
          "name": "Vuesy API key"
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000,
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "7de74875-938f-5b48-8942-029d6f62ca00",
              "leftValue": "={{ ['queued', 'running'].includes($json.status) }}",
              "rightValue": "true",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "25415d6c-e559-5e39-83d9-d9fe1c9607aa",
      "name": "Video still rendering?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        2860,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "c4c9f4a8-55d0-5ca9-9a22-937829546c13",
              "leftValue": "={{ $json.status }}",
              "rightValue": "succeeded",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "4444ea5d-90b7-53d6-91c2-af29ad92e91d",
      "name": "Video ready?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        3080,
        320
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://vuesy.dev/v1/videos/{{ $('Create video').first().json.id }}/export",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {
          "timeout": 60000
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Idempotency-Key",
              "value": "={{ 'n8n-export-' + $('Create video').first().json.id }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ quality: 'medium' }) }}"
      },
      "id": "5b9e5617-5109-518f-8e42-3592e74a1f0f",
      "name": "Export MP4",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        3300,
        220
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "gmApiKeyCred01",
          "name": "Vuesy API key"
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000,
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "amount": 20
      },
      "id": "20b302c6-9b87-5904-b598-e28216854ff3",
      "name": "Wait for export",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        3520,
        220
      ],
      "webhookId": "7b67436e-eb4a-579b-afe6-63ff0961d969"
    },
    {
      "parameters": {
        "method": "GET",
        "url": "=https://vuesy.dev/v1/exports/{{ $('Export MP4').first().json.id }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {
          "timeout": 60000
        }
      },
      "id": "6dc61e29-34ee-5519-8670-1d2f142cb890",
      "name": "Get export",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        3740,
        220
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "gmApiKeyCred01",
          "name": "Vuesy API key"
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000,
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "4f13bd59-5fb3-529e-b07e-b87c2f18cfd1",
              "leftValue": "={{ ['queued', 'running'].includes($json.status) }}",
              "rightValue": "true",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "a6fa6ffc-1b63-5dd2-a0b8-43e26d1d7d79",
      "name": "Export still rendering?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        3960,
        220
      ]
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID/edit",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "row_number": "={{ $('Next new row').first().json.row_number }}",
            "status": "={{ $json.status === 'succeeded' ? 'done' : 'failed' }}",
            "video_id": "={{ $('Create video').first().json.id }}",
            "download_url": "={{ $json.download_url || '' }}",
            "error": "={{ $json.error || '' }}"
          },
          "matchingColumns": [
            "row_number"
          ],
          "schema": [
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "topic",
              "displayName": "topic",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "channel_url",
              "displayName": "channel_url",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "script",
              "displayName": "script",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "title",
              "displayName": "title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "displayName": "status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "video_id",
              "displayName": "video_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "download_url",
              "displayName": "download_url",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "error",
              "displayName": "error",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "voice",
              "displayName": "voice",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ]
        },
        "options": {}
      },
      "id": "4d2f2f80-51ab-591a-a3e1-254668d7d8df",
      "name": "Write download link",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        4180,
        240
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "gSheetsCred01",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID/edit",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "row_number": "={{ $('Next new row').first().json.row_number }}",
            "status": "failed",
            "error": "={{ String(($json.error && ($json.error.description || $json.error.message)) || $json.error || 'API error').slice(0, 300) }}"
          },
          "matchingColumns": [
            "row_number"
          ],
          "schema": [
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "topic",
              "displayName": "topic",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "channel_url",
              "displayName": "channel_url",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "script",
              "displayName": "script",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "title",
              "displayName": "title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "displayName": "status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "video_id",
              "displayName": "video_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "download_url",
              "displayName": "download_url",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "error",
              "displayName": "error",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "voice",
              "displayName": "voice",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ]
        },
        "options": {}
      },
      "id": "980ad2c7-478a-5e73-a8a1-d4f01d36139d",
      "name": "Write API error",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        2420,
        640
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "gSheetsCred01",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID/edit",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "row_number": "={{ $('Next new row').first().json.row_number }}",
            "status": "failed",
            "video_id": "={{ $json.id }}",
            "error": "={{ $json.error || $json.status }}"
          },
          "matchingColumns": [
            "row_number"
          ],
          "schema": [
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "topic",
              "displayName": "topic",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "channel_url",
              "displayName": "channel_url",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "script",
              "displayName": "script",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "title",
              "displayName": "title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "displayName": "status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "video_id",
              "displayName": "video_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "download_url",
              "displayName": "download_url",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "error",
              "displayName": "error",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "voice",
              "displayName": "voice",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ]
        },
        "options": {}
      },
      "id": "f93aa951-70ba-57ce-9f8f-f639277ba4f9",
      "name": "Write video error",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        3300,
        440
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "gSheetsCred01",
          "name": "Google Sheets account"
        }
      }
    }
  ],
  "connections": {
    "Every 15 minutes": {
      "main": [
        [
          {
            "node": "Read sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read sheet": {
      "main": [
        [
          {
            "node": "Next new row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Next new row": {
      "main": [
        [
          {
            "node": "Mark row: working",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mark row: working": {
      "main": [
        [
          {
            "node": "Has script?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has script?": {
      "main": [
        [
          {
            "node": "Use sheet script",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Write script (AI)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Use sheet script": {
      "main": [
        [
          {
            "node": "Create video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write script (AI)": {
      "main": [
        [
          {
            "node": "Wait for script",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Write API error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for script": {
      "main": [
        [
          {
            "node": "Get script",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get script": {
      "main": [
        [
          {
            "node": "Script still running?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Write API error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Script still running?": {
      "main": [
        [
          {
            "node": "Wait for script",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Use AI script",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Use AI script": {
      "main": [
        [
          {
            "node": "Create video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create video": {
      "main": [
        [
          {
            "node": "Wait for video",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Write API error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for video": {
      "main": [
        [
          {
            "node": "Get video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get video": {
      "main": [
        [
          {
            "node": "Video still rendering?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Write API error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Video still rendering?": {
      "main": [
        [
          {
            "node": "Wait for video",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Video ready?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Video ready?": {
      "main": [
        [
          {
            "node": "Export MP4",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Write video error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Export MP4": {
      "main": [
        [
          {
            "node": "Wait for export",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Write API error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for export": {
      "main": [
        [
          {
            "node": "Get export",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get export": {
      "main": [
        [
          {
            "node": "Export still rendering?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Write API error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Export still rendering?": {
      "main": [
        [
          {
            "node": "Wait for export",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Write download link",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "active": false,
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "pinData": {},
  "tags": []
}
