{
  "name": "Vorlux AI | YouTube Community Post",
  "active": false,
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "youtube-community-post",
        "options": { "responseMode": "lastNode" }
      },
      "id": "webhook-trigger",
      "name": "Community Post Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [220, 300]
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const data = $input.first().json.body || $input.first().json;\nconst type = data.type || 'text'; // text, poll, image\nconst content = data.content || data.text || '';\nconst pollOptions = data.pollOptions || [];\nconst imageUrl = data.imageUrl || null;\n\nreturn [{ json: { type, content, pollOptions, imageUrl, channelId: data.channelId || 'default' } }];"
      },
      "id": "format-post",
      "name": "Format Post",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [460, 300]
    },
    {
      "parameters": {
        "url": "http://host.docker.internal:3010/api/integrations/youtube",
        "method": "POST",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ action: 'community-post', type: $json.type, content: $json.content, pollOptions: $json.pollOptions, imageUrl: $json.imageUrl }) }}",
        "options": { "timeout": 30000 }
      },
      "id": "post-to-youtube",
      "name": "Post to YouTube Community",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [700, 300]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{$env.DISCORD_CONTENT_WEBHOOK}}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ content: '📢 **YouTube Community Post Published**\\nType: ' + $('Format Post').first().json.type + '\\nContent: ' + $('Format Post').first().json.content.substring(0, 100) + '...' }) }}"
      },
      "id": "discord-notify",
      "name": "Discord Notify",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [940, 300]
    }
  ],
  "connections": {
    "Community Post Webhook": { "main": [[{ "node": "Format Post", "type": "main", "index": 0 }]] },
    "Format Post": { "main": [[{ "node": "Post to YouTube Community", "type": "main", "index": 0 }]] },
    "Post to YouTube Community": { "main": [[{ "node": "Discord Notify", "type": "main", "index": 0 }]] }
  },
  "settings": { "executionOrder": "v1" }
}
