8
n8n 中文网amn8n.com

使用MagicHour进行AI图像生成

高级

这是一个自动化工作流,包含 25 个节点。主要使用 If, Set, Wait, Webhook, HttpRequest 等节点。 自动化AI媒体创作,使用MagicHour AI和GPT-4提示优化

前置要求
  • HTTP Webhook 端点(n8n 会自动生成)
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key

分类

-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "PwD9bKQiuu5Rtufl",
  "meta": {
    "instanceId": "3c35a703d75886d08705c211ee107a7513430dd05494ec0c569f28570a3768fa",
    "templateCredsSetupCompleted": true
  },
  "name": "使用 MagicHour 进行 AI 图像生成",
  "tags": [],
  "nodes": [
    {
      "id": "f00a60e4-3025-4561-8e82-a737b69ce1e6",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -2208,
        -960
      ],
      "webhookId": "316b0cb8-1699-400b-a68b-97311bef3c17",
      "parameters": {
        "path": "generate-image",
        "options": {
          "allowedOrigins": "*"
        },
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2.1
    },
    {
      "id": "6ee2c66f-5cb2-43ca-9cae-c73bb908d1fb",
      "name": "生成图像提示词",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        -1344,
        -1232
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1",
          "cachedResultName": "GPT-4.1"
        },
        "options": {
          "topP": 1,
          "temperature": 0.5
        },
        "messages": {
          "values": [
            {
              "content": "=Generate a comprehensive and detailed image generation prompt from {{ $json.body.prompt }} for AI image generation model as input. Use the following information:\n\n**Subject**: AI generated\n**Image Count**: {{ $json.body.parameters.image_count }}\n**Orientation**: {{ $json.body.parameters.orientation }}\n**Style**: {{ $json.body.parameters.style.tool }}"
            },
            {
              "role": "system",
              "content": "=## Purpose\nYou are a prompt-generation agent. Your task is to convert structured user input into a clean, descriptive prompt suitable for text-to-image generation models (e.g., RunwayML, Stability AI, Midjourney). You do not generate images yourself. You must never invent or infer content beyond what is explicitly provided.\n\n---\n\n## Generate Subject\n- **Subject**: \n  - **ANALYZE** the user prompt carefully to create a subject. Make sure the subject is precisely inline with user expectation and their tone. \n\n## Generate Characters\n- **Character list**: \n  - Create a character list based on their roles in the user prompt\n  - Create authentic appearance, clothing when any religious prompt is provided\n\n## Output Requirements\n- Generate a **non-empty prompt** that is **≤1000 characters**, measured in UTF-16 code units.\n- The prompt must be:\n  - Grammatically correct\n  - Visually descriptive\n  - Free of filler, emotional tone, or interpretation unless explicitly provided\n  - Strictly limited to elements present in the input\n  - NO USE OF \"\". ONLY use ''\n\n---\n\n## Input Expectations\nYou will receive structured input containing:\n- **Style**: visual style (e.g., realistic, cinematic, flat vector, watercolor)\n- **Scene details**: setting, objects, characters\n- **Text overlays** (if any): exact wording and placementl\n- **Aspect ratio or dimensions** (optional)\n\nIf any required field is missing or ambiguous, you must request clarification. Do not guess or proceed with assumptions.\n\n---\n\n## Prompt Format\nProduce a single prompt string suitable for direct use in a text-to-image API. Example:\n\n> \"A realistic portrait of a Sikh man in traditional attire standing in front of the Golden Temple at sunrise, with soft lighting and warm tones. No text overlay.\"\n\n---\n\n## Constraints\n- Do **not** add characters, objects, settings, or styles not present in the input.\n- Do **not** infer emotional tone, symbolism, or narrative unless explicitly described.\n- Do **not** include fantasy, surreal, or fictional elements unless requested.\n- Do **not** include political figures, celebrities, or religious icons unless authorized.\n- Do **not** exceed 500 UTF-16 characters under any circumstance.\n- Do **not** use double quotes. Output should be JSON compatible\n\n\n---\n\n## Character Control\n- Only include characters listed in the input.\n- Do **not** invent names, faces, roles, or behaviors.\n- If a character is referenced without description, request clarification.\n\n---\n\n## Typography & Text Rules\n- Use only text explicitly provided.\n- Do **not** add slogans, captions, or labels unless specified.\n- Font style, size, color, and placement must match instructions.\n\n---\n\n## Clarification Logic\nIf the input is vague, contradictory, or incomplete:\n- **Pause prompt generation**\n- **Respond with a clarification request**\n- Do **not** guess or proceed with assumptions\n\n---\n\n## Integration Notes\n- Designed for use in automated workflows (e.g., n8n, Zapier, API pipelines)\n- Output is a single prompt string for downstream image generation\n- Compatible with models that accept natural language input and enforce character limits (e.g., RunwayML, Stability AI)\n"
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "PzzLblAykQPFIDZf",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "c623f5ca-8b61-471f-958a-fe631a344af1",
      "name": "响应 Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1216,
        -976
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.4
    },
    {
      "id": "941f585d-52aa-4a34-bf38-04c7a6c8c3fe",
      "name": "如果",
      "type": "n8n-nodes-base.if",
      "position": [
        -1920,
        -1104
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "08c86a8b-f2a8-4a5d-99a3-dc1079267c87",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.body.type }}",
              "rightValue": "image"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "cb6e7ecb-a20e-40b1-9c98-dd1cd788a560",
      "name": "等待",
      "type": "n8n-nodes-base.wait",
      "position": [
        16,
        -1216
      ],
      "webhookId": "9835fad4-06fc-4e09-9595-0c6f5ad59283",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "0a9dc79f-32b5-4ca6-a4f1-beb656b3acc6",
      "name": "获取图像详情",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        256,
        -1136
      ],
      "parameters": {
        "url": "=https://api.magichour.ai/v1/image-projects/{{ $('ai-image-generator').item.json.id }}",
        "options": {},
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "accept",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpBearerAuth": {
          "id": "bGXAPcjNHEGxQCF1",
          "name": "MagicHour AI"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "6c753ca8-98c1-4a8a-9e04-6d69094d731b",
      "name": "如果1",
      "type": "n8n-nodes-base.if",
      "position": [
        544,
        -1136
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "e240e5dc-6bdf-47a3-85c4-098b5e3235fc",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "complete"
            },
            {
              "id": "cfeb1810-471d-438a-ad2c-f2bf14124616",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "error"
            },
            {
              "id": "5b001186-3156-4f1a-bc59-7e55c51d83ff",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "cancelled"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "c1d25e83-a30a-4f2d-84cf-d4a6a86e646b",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -16,
        -1568
      ],
      "parameters": {
        "width": 416,
        "height": 576,
        "content": "## 图像可能处于以下状态之一"
      },
      "typeVersion": 1
    },
    {
      "id": "deb09fda-0660-4c02-a3cc-1c022bf44b9e",
      "name": "If2",
      "type": "n8n-nodes-base.if",
      "position": [
        -640,
        -960
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "19a5f814-1943-49b7-97b6-e0af31eee57b",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.id }}",
              "rightValue": ""
            },
            {
              "id": "deea2b1d-a20d-4a8f-911c-02518bcad2ad",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $json.credits_charged }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "f4c83f1a-e23c-496c-8594-6f4d2301798d",
      "name": "下载图片",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        832,
        -1152
      ],
      "parameters": {
        "url": "={{ $json.downloads[0].url }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "dfdccb9b-0ee4-42ea-adb7-0ebc652efe9f",
      "name": "生成视频提示词",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        -1360,
        -704
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1",
          "cachedResultName": "GPT-4.1"
        },
        "options": {
          "topP": 1,
          "temperature": 0.6
        },
        "messages": {
          "values": [
            {
              "content": "=Generate a comprehensive and detailed video generation prompt from {{ $json.body.prompt }} for AI image generation model as input. Use the following information:\n\n**Subject**: AI generated\n**Duration**: {{ $json.body.parameters.end_seconds }}\n**Orientation**: {{ $json.body.parameters.orientation }}\n**Resolution**: {{ $json.body.parameters.resolution }}"
            },
            {
              "role": "system",
              "content": "=## 🔹 Purpose\nYou are a prompt-generation agent. Your task is to convert minimal or structured user input into a clean, descriptive prompt suitable for text-to-video generation models (e.g., RunwayML Gen-2, Pika, Luma). You do not generate videos yourself. You must never invent characters, narrative arcs, or symbolic meaning beyond what is explicitly provided or reasonably inferred.\n\n---\n\n## 🔹 Output Requirements\n- Generate a **non-empty**, grammatically correct prompt string\n- Output must be **≤1000 UTF-16 characters**\n- Prompt must be:\n  - Visually descriptive\n  - Free of emotional tone or interpretation unless specified\n  - Strictly limited to elements provided or inferred from context\n  - Suitable for direct use in a text-to-video API\n\n---\n\n## 🔹 Input Expectations\nYou may receive minimal or structured input containing:\n- **Subject or concept** (e.g., “two world leaders playing chess”)\n- **Duration** (e.g., 5 seconds)\n- **Style** (e.g., realistic, cinematic, animated)\n- **Optional details**:\n  - Characters\n  - Setting\n  - Scene breakdown\n  - Audio/narration\n  - Text overlays\n  - End frame instructions\n\n---\n\n## 🔹 Default Handling Logic\nIf specific details are missing, apply the following default assumptions:\n\n- **Characters**: Represent as generic silhouettes or neutral figures unless described\n- **Setting**: Default to a neutral indoor space with soft lighting\n- **Scene Breakdown**: Use a single continuous shot with minimal movement\n- **Audio/Narration**: Assume silence unless ambient sound or narration is specified\n- **Text Overlays**: Assume no text unless explicitly requested\n- **Transitions**: Use hard cuts or static framing unless otherwise described\n\n---\n\n## 🔹 Output Format\nProduce a single prompt string. Example:\n\n> \"A 5-second cinematic video showing two silhouetted world leaders seated across a chessboard in a dimly lit formal room. One leader makes a move while the other watches intently. The camera remains static. No narration or text overlay.\"\n\n---\n\n## 🔹 Constraints\n- Do **not** add characters, symbols, or narrative elements not present or implied\n- Do **not** infer emotional tone, symbolism, or political meaning\n- Do **not** include fantasy, surreal, or fictional content unless requested\n- Do **not** include political figures, celebrities, or religious icons unless authorized\n\n---\n\n## 🔹 Clarification Logic\nIf the input is contradictory or dangerously vague:\n- **Pause prompt generation**\n- **Respond with a clarification request**\n- Do **not** guess or proceed with assumptions that could misrepresent intent\n\n---\n\n## 🔹 Integration Notes\n- Designed for use in automated workflows (e.g., n8n, Zapier, API pipelines)\n- Output is a single prompt string for downstream video generation\n- Compatible with models that accept natural language input and enforce character limits\n"
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "PzzLblAykQPFIDZf",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "a18904cc-6f73-494c-903a-8b074159218d",
      "name": "编辑字段2",
      "type": "n8n-nodes-base.set",
      "position": [
        -1568,
        -688
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "3e45a85a-be16-480c-8ce9-f9fe7ae07ba5",
              "name": "body.prompt",
              "type": "string",
              "value": "={{ $('Webhook').item.json.body.parameters.style.prompt }}"
            },
            {
              "id": "d1742fce-32ae-4d00-940b-7a6e341f90f7",
              "name": "body.parameters.name",
              "type": "string",
              "value": "={{ $('Webhook').item.json.body.parameters.name }}"
            },
            {
              "id": "b32892cc-7b6b-4ad7-a24f-27e93bc99364",
              "name": "body.parameters.end_seconds",
              "type": "number",
              "value": "={{ $('Webhook').item.json.body.parameters.end_seconds }}"
            },
            {
              "id": "69b8e6de-23dd-4fd1-b31c-a63fbf52b6c9",
              "name": "body.parameters.orientation",
              "type": "string",
              "value": "={{ $('Webhook').item.json.body.parameters.orientation }}"
            },
            {
              "id": "6e6c76ad-a508-497c-9e35-66f0aa0798a9",
              "name": "body.parameters.resolution",
              "type": "string",
              "value": "={{ $('Webhook').item.json.body.parameters.resolution }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "56c92629-de44-455a-bdea-a8af21a436f3",
      "name": "从 Webhook 获取数据",
      "type": "n8n-nodes-base.set",
      "position": [
        -1568,
        -1232
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "3e45a85a-be16-480c-8ce9-f9fe7ae07ba5",
              "name": "body.prompt",
              "type": "string",
              "value": "={{ $json.body.parameters.style.prompt }}"
            },
            {
              "id": "4c8bbfdd-15e9-4e4b-8d85-2c3ed5048738",
              "name": "body.parameters.style.tool",
              "type": "string",
              "value": "={{ $json.body.parameters.style.tool }}"
            },
            {
              "id": "e75c66ce-03a8-486b-a761-a362e2a0236f",
              "name": "body.parameters.name",
              "type": "string",
              "value": "={{ $json.body.parameters.name }}"
            },
            {
              "id": "93503d53-a707-406c-81c2-5062b06391b6",
              "name": "body.parameters.image_count",
              "type": "number",
              "value": "={{ $json.body.parameters.image_count }}"
            },
            {
              "id": "5a10f233-78cb-4b87-b3cd-61f087f947ff",
              "name": "body.parameters.orientation",
              "type": "string",
              "value": "={{ $json.body.parameters.orientation }}"
            },
            {
              "id": "909e57e2-5fa4-4647-94ec-7143be75062f",
              "name": "body.type",
              "type": "string",
              "value": "={{ $json.body.type }}"
            },
            {
              "id": "6271c772-a93a-4495-af5b-694e23483d79",
              "name": "body.action",
              "type": "string",
              "value": "={{ $json.body.action }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "33d63aeb-a2ad-4828-ac5a-43fac9794aac",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1104,
        -1600
      ],
      "parameters": {
        "width": 384,
        "height": 592,
        "content": "## POST 请求"
      },
      "typeVersion": 1
    },
    {
      "id": "424e2d3a-93dc-4415-963b-f10f1fdbe092",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        736,
        -1376
      ],
      "parameters": {
        "width": 336,
        "height": 832,
        "content": "## GET 请求"
      },
      "typeVersion": 1
    },
    {
      "id": "27979d9b-1e87-4777-b935-175d58acdf31",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1104,
        -960
      ],
      "parameters": {
        "width": 368,
        "height": 416,
        "content": "## POST 请求"
      },
      "typeVersion": 1
    },
    {
      "id": "9321dada-7ef9-42bd-9b4b-e405de84ae3f",
      "name": "条件3",
      "type": "n8n-nodes-base.if",
      "position": [
        -352,
        -1088
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "69e57e0d-864d-4080-a8a8-1cf933308e79",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $item(\"0\").$node[\"Webhook\"].json[\"body\"][\"type\"] }}",
              "rightValue": "image"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "69469d82-f353-4c10-a31d-fbb5414f6718",
      "name": "获取错误详情",
      "type": "n8n-nodes-base.set",
      "position": [
        192,
        -256
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "817f5e6f-6548-49b2-834b-9a9199a63c06",
              "name": "error.message",
              "type": "string",
              "value": "={{ $json.error.message }}"
            },
            {
              "id": "80b4427b-7157-41e1-b694-dfe214cd4c1c",
              "name": "error.code",
              "type": "string",
              "value": "={{ $json.error.code }}"
            },
            {
              "id": "37299c90-153c-48d1-b21b-f4c8c97e97d3",
              "name": "error.status",
              "type": "number",
              "value": "={{ $json.error.status }}"
            },
            {
              "id": "712965ae-c018-4dbf-84c5-d031e76214ae",
              "name": "finish_reason",
              "type": "string",
              "value": "={{ $json.finish_reason }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "79aa3064-f37f-4bbb-bfde-d9dba40a5975",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32,
        -464
      ],
      "parameters": {
        "width": 384,
        "height": 352,
        "content": "## 捕获 HTTP 运行中的错误"
      },
      "typeVersion": 1
    },
    {
      "id": "205e235d-fac9-4288-983d-b1b31407f0dc",
      "name": "ai-image-generator",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        -976,
        -1232
      ],
      "parameters": {
        "url": "https://api.magichour.ai/v1/ai-image-generator",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"name\": \"{{ $('Get Data from Webhook').item.json.body.parameters.name }}\",\n  \"image_count\": {{ $('Get Data from Webhook').item.json.body.parameters.image_count }},\n  \"orientation\": \"{{ $('Get Data from Webhook').item.json.body.parameters.orientation }}\",\n  \"style\": {\n    \"prompt\": \"{{ $json.message.content }}\",\n    \"tool\": \"{{ $('Get Data from Webhook').item.json.body.parameters.style.tool }}\"\n  }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "accept",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpBearerAuth": {
          "id": "bGXAPcjNHEGxQCF1",
          "name": "MagicHour AI"
        }
      },
      "typeVersion": 4.2,
      "alwaysOutputData": true
    },
    {
      "id": "c0186ccf-3bfa-4390-a5a0-41245db45873",
      "name": "text-to-video",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        -976,
        -688
      ],
      "parameters": {
        "url": "https://api.magichour.ai/v1/text-to-video",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"name\": \"{{ $('Edit Fields2').item.json.body.parameters.name }}\",\n  \"end_seconds\": {{ $('Edit Fields2').item.json.body.parameters.end_seconds }},\n  \"orientation\": \"{{ $('Edit Fields2').item.json.body.parameters.orientation }}\",\n  \"resolution\": \"{{ $('Edit Fields2').item.json.body.parameters.resolution }}\",\n  \"style\": {\n    \"prompt\": \"{{ $json.message.content }}\"\n  }\n} ",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "accept",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpBearerAuth": {
          "id": "bGXAPcjNHEGxQCF1",
          "name": "MagicHour AI"
        }
      },
      "typeVersion": 4.2,
      "alwaysOutputData": true
    },
    {
      "id": "e4bfdb41-1e79-40b9-adc7-fc353bb9dc64",
      "name": "等待1",
      "type": "n8n-nodes-base.wait",
      "position": [
        32,
        -736
      ],
      "webhookId": "3b834feb-d5dd-4637-b488-d00e66c9537d",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "aaf5f07a-7086-4f90-b959-fc3a51d5cb3c",
      "name": "获取视频详情",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        224,
        -736
      ],
      "parameters": {
        "url": "https://api.magichour.ai/v1/video-projects/id",
        "options": {},
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "accept",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpBearerAuth": {
          "id": "bGXAPcjNHEGxQCF1",
          "name": "MagicHour AI"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "b86b8653-7125-49cc-934a-efbf729e92df",
      "name": "If4",
      "type": "n8n-nodes-base.if",
      "position": [
        560,
        -736
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "e240e5dc-6bdf-47a3-85c4-098b5e3235fc",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "complete"
            },
            {
              "id": "cfeb1810-471d-438a-ad2c-f2bf14124616",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "error"
            },
            {
              "id": "5b001186-3156-4f1a-bc59-7e55c51d83ff",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "cancelled"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "0dec21e4-5da8-4b1c-acfd-e051d12daf27",
      "name": "下载视频",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        864,
        -752
      ],
      "parameters": {
        "url": "={{ $json.downloads[0].url }}",
        "options": {}
      },
      "typeVersion": 4.2
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "ce361a06-9a8c-4df2-a40d-139c04f5ce71",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Get Data from Webhook",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Edit Fields2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "Download Image",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If2": {
      "main": [
        [
          {
            "node": "If3",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "If3": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If4": {
      "main": [
        [
          {
            "node": "Download Video",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Get Image Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait1": {
      "main": [
        [
          {
            "node": "Get Video Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields2": {
      "main": [
        [
          {
            "node": "Generate video Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "text-to-video": {
      "main": [
        [
          {
            "node": "If2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Error Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Image": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Video": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Error Details": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Image Details": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Video Details": {
      "main": [
        [
          {
            "node": "If4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ai-image-generator": {
      "main": [
        [
          {
            "node": "If2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Error Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Image Prompt": {
      "main": [
        [
          {
            "node": "ai-image-generator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate video Prompt": {
      "main": [
        [
          {
            "node": "text-to-video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Data from Webhook": {
      "main": [
        [
          {
            "node": "Generate Image Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量25
分类-
节点类型8
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
inderjeet Bhambra

inderjeet Bhambra

@idsinghbhambra

I am on a journey to learn and spread the automations through n8n workflows.

外部链接
在 n8n.io 查看

分享此工作流