{
  "name": "Vorlux AI | ComfyUI Batch Thumbnails",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "batch-thumbnails",
        "options": {
          "responseMode": "lastNode"
        }
      },
      "id": "webhook",
      "name": "Batch Thumbnail Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        220,
        300
      ]
    },
    {
      "parameters": {
        "url": "http://host.docker.internal:3010/api/blog/posts",
        "method": "GET",
        "qs": {
          "status": "published",
          "noThumbnail": "true"
        },
        "options": {
          "timeout": 15000
        }
      },
      "id": "fetch-posts",
      "name": "Fetch Posts Without Thumbnails",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const posts = $input.first().json.data || [];\nconst jobs = posts.slice(0, 10).map(p => ({\n  contentId: p.id,\n  title: p.title,\n  prompt: 'professional blog thumbnail, topic: ' + p.title + ', modern design, clean composition, 16:9 aspect ratio',\n  width: 1280,\n  height: 720\n}));\nreturn [{ json: { jobs, count: jobs.length } }];"
      },
      "id": "build-jobs",
      "name": "Build Generation Jobs",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        700,
        300
      ]
    },
    {
      "parameters": {
        "url": "http://host.docker.internal:3010/api/admin/generate-thumbnail",
        "method": "POST",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ batch: $json.jobs }) }}",
        "options": {
          "timeout": 300000
        }
      },
      "id": "generate",
      "name": "Generate Batch via ComfyUI",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        960,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{$env.DISCORD_CONTENT_WEBHOOK}}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ content: '\ud83c\udfa8 **Batch Thumbnails Generated**\\nPosts processed: ' + $('Build Generation Jobs').first().json.count }) }}"
      },
      "id": "notify",
      "name": "Discord Notify",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1200,
        300
      ]
    }
  ],
  "connections": {
    "Batch Thumbnail Webhook": {
      "main": [
        [
          {
            "node": "Fetch Posts Without Thumbnails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Posts Without Thumbnails": {
      "main": [
        [
          {
            "node": "Build Generation Jobs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Generation Jobs": {
      "main": [
        [
          {
            "node": "Generate Batch via ComfyUI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Batch via ComfyUI": {
      "main": [
        [
          {
            "node": "Discord Notify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}