{
  "name": "YouTube Scheduler Workflow",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 10 * * *"
            }
          ]
        }
      },
      "id": "cron-trigger",
      "name": "Daily Trigger",
      "type": "n8n-nodes-base.cron",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "// Load user configurations from database/config\n// In production, fetch from Firestore or database\n\nreturn {\n  users: [\n    {\n      userId: 'user1',\n      topic: 'AI Technology',\n      scriptDuration: 60,\n      voiceSettings: {\n        languageCode: 'en-US',\n        name: 'en-US-Neural2-D',\n        speed: 1.0\n      },\n      imagesPerMinute: 3,\n      apiKeys: {\n        gemini: '$env.GEMINI_API_KEY',\n        googleTTS: '$env.GOOGLE_TTS_API_KEY'\n      }\n    }\n  ]\n};"
      },
      "id": "load-users",
      "name": "Load Active Users",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "batchSize": 1,
        "options": {}
      },
      "id": "split-users",
      "name": "Split Users",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        650,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $env.N8N_WEBHOOK_BASE_URL }}/webhook/youtube/generate",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "userId",
              "value": "={{ $json.userId }}"
            },
            {
              "name": "topic",
              "value": "={{ $json.topic }}"
            },
            {
              "name": "scriptDuration",
              "value": "={{ $json.scriptDuration }}"
            },
            {
              "name": "voiceSettings",
              "value": "={{ $json.voiceSettings }}"
            },
            {
              "name": "imagesPerMinute",
              "value": "={{ $json.imagesPerMinute }}"
            },
            {
              "name": "apiKeys",
              "value": "={{ $json.apiKeys }}"
            }
          ]
        },
        "options": {}
      },
      "id": "trigger-generation",
      "name": "Trigger Generation",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        850,
        300
      ]
    },
    {
      "parameters": {
        "amount": 5,
        "unit": "seconds"
      },
      "id": "wait-between",
      "name": "Wait Between Users",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1,
      "position": [
        1050,
        300
      ]
    }
  ],
  "connections": {
    "Daily Trigger": {
      "main": [
        [
          {
            "node": "Load Active Users",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Load Active Users": {
      "main": [
        [
          {
            "node": "Split Users",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Users": {
      "main": [
        [
          {
            "node": "Trigger Generation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger Generation": {
      "main": [
        [
          {
            "node": "Wait Between Users",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait Between Users": {
      "main": [
        [
          {
            "node": "Split Users",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [],
  "triggerCount": 1,
  "updatedAt": "2026-01-25T00:00:00.000Z",
  "versionId": "1"
}