{
  "name": "Vorlux AI | Live to Content Pack",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "vod-ready",
        "options": {
          "responseMode": "lastNode"
        }
      },
      "id": "webhook",
      "name": "VOD Ready Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        220,
        300
      ],
      "webhookId": "vod-ready"
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const data = $input.first().json.body || $input.first().json;\nreturn [{ json: {\n  sessionId: data.sessionId,\n  vodUrl: data.vodUrl,\n  title: data.title || 'Stream VOD',\n  duration: data.durationMinutes || 0,\n  platform: data.platform || 'twitch'\n} }];"
      },
      "id": "parse",
      "name": "Parse VOD Data",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        440,
        300
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "={{$env.VORLUX_HUB_URL}}/api/broadcast/sessions/{{ $json.sessionId }}/chapters",
        "options": {
          "timeout": 15000
        }
      },
      "id": "get-chapters",
      "name": "Get Chapters",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        660,
        200
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "={{$env.VORLUX_HUB_URL}}/api/broadcast/sessions/{{ $json.sessionId }}/transcript",
        "options": {
          "timeout": 15000
        }
      },
      "id": "get-transcript",
      "name": "Get Transcript",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        660,
        400
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const chapters = $node['Get Chapters'].json.data?.chapters || [];\nconst transcript = $node['Get Transcript'].json.data?.transcript || '';\nconst vod = $node['Parse VOD Data'].json;\nconst blogContent = `# ${vod.title}\\n\\n*Originally streamed live on ${vod.platform}*\\n\\n${transcript.substring(0, 3000)}\\n\\n## Key Moments\\n\\n${chapters.slice(0, 10).map(c => `- **${c.label}** \u2014 ${c.title}`).join('\\n')}\\n\\n---\\n*Watch the full VOD: [${vod.title}](${vod.vodUrl})*`;\nconst tweetThread = [\n  `\ud83c\udfac New content from today's stream: ${vod.title}\\n\\nKey highlights \ud83e\uddf5\ud83d\udc47`,\n  ...chapters.slice(0, 4).map((c, i) => `${i+1}/ ${c.title} (${c.label})`),\n  `Full VOD: ${vod.vodUrl}\\n\\n#Vorlux AI #ContentCreator`\n];\nconst shortClips = chapters.filter(c => c.text && c.text.length > 100).slice(0, 3).map(c => ({\n  startTime: c.timestamp,\n  endTime: c.timestamp + 60,\n  title: c.title\n}));\nreturn [{ json: { blogContent, tweetThread, shortClips, vodUrl: vod.vodUrl, sessionId: vod.sessionId, title: vod.title } }];"
      },
      "id": "generate-pack",
      "name": "Generate Content Pack",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        900,
        300
      ],
      "notes": "Creates blog post, tweet thread, and clip timestamps from VOD data"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{$env.VORLUX_HUB_URL}}/api/blog/posts",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"title\": \"{{ $json.title }}\",\n  \"content\": {{ JSON.stringify($json.blogContent) }},\n  \"category\": \"video-scripts\",\n  \"status\": \"draft\",\n  \"video_url\": \"{{ $json.vodUrl }}\"\n}",
        "options": {
          "timeout": 15000
        }
      },
      "id": "create-blog",
      "name": "Create Blog Draft",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1140,
        200
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{$env.VORLUX_HUB_URL}}/api/content/pipeline",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"action\": \"enrich\",\n  \"contentId\": \"{{ $json.sessionId }}\",\n  \"type\": \"vod-to-content\",\n  \"clips\": {{ JSON.stringify($json.shortClips) }},\n  \"tweetThread\": {{ JSON.stringify($json.tweetThread) }}\n}",
        "options": {
          "timeout": 15000
        }
      },
      "id": "queue-enrichment",
      "name": "Queue Enrichment",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1140,
        400
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ success: true, blog: 'draft_created', clips: $json.shortClips?.length || 0 }) }}"
      },
      "id": "respond",
      "name": "Respond",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1380,
        300
      ]
    }
  ],
  "connections": {
    "VOD Ready Webhook": {
      "main": [
        [
          {
            "node": "Parse VOD Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse VOD Data": {
      "main": [
        [
          {
            "node": "Get Chapters",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Transcript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Chapters": {
      "main": [
        [
          {
            "node": "Generate Content Pack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Transcript": {
      "main": [
        [
          {
            "node": "Generate Content Pack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Content Pack": {
      "main": [
        [
          {
            "node": "Create Blog Draft",
            "type": "main",
            "index": 0
          },
          {
            "node": "Queue Enrichment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Blog Draft": {
      "main": [
        [
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Queue Enrichment": {
      "main": [
        [
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true
  }
}