{
  "name": "壁纸工厂",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 6
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -80,
        -440
      ],
      "id": "acc9b89b-81a8-4395-acb5-aa864b988f0d",
      "name": "Schedule Trigger"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatDeepSeek",
      "typeVersion": 1,
      "position": [
        100,
        -580
      ],
      "id": "61074aa5-a7dc-4059-923b-12e3a3e1feb0",
      "name": "DeepSeek Chat Model",
      "credentials": {
        "deepSeekApi": {
          "id": "nOzz0lce9yzBED41",
          "name": "DeepSeek account 2"
        }
      }
    },
    {
      "parameters": {
        "jsonSchemaExample": "  [\n    {\n      \"name\":\"鸟语花香\",\n      \"prompt\":\"prompt1\",\n      \"motion\":\"\"\n    },\n    {\n      \"name\":\"花香\",\n      \"prompt\":\"prompt2\",\n      \"motion\":\"\"\n    },{\n      \"name\":\"鸟语\",\n      \"prompt\":\"prompt3\",\n      \"motion\":\"\"\n    }]"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.2,
      "position": [
        300,
        -580
      ],
      "id": "19fe9039-6892-49a3-835b-8211a71ef330",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -80,
        -180
      ],
      "id": "dcdb8e18-ba05-4c61-8bf1-4486246800dd",
      "name": "Loop Over Items"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.replicate.com/v1/models/black-forest-labs/flux-kontext-pro/predictions",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Prefer",
              "value": "wait"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n    \"input\": {\n      \"prompt\": \"{{ $json.prompt }}\",\n      \"aspect_ratio\": \"9:16\",\n      \"output_format\": \"png\",\n      \"safety_tolerance\": 2,\n      \"prompt_upsampling\": false\n    }\n  }",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        100,
        -180
      ],
      "id": "4c0d50ce-74f5-457b-9fee-d17dd4905023",
      "name": "flux-kontext-pro",
      "credentials": {
        "httpBearerAuth": {
          "id": "EYBcHvt7jgSZtyM6",
          "name": "replicate account"
        }
      }
    },
    {
      "parameters": {
        "operation": "write",
        "fileName": "={{ $json.stdout }}/{{ $('Loop Over Items').item.json.name }}_low.png",
        "options": {}
      },
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [
        280,
        340
      ],
      "id": "7a421067-bf5a-473f-8a5b-2e033b86921e",
      "name": "保存本地，非高清图"
    },
    {
      "parameters": {
        "url": "={{ $json.urls.get }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        440,
        -180
      ],
      "id": "c06c3bc8-403d-4280-8b12-c3a3aa48b26e",
      "name": "检查是否已经完成",
      "credentials": {
        "httpBearerAuth": {
          "id": "EYBcHvt7jgSZtyM6",
          "name": "replicate account"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "e6594b0a-fb66-463a-ab6d-ad015c9ae854",
              "leftValue": "={{ $json.status }}",
              "rightValue": "succeeded",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        620,
        -160
      ],
      "id": "f742ef71-fbf2-45a9-b6bd-1d0705b8569c",
      "name": "判断是否已经完成"
    },
    {
      "parameters": {
        "url": "={{ $('判断是否已经完成').item.json.output }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        100,
        340
      ],
      "id": "7169902c-ce73-4110-b818-7312da594396",
      "name": "下载图片",
      "credentials": {
        "httpBearerAuth": {
          "id": "EYBcHvt7jgSZtyM6",
          "name": "replicate account"
        }
      }
    },
    {
      "parameters": {
        "command": "=dir_name=\"{{ $('Loop Over Items').item.json.name }}_$(date +'%Y%m%d_%H%M%S')\"\nfull_path=\"/home/node/n8n_files/$dir_name\"\n\n[ -d \"$full_path\" ] || mkdir -p \"$full_path\"\n\necho \"$full_path\""
      },
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        -100,
        160
      ],
      "id": "69718cec-e3ee-41cb-9d5a-4267c409d4fc",
      "name": "创建下载路径"
    },
    {
      "parameters": {
        "url": "={{ $json.urls.get }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        340,
        100
      ],
      "id": "4533a032-8854-4f67-9d58-9b8531c1a8fc",
      "name": "检查高清有没有生成完",
      "credentials": {
        "httpBearerAuth": {
          "id": "EYBcHvt7jgSZtyM6",
          "name": "replicate account"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        260,
        -180
      ],
      "id": "735507fb-7a5c-4964-a866-8d8a501ecad0",
      "name": "等待5秒",
      "webhookId": "61457ca8-fd7a-40fd-876a-bc2fc3ebaf0f"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.replicate.com/v1/predictions",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Prefer",
              "value": "wait"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n    \"version\": \"nightmareai/real-esrgan:f121d640bd286e1fdc67f9799164c1d5be36ff74576ee11c803ae5b665dd46aa\",\n    \"input\": {\n      \"image\": \"{{ $('判断是否已经完成').item.json.output }}\",\n      \"scale\": 2,\n      \"face_enhance\": false\n    }\n  }",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        60,
        100
      ],
      "id": "93fc94ae-5256-44fd-85db-279396d16b09",
      "name": "将图片转成高清4k",
      "credentials": {
        "httpBearerAuth": {
          "id": "EYBcHvt7jgSZtyM6",
          "name": "replicate account"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        200,
        100
      ],
      "id": "3e408499-8838-44c9-9fe7-8e5319ebdf7a",
      "name": "等待5秒1",
      "webhookId": "a6a4e895-9129-41db-8e28-33e85490764f"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        880,
        320
      ],
      "id": "8af9de66-f1b0-416c-8728-6a1a9b6be43e",
      "name": "合并结果"
    },
    {
      "parameters": {
        "operation": "write",
        "fileName": "={{ $('创建下载路径').item.json.stdout }}/{{ $('Loop Over Items').item.json.name }}_hight.png",
        "options": {}
      },
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [
        820,
        120
      ],
      "id": "6ef6e317-f761-4243-af6e-4dc2ae3091a6",
      "name": "保存本地，高清图"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "52d42d06-3d40-4ff1-88ff-27f0a6ca751e",
              "leftValue": "={{ $json.status }}",
              "rightValue": "succeeded",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        500,
        100
      ],
      "id": "5fd9e9f8-9360-4b19-bbcd-ef766fe7126a",
      "name": "是否可以下载高清图片"
    },
    {
      "parameters": {
        "url": "={{ $('将图片转成高清4k').item.json.output }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        660,
        120
      ],
      "id": "782dc821-5798-4a1c-81a4-b972c6139a08",
      "name": "下载高清图片",
      "credentials": {
        "httpBearerAuth": {
          "id": "EYBcHvt7jgSZtyM6",
          "name": "replicate account"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1060,
        -280
      ],
      "id": "d51a3d96-4311-41fe-912b-0ecd100d0817",
      "name": "No Operation, do nothing"
    },
    {
      "parameters": {
        "content": "## 开始生成prompt\n",
        "height": 340,
        "width": 1180,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -140,
        -640
      ],
      "typeVersion": 1,
      "id": "fd9c6bf2-fdd9-458b-9659-b9ed2a5438f0",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## 将prompt生成给 文生图大模型使用",
        "height": 320,
        "width": 1180
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -140,
        -280
      ],
      "typeVersion": 1,
      "id": "667df418-480a-42ac-bb4e-083b28b78e21",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "## 保存图标到本地",
        "height": 460,
        "width": 1180,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -140,
        60
      ],
      "typeVersion": 1,
      "id": "a2b2a645-e33e-418a-9ffe-8cce9e31d0f2",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=生成10个prompt,并且每一幅不能重复,然后要为每一幅画,附上一个情绪 ",
        "hasOutputParser": true,
        "options": {
          "systemMessage": "=You are an expert AI prompt engineer that specializes in generating prompts for AI image generation tools like Midjourney or Stable Diffusion.\n\nYour task is to generate high-quality, detailed prompts for images depicting peaceful and poetic Chinese landscape or nature scenes, rendered in the style of traditional Chinese ink painting and watercolor artworks.\n\nEach prompt should describe:\n• Majestic natural elements such as towering mountains, serene rivers or lakes, cascading waterfalls, dense forests, or graceful bamboo groves.\n• A tranquil body of water (e.g., a river, lake, or pond) reflecting the surrounding scenery.\n• Diverse flora and/or fauna (e.g., ancient trees, blooming flowers, elegant birds) that harmonize with the natural environment.\n• Optional traditional Chinese structures or subtle human elements (e.g., a secluded pavilion, a humble dwelling, a small boat, an arched bridge, a lone figure contemplating) integrated seamlessly into the landscape.\n• Optional atmospheric or seasonal elements (e.g., morning mist, ethereal clouds, falling snow, vibrant autumn foliage, delicate spring blossoms, gentle rain).\n\nThe style must emphasize:\n• Chinese watercolor and ink wash painting (水墨丹青)\n• Soft, diffused lighting, delicate and flowing brush strokes, translucent washes, a rich sense of depth, and a poetic atmosphere.\n• A profound sense of tranquility, elegance, and natural simplicity.\n\nGenerate prompts in English in a single sentence, using descriptive and visual language. Do not include camera parameters or technical terms.\n\nExample: A majestic, mist-shrouded mountain range overlooking a serene, reflective lake lined with ancient pine trees and blooming lotus flowers, rendered with delicate ink washes and soft watercolor hues in a poetic Chinese landscape painting style."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2,
      "position": [
        100,
        -440
      ],
      "id": "174e1daf-5433-46ca-b1b6-e762f0fb2158",
      "name": "AI 生成提示词"
    },
    {
      "parameters": {
        "fieldToSplitOut": "output",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        420,
        -420
      ],
      "id": "9282a028-1129-40f7-abf6-43325689f5cc",
      "name": "将数据转成数组"
    },
    {
      "parameters": {
        "content": "# 🛠️ Setup Guide：n8n 壁纸工厂自动生成系统  \n**作者：** Albert\n\n通过这个流程，你可以每天自动生成多张国风 / 水墨风格的高清壁纸，并将清晰预览图用于网店展示，实现素材副业自动化。\n\n---\n\n## 📺 视频教程支持  \n查看完整构建过程：[点击跳转观看](#)（可替换为你的 YouTube 或 B 站链接）\n\n---\n\n### 💡 系统功能概览  \n📌 **自动生成 prompt → 批量调用图像大模型 → 生成高清与展示图 → 下载并本地保存。**  \n依赖 `DeepSeek Chat`, `Replicate API`, `n8n` 多个模块，构建出稳定运行的「7x24 壁纸工厂」。\n\n---\n\n## ✅ Step 1：定时触发，开始生成 prompt  \n- 使用 `Schedule Trigger` 设置每天定时启动（推荐每天 1 次）  \n- 调用 `DeepSeek Chat Model` 自动生成图像提示词（prompt）  \n- 系统提示词中内置风格约束（如“国风”、“水墨”、“浮世绘”等）  \n- 使用 `Structured Output Parser` 将模型输出转换为结构化 JSON 数据\n\n---\n\n## ✅ Step 2：将 prompt 批量发送给图像生成模型  \n- 使用 `Loop Over Items` 遍历生成的 prompt  \n- 使用 `flux-kontext-pro`（Replicate API 接口）提交绘图任务  \n- 设置延迟（5 秒），再检查状态  \n- 使用判断节点 `是否完成` 控制流程继续或重试  \n- 成功后进入下载流程\n\n---\n\n## ✅ Step 3：下载高清图与预览图并保存本地  \n- 创建本地保存路径  \n- 检查图像是否生成完成  \n- 下载高清图（展示图也可按需下载）  \n- 分别使用 `Write File to Disk` 保存到不同文件夹  \n- 最终用 `Append` 节点合并输出结果用于后续处理\n\n---\n\n## 🎯 附加说明  \n- ✅ 支持多 prompt 并行处理  \n- ✅ 输出结构清晰：高清图 + 压缩图  \n- ✅ 可对接 Notion、百度网盘、阿里云 OSS 等做扩展  \n- ✅ 图像模型、解析逻辑均可自由替换与拓展\n\n---\n\n## 📂 文件命名结构建议\n| 类型 | 示例文件名 |\n|------|--------------|\n| 高清图 | `xxx_2025-07-28_low.png` |\n| 展示图 | `xxx_2025-07-28_high.jpg` |\n\n---\n\n\n",
        "height": 1540,
        "width": 800
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        -640
      ],
      "typeVersion": 1,
      "id": "c7a7d193-f721-4962-a562-18d469642c52",
      "name": "Sticky Note4"
    }
  ],
  "pinData": {},
  "connections": {
    "DeepSeek Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI 生成提示词",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "AI 生成提示词",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI 生成提示词",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "flux-kontext-pro",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "flux-kontext-pro": {
      "main": [
        [
          {
            "node": "等待5秒",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "检查是否已经完成": {
      "main": [
        [
          {
            "node": "判断是否已经完成",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "判断是否已经完成": {
      "main": [
        [
          {
            "node": "创建下载路径",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "等待5秒",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "下载图片": {
      "main": [
        [
          {
            "node": "保存本地，非高清图",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "创建下载路径": {
      "main": [
        [
          {
            "node": "下载图片",
            "type": "main",
            "index": 0
          },
          {
            "node": "将图片转成高清4k",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "等待5秒": {
      "main": [
        [
          {
            "node": "检查是否已经完成",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "将图片转成高清4k": {
      "main": [
        [
          {
            "node": "等待5秒1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "等待5秒1": {
      "main": [
        [
          {
            "node": "检查高清有没有生成完",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "保存本地，非高清图": {
      "main": [
        [
          {
            "node": "合并结果",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "检查高清有没有生成完": {
      "main": [
        [
          {
            "node": "是否可以下载高清图片",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "保存本地，高清图": {
      "main": [
        [
          {
            "node": "合并结果",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "是否可以下载高清图片": {
      "main": [
        [
          {
            "node": "下载高清图片",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "等待5秒1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "下载高清图片": {
      "main": [
        [
          {
            "node": "保存本地，高清图",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "合并结果": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI 生成提示词": {
      "main": [
        [
          {
            "node": "将数据转成数组",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "将数据转成数组": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "No Operation, do nothing": {
      "main": [
        []
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "190032fe-f905-4a09-8b00-62d40299df76",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "ce5750bcea5ce4a182b9db86f90bac4c0366512695ec36bf86628e3e21ef4e76"
  },
  "id": "MjRxwp2junylRXWB",
  "tags": []
}