{
  "name": "Vorlux AI | Full Video Production Pipeline",
  "nodes": [
    {
      "id": "a1d021a6-2189-49d0-84b7-b182b0344bf0",
      "name": "Trigger",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        220,
        300
      ],
      "webhookId": "4a8ffaaa-62cf-4fd9-afa5-f8924722dfa8",
      "parameters": {
        "httpMethod": "POST",
        "path": "produce-video",
        "options": {
          "responseMode": "lastNode"
        }
      }
    },
    {
      "id": "c119b40b-28b4-493b-95a7-fa0dd05a8b62",
      "name": "Parse Script",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        460,
        300
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const d=$input.first().json.body||$input.first().json;const scenes=(d.script||d.content||'').split(/^##\\s/gm).filter(Boolean).map((s,i)=>({id:i,title:s.split('\\n')[0].trim(),text:s.split('\\n').slice(1).join('\\n').trim(),prompt:'Scene illustration: '+s.split('\\n')[0].trim()+', professional, cinematic, 1920x1080'}));return [{json:{title:d.title||'Video',scenes,sceneCount:scenes.length,voice:d.voice||'paco'}}];"
      },
      "notes": "Splits script into scenes for TTS + image generation"
    },
    {
      "id": "d369fb0d-a17c-4a15-8c89-b14cb4735276",
      "name": "Generate TTS",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        700,
        200
      ],
      "parameters": {
        "method": "POST",
        "url": "={{$env.VORLUX_HUB_URL}}/api/tts/batch",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"scenes\":{{ JSON.stringify($json.scenes.map(s => ({id: s.id, text: s.text}))) }},\"voice\":\"{{ $json.voice }}\"}",
        "options": {
          "timeout": 300000
        }
      },
      "notes": "Generates TTS audio for each scene via Kokoro"
    },
    {
      "id": "9fedbcc8-34fe-4385-9d59-1ab068af6bb9",
      "name": "Generate Images",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        700,
        400
      ],
      "parameters": {
        "method": "POST",
        "url": "={{$env.VORLUX_HUB_URL}}/api/comfyui",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"workflowId\":\"video_slides\",\"inputs\":{\"scenes\":{{ JSON.stringify($json.scenes.map(s => ({prompt: s.prompt}))) }}}}",
        "options": {
          "timeout": 300000
        }
      },
      "notes": "Generates scene images via ComfyUI SDXL"
    },
    {
      "id": "99f76c90-2aee-4c8c-998e-f4727f37dc27",
      "name": "Assemble Video",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        940,
        300
      ],
      "parameters": {
        "method": "POST",
        "url": "={{$env.VORLUX_HUB_URL}}/api/video/assemble",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"title\":\"{{ $node[\"Parse Script\"].json.title }}\",\"audioFiles\":{{ JSON.stringify($node[\"Generate TTS\"].json.data?.files || []) }},\"imageFiles\":{{ JSON.stringify($node[\"Generate Images\"].json.data?.files || []) }}}",
        "options": {
          "timeout": 600000
        }
      },
      "notes": "FFmpeg assembles TTS audio + images into final MP4"
    },
    {
      "id": "af79c9de-a9b1-4226-a7f0-7253925a5cd4",
      "name": "Save & Notify",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1180,
        200
      ],
      "parameters": {
        "method": "POST",
        "url": "={{$env.DISCORD_CONTENT_WEBHOOK}}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"embeds\":[{\"title\":\"\ud83c\udfac Video Produced: {{ $node[\"Parse Script\"].json.title }}\",\"description\":\"{{ $node[\"Parse Script\"].json.sceneCount }} scenes | TTS + Images + Assembled\",\"color\":16711680}]}",
        "options": {
          "timeout": 10000
        }
      }
    },
    {
      "id": "d92a7683-ff30-4f0b-ad71-6e4bf1ac47cf",
      "name": "Respond",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1180,
        400
      ],
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ok: true, scenes: $node[\"Parse Script\"].json.sceneCount}) }}"
      }
    }
  ],
  "connections": {
    "Trigger": {
      "main": [
        [
          {
            "node": "Parse Script",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Script": {
      "main": [
        [
          {
            "node": "Generate TTS",
            "type": "main",
            "index": 0
          },
          {
            "node": "Generate Images",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate TTS": {
      "main": [
        [
          {
            "node": "Assemble Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Images": {
      "main": [
        [
          {
            "node": "Assemble Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Assemble Video": {
      "main": [
        [
          {
            "node": "Save & Notify",
            "type": "main",
            "index": 0
          },
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "saveExecutionProgress": true
  }
}