{
  "name": "AutoFeed: Google Sheet of topics -> AI video -> YouTube",
  "nodes": [
    {
      "parameters": {
        "content": "# Sheet of topics -> AutoFeed video -> YouTube\nEvery day at 9:00 this takes the first row whose **status** is empty, makes an AI Slideshow about its **topic**, uploads it to YouTube as a Short and writes the result back to the row.\n\n**Sheet columns:** `topic`, `status`, `video_url`, `youtube_url`\n\n## AutoFeed API key\n1. On AutoFeed.ai (Ultimate plan) open **Dashboard > API Keys** and create a key.\n2. In n8n create a **Header Auth** credential named `AutoFeed API key`:\n   - Name: `Authorization`\n   - Value: `Bearer af_live_...`\n3. Select it on every node that calls `www.autofeed.ai`.\n\nCost: 1,000 credits per 15-30 s slideshow. The idempotency key is the row number, so a retry never pays twice.",
        "height": 520,
        "width": 460,
        "color": 4
      },
      "id": "3d65f3c2-fb2c-4059-9661-e3749dde3493",
      "name": "Setup",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -520,
        -380
      ]
    },
    {
      "parameters": {
        "content": "## How the wait works\nThe create call passes `{{ $execution.resumeUrl }}` as `webhookUrl`. AutoFeed posts the finished video there and the **Wait** node resumes with it in `$json.body` (`status`, `url`, `error`).\n\nYour n8n must be reachable on public **https** (n8n Cloud is). On a local n8n, set the **Wait** node to wait 5 minutes, then add an HTTP GET to `/v1/videos/{{ id }}`, or use the AutoFeed community node with **Wait for Completion** on.\n\nA failed video is refunded automatically.",
        "height": 360,
        "width": 420,
        "color": 7
      },
      "id": "39552ab3-86bb-434d-b3ad-1c88e555ae16",
      "name": "Webhook note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        740,
        -380
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 9
            }
          ]
        }
      },
      "id": "61a76bbd-292a-4415-842d-6c47b01d77fb",
      "name": "Every day at 9:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "operation": "read",
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Sheet1"
        },
        "options": {}
      },
      "id": "90d5b53e-33dd-40af-9966-05ac7af7629c",
      "name": "Read topics",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "2555b8f2-0d1f-4f53-82fb-4ec904e380b2",
              "leftValue": "={{ $json.status }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "empty",
                "singleValue": true
              }
            },
            {
              "id": "06b0bdd7-6445-4771-ba60-66d9b10bd1e0",
              "leftValue": "={{ $json.topic }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "e666cb8c-b1a6-443f-bb37-9da289637422",
      "name": "Not done yet",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        440,
        0
      ]
    },
    {
      "parameters": {
        "maxItems": 1
      },
      "id": "f84879a7-796f-427d-a7f1-170446eab67c",
      "name": "Pick next topic",
      "type": "n8n-nodes-base.limit",
      "typeVersion": 1,
      "position": [
        660,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://www.autofeed.ai/api/v1/videos",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({\n  type: 'ai_slideshow',\n  input: {\n    category: 'Write Your Own Story',\n    topic: $json.topic,\n    duration: '15 to 30 seconds',\n    format: '9:16'\n  },\n  webhookUrl: $execution.resumeUrl,\n  idempotencyKey: 'sheet-row-' + $json.row_number\n}) }}",
        "options": {}
      },
      "id": "4b0cf7e5-5d52-4134-8a0a-d44de414d488",
      "name": "Create AutoFeed video",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        880,
        0
      ]
    },
    {
      "parameters": {
        "resume": "webhook",
        "httpMethod": "POST",
        "limitWaitTime": true,
        "limitType": "afterTimeInterval",
        "resumeAmount": 2,
        "resumeUnit": "hours",
        "options": {}
      },
      "id": "9ddfb626-8824-4ae0-885b-d9579d526a44",
      "name": "Wait for AutoFeed",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1100,
        0
      ],
      "webhookId": "c2abad31-9328-4a59-8854-d8c93ffb0d90"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "386f7ff4-5a3c-4cec-98de-ceee336c6c5a",
              "leftValue": "={{ $json.body.status }}",
              "rightValue": "completed",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "b12ee2d2-2148-49a0-8d73-9ce9e64f9e3f",
      "name": "Completed?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1320,
        0
      ]
    },
    {
      "parameters": {
        "url": "={{ $json.body.url }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "id": "36b2686f-a67e-433a-8f0a-49b785f7b860",
      "name": "Download MP4",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1540,
        -100
      ]
    },
    {
      "parameters": {
        "resource": "video",
        "operation": "upload",
        "title": "={{ $('Pick next topic').item.json.topic.slice(0, 95) }}",
        "regionCode": "US",
        "categoryId": "22",
        "binaryProperty": "data",
        "options": {
          "privacyStatus": "public",
          "description": "={{ $('Pick next topic').item.json.topic }}",
          "selfDeclaredMadeForKids": false
        }
      },
      "id": "897dada7-b45d-44b3-bfc0-5f3ec994d912",
      "name": "Upload to YouTube",
      "type": "n8n-nodes-base.youTube",
      "typeVersion": 1,
      "position": [
        1760,
        -100
      ]
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Sheet1"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "row_number": "={{ $('Pick next topic').item.json.row_number }}",
            "status": "posted",
            "video_url": "={{ $('Wait for AutoFeed').item.json.body.url }}",
            "youtube_url": "=https://www.youtube.com/shorts/{{ $json.uploadId }}"
          },
          "matchingColumns": [
            "row_number"
          ],
          "schema": [
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true,
              "removed": false,
              "readOnly": true
            },
            {
              "id": "status",
              "displayName": "status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "video_url",
              "displayName": "video_url",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "youtube_url",
              "displayName": "youtube_url",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ]
        },
        "options": {}
      },
      "id": "22e696f5-46fa-4067-b722-c544cc6b116e",
      "name": "Mark posted",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1980,
        -100
      ]
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Sheet1"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "row_number": "={{ $('Pick next topic').item.json.row_number }}",
            "status": "=failed: {{ $json.body.error || 'unknown error' }} (credits refunded)"
          },
          "matchingColumns": [
            "row_number"
          ],
          "schema": [
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true,
              "removed": false,
              "readOnly": true
            },
            {
              "id": "status",
              "displayName": "status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ]
        },
        "options": {}
      },
      "id": "a1670a06-1978-4a3b-8444-1b39b0740502",
      "name": "Mark failed",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1540,
        120
      ]
    }
  ],
  "connections": {
    "Every day at 9:00": {
      "main": [
        [
          {
            "node": "Read topics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read topics": {
      "main": [
        [
          {
            "node": "Not done yet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Not done yet": {
      "main": [
        [
          {
            "node": "Pick next topic",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pick next topic": {
      "main": [
        [
          {
            "node": "Create AutoFeed video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create AutoFeed video": {
      "main": [
        [
          {
            "node": "Wait for AutoFeed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for AutoFeed": {
      "main": [
        [
          {
            "node": "Completed?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Completed?": {
      "main": [
        [
          {
            "node": "Download MP4",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Mark failed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download MP4": {
      "main": [
        [
          {
            "node": "Upload to YouTube",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload to YouTube": {
      "main": [
        [
          {
            "node": "Mark posted",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false,
    "description": "Turns a Google Sheet of topics into one AutoFeed AI slideshow a day and posts it to YouTube Shorts."
  },
  "pinData": {},
  "tags": []
}