8
n8n 中文网amn8n.com

使用 FLUX Kontext 生成 AI 情境化图像

高级

这是一个Design, AI, Marketing领域的自动化工作流,包含 17 个节点。主要使用 If, Wait, GoogleDrive, HttpRequest, GoogleSheets 等节点,结合人工智能技术实现智能自动化。 使用 FLUX Kontext、Google Sheets 和 Drive 通过 AI 提示词变换图像

前置要求
  • Google Drive API 凭证
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "IctMuVMXlEownJe1",
  "meta": {
    "instanceId": "a4bfc93e975ca233ac45ed7c9227d84cf5a2329310525917adaf3312e10d5462",
    "templateCredsSetupCompleted": true
  },
  "name": "使用 FLUX Kontext 生成 AI 情境化图像",
  "tags": [],
  "nodes": [
    {
      "id": "b0f612bd-9665-4607-81fd-5b6fbd9cb562",
      "name": "当点击\"测试工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -140,
        660
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "8f02f950-7ea3-4dfe-be9e-989f675080e0",
      "name": "获取状态",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        800,
        660
      ],
      "parameters": {
        "url": "=https://queue.fal.run/fal-ai/flux-pro/requests/{{ $('Create Image').item.json.request_id }}/status ",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "daOZafXpRXLtoLUV",
          "name": "Fal.run API"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "ec42f3a9-f489-4dcd-b606-e5dee097eea9",
      "name": "等待 60 秒",
      "type": "n8n-nodes-base.wait",
      "position": [
        580,
        660
      ],
      "webhookId": "8d37a81d-c373-479f-9cc6-42598c4f37e5",
      "parameters": {
        "amount": 60
      },
      "typeVersion": 1.1
    },
    {
      "id": "8c927df4-9f70-4e91-940c-9c3a08394a8b",
      "name": "计划触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -140,
        520
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "19b6b133-842d-49e6-9fe4-3acb2afeac78",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -220,
        -500
      ],
      "parameters": {
        "color": 3,
        "width": 740,
        "height": 320,
        "content": "# 使用 FLUX Kontext 生成 AI 情境化图像"
      },
      "typeVersion": 1
    },
    {
      "id": "de86c0a1-ad6f-4037-83a1-099b52b8ed8b",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -220,
        -140
      ],
      "parameters": {
        "width": 740,
        "height": 220,
        "content": "## 步骤 1 - GOOGLE SHEET"
      },
      "typeVersion": 1
    },
    {
      "id": "74a1a103-a662-4b03-97e6-1d557731c43e",
      "name": "完成?",
      "type": "n8n-nodes-base.if",
      "position": [
        1020,
        660
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "383d112e-2cc6-4dd4-8985-f09ce0bd1781",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "COMPLETED"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "8410d765-7507-4b14-b64c-429cb962db0a",
      "name": "更新结果",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        820,
        1000
      ],
      "parameters": {
        "columns": {
          "value": {
            "RESULT": "={{ $('Get Image Url').item.json.images[0].url }}",
            "row_number": "={{ $('Get new image').item.json.row_number }}"
          },
          "schema": [
            {
              "id": "IMAGE URL",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "IMAGE URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "PROMPT",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "PROMPT",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ASCPECT RATIO",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "ASCPECT RATIO",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "OUTPUT FORMAT",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "OUTPUT FORMAT",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "RESULT",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "RESULT",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "row_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/11ebWJvwwXHgvQld9kxywKQUvIoBw6xMa0g0BuIqHDxE/edit#gid=0",
          "cachedResultName": "Foglio1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1N1Yg7FA4tQ8mDll5HLKqwPBuHj31AGDKwzAOg8mLQKs",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1N1Yg7FA4tQ8mDll5HLKqwPBuHj31AGDKwzAOg8mLQKs/edit?usp=drivesdk",
          "cachedResultName": "Flux Kontext"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "JYR6a64Qecd6t8Hb",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "b3087b1a-f9c9-4674-a894-0290768b0c9b",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -220,
        300
      ],
      "parameters": {
        "width": 740,
        "height": 100,
        "content": "## 步骤 4 - 主流程"
      },
      "typeVersion": 1
    },
    {
      "id": "9b149100-99eb-4b6a-9335-ee4888a97c25",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -220,
        120
      ],
      "parameters": {
        "width": 740,
        "height": 140,
        "content": "## 步骤 2 - 获取 API 密钥 (您的API密钥)"
      },
      "typeVersion": 1
    },
    {
      "id": "8a34a1a2-3f39-4cc5-9739-0cad1d811f10",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        280,
        600
      ],
      "parameters": {
        "width": 180,
        "height": 200,
        "content": "设置在步骤 2 中创建的 API 密钥"
      },
      "typeVersion": 1
    },
    {
      "id": "d8240bd8-f127-40a7-aa3a-29211befe2e3",
      "name": "获取图像 URL",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        100,
        1000
      ],
      "parameters": {
        "url": "=https://queue.fal.run/fal-ai/flux-pro/requests/{{ $json.request_id }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "daOZafXpRXLtoLUV",
          "name": "Fal.run API"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "987ce6a8-13ac-4516-9a3a-a71fa8b513b1",
      "name": "上传图像",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        580,
        1000
      ],
      "parameters": {
        "name": "={{ $now.format('yyyyLLddHHmmss') }}.{{ $('Get new image').item.json[\"OUTPUT FORMAT\"] }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1aHRwLWyrqfzoVC8HoB-YMrBvQ4tLC-NZ",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1aHRwLWyrqfzoVC8HoB-YMrBvQ4tLC-NZ",
          "cachedResultName": "Fal.run"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "HEy5EuZkgPZVEa9w",
          "name": "Google Drive account (n3w.it)"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "1d6b21c5-429e-4095-b74d-fd12ca62afca",
      "name": "创建图像",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        320,
        660
      ],
      "parameters": {
        "url": "https://queue.fal.run/fal-ai/flux-pro/kontext",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"prompt\": \"{{ $json.PROMPT }}\",\n  \"image_url\": \"{{ $json['IMAGE URL'] }}\",\n  \"output_format\": \"{{ $json['OUTPUT FORMAT'] }}\",\n  \"aspect_ratio\": \"{{ $json['ASCPECT RATIO'] }}\"\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "daOZafXpRXLtoLUV",
          "name": "Fal.run API"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "c350e744-bf61-4837-bc97-8b35ff1c6755",
      "name": "获取新图像",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        80,
        660
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "RESULT"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1N1Yg7FA4tQ8mDll5HLKqwPBuHj31AGDKwzAOg8mLQKs/edit#gid=0",
          "cachedResultName": "Foglio1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1N1Yg7FA4tQ8mDll5HLKqwPBuHj31AGDKwzAOg8mLQKs",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1N1Yg7FA4tQ8mDll5HLKqwPBuHj31AGDKwzAOg8mLQKs/edit?usp=drivesdk",
          "cachedResultName": "Flux Kontext"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "JYR6a64Qecd6t8Hb",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "6f5181b9-300f-4214-a19b-f0f717c9db29",
      "name": "获取图像文件",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        320,
        1000
      ],
      "parameters": {
        "url": "={{ $json.images[0].url }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "539eb1dc-e439-42ad-b313-943d1dbc1937",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        560,
        -500
      ],
      "parameters": {
        "color": 5,
        "width": 360,
        "height": 900,
        "content": "## 示例"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "0efa8e9f-21d0-45ce-b557-03620f3fc771",
  "connections": {
    "Completed?": {
      "main": [
        [
          {
            "node": "Get Image Url",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 60 sec.",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get status": {
      "main": [
        [
          {
            "node": "Completed?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Image": {
      "main": [
        [
          {
            "node": "Wait 60 sec.",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Image": {
      "main": [
        [
          {
            "node": "Update result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 60 sec.": {
      "main": [
        [
          {
            "node": "Get status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Image Url": {
      "main": [
        [
          {
            "node": "Get Image File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get new image": {
      "main": [
        [
          {
            "node": "Create Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update result": {
      "main": [
        []
      ]
    },
    "Get Image File": {
      "main": [
        [
          {
            "node": "Upload Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Get new image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 设计, 人工智能, 营销

需要付费吗?

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

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

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

作者

Full-stack Web Developer based in Italy specialising in Marketing & AI-powered automations. For business enquiries, send me an email at info@n3w.it or add me on Linkedin.com/in/davideboizza

外部链接
在 n8n.io 查看

分享此工作流