{
  "name": "Vorlux AI | Sponsor Segment Manager",
  "nodes": [
    {
      "id": "17e0cbe4-6277-44e9-a317-6393398bca54",
      "name": "Trigger",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        220,
        300
      ],
      "webhookId": "3f5a6ab8-c418-4c9b-a058-4270a0fb6c00",
      "parameters": {
        "httpMethod": "POST",
        "path": "sponsor-segment",
        "options": {
          "responseMode": "lastNode"
        }
      }
    },
    {
      "id": "c9c1d294-d10b-4171-b068-8a7cc54daf84",
      "name": "Build Segment",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        460,
        300
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const d=$input.first().json.body||$input.first().json;\nreturn [{json:{sponsor:d.sponsor||'Partner',message:d.message||'',duration:d.duration||60,placement:d.placement||'mid-roll',scene:d.obsScene||'Sponsor Overlay'}}];"
      }
    },
    {
      "id": "58297de0-d79d-4818-8ba4-d7cfee437288",
      "name": "OBS Scene",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        700,
        200
      ],
      "parameters": {
        "method": "POST",
        "url": "={{$env.OBS_WEBSOCKET_URL||\"http://100.79.221.32:4455\"}}/api/scenes/switch",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"sceneName\":\"{{ $json.scene }}\",\"transitionName\":\"Stinger\"}",
        "options": {
          "timeout": 5000
        }
      }
    },
    {
      "id": "8bdb19cf-fcff-45ed-a54e-499ac325d1d1",
      "name": "Log Sponsor",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        700,
        400
      ],
      "parameters": {
        "method": "POST",
        "url": "={{$env.VORLUX_HUB_URL}}/api/broadcast/events",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"type\":\"sponsor\",\"sponsor\":\"{{ $json.sponsor }}\",\"duration\":{{ $json.duration }}}",
        "options": {
          "timeout": 10000
        }
      }
    },
    {
      "id": "b351586f-6f32-4e9d-af10-bd18b77d63cf",
      "name": "Respond",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        940,
        300
      ],
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({playing:$json.sponsor}) }}"
      }
    }
  ],
  "connections": {
    "Trigger": {
      "main": [
        [
          {
            "node": "Build Segment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Segment": {
      "main": [
        [
          {
            "node": "OBS Scene",
            "type": "main",
            "index": 0
          },
          {
            "node": "Log Sponsor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OBS Scene": {
      "main": [
        [
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Sponsor": {
      "main": [
        [
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true
  }
}