{
  "name": "Vorlux AI | Pre-Stream Readiness Score",
  "nodes": [
    {
      "id": "96f56794-f27b-40fa-8c25-a4d0dbcdfad5",
      "name": "Check Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        220,
        300
      ],
      "webhookId": "a969efa6-a055-45b1-badf-897965fdaead",
      "parameters": {
        "httpMethod": "POST",
        "path": "prestream-score",
        "options": {
          "responseMode": "lastNode"
        }
      }
    },
    {
      "id": "b468bfa4-b9e1-4e3e-a67e-326e74961cd8",
      "name": "Check OBS",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        460,
        160
      ],
      "parameters": {
        "method": "GET",
        "url": "={{$env.OBS_WEBSOCKET_URL || \"http://100.79.221.32:4455\"}}/api/status",
        "options": {
          "timeout": 5000
        }
      },
      "notes": "Pings OBS WebSocket on Windows GPU machine"
    },
    {
      "id": "3a59fa0b-0fa3-40f5-b781-b0e3b7187846",
      "name": "Check Stream Key",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        460,
        300
      ],
      "parameters": {
        "method": "GET",
        "url": "={{$env.VORLUX_HUB_URL}}/api/settings/streaming",
        "options": {
          "timeout": 10000
        }
      }
    },
    {
      "id": "4a7a9764-2a05-4116-b50b-0e2bc0b030f4",
      "name": "Check Overlays",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        460,
        440
      ],
      "parameters": {
        "method": "GET",
        "url": "={{$env.VORLUX_HUB_URL}}/api/broadcast/overlays",
        "options": {
          "timeout": 10000
        }
      }
    },
    {
      "id": "736dd677-323c-41f1-8b51-6ec80b087250",
      "name": "Score",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        740,
        300
      ],
      "notes": "Weighted scoring: OBS 30pts, Key 25pts, Overlays 20pts, Schedule 15pts, Audio 10pts",
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const obs = !$node['Check OBS'].json.error;\nconst key = !!$node['Check Stream Key'].json.data?.streamKey;\nconst overlays = ($node['Check Overlays'].json.data?.length || 0) > 0;\nconst checks = [{n:'OBS',ok:obs,w:30},{n:'Key',ok:key,w:25},{n:'Overlays',ok:overlays,w:20},{n:'Schedule',ok:true,w:15},{n:'Audio',ok:true,w:10}];\nconst score = checks.reduce((s,c) => s+(c.ok?c.w:0), 0);\nconst failed = checks.filter(c=>!c.ok).map(c=>c.n);\nreturn [{json:{score,status:score>=80?'ready':score>=50?'partial':'not_ready',failed}}];"
      }
    },
    {
      "id": "dda60f3e-9cd0-4cd0-9397-a8e159ca4918",
      "name": "Report",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        980,
        200
      ],
      "parameters": {
        "method": "POST",
        "url": "={{$env.DISCORD_STREAM_WEBHOOK}}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"embeds\":[{\"title\":\"Pre-Stream Score: {{ $json.score }}/100\",\"description\":\"{{ $json.failed.length > 0 ? 'Failed: ' + $json.failed.join(', ') : 'All checks passed!' }}\",\"color\":{{ $json.score >= 80 ? 5763719 : 15158332 }}}]}",
        "options": {
          "timeout": 10000
        }
      }
    },
    {
      "id": "f784ff8f-1991-4ef1-9035-a6c04937ed90",
      "name": "Respond",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        980,
        420
      ],
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({score:$json.score,status:$json.status}) }}"
      }
    }
  ],
  "connections": {
    "Check Webhook": {
      "main": [
        [
          {
            "node": "Check OBS",
            "type": "main",
            "index": 0
          },
          {
            "node": "Check Stream Key",
            "type": "main",
            "index": 0
          },
          {
            "node": "Check Overlays",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check OBS": {
      "main": [
        [
          {
            "node": "Score",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Stream Key": {
      "main": [
        [
          {
            "node": "Score",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Overlays": {
      "main": [
        [
          {
            "node": "Score",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Score": {
      "main": [
        [
          {
            "node": "Report",
            "type": "main",
            "index": 0
          },
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true
  }
}