8
n8n 中文网amn8n.com

## 设置指南

中级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 13 个节点。主要使用 If, Set, Code, Wait, FormTrigger 等节点。 使用 Gemini AI 生成复古宝丽来风格照片

前置要求
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "MomV5viXB16wUmuP",
  "meta": {
    "instanceId": "61055bd86de35ef46fd36e8f404f58e3f9ad437c028cde71d16413774416da74"
  },
  "name": "## 设置指南",
  "tags": [],
  "nodes": [
    {
      "id": "af84ccab-6bfc-4223-a846-200942e41371",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -768,
        -736
      ],
      "parameters": {
        "color": 3,
        "width": 780,
        "height": 760,
        "content": "### 步骤1:配置触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "7c7629bf-0c92-4de1-b0b4-93d0bb097146",
      "name": "获取生成状态",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -320,
        96
      ],
      "parameters": {
        "url": "https://api.defapi.org/api/task/query",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "task_id",
              "value": "={{$json.data.task_id}}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Convert to JSON').item.json.api_key }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "a6ff7deb-a1d7-4b4b-b0cf-a97e56805a6d",
      "name": "向 Defapi.org API 发送图像生成请求",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -752,
        96
      ],
      "parameters": {
        "url": "https://api.defapi.org/api/image/gen",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"prompt\": \"{{$json.prompt}}\",\n  \"model\": \"google/nano-banana\",\n  \"images\": [\"{{ $json.img_url_01 }}\", \"{{ $json.img_url_02 }}\"]\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{ $json.api_key }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "765b6cfd-8678-42f5-aad4-a4c197b0e628",
      "name": "模板使用n8n的默认聊天触发器",
      "type": "n8n-nodes-base.wait",
      "position": [
        -512,
        96
      ],
      "webhookId": "bb6c2821-9586-44b7-8606-2ee69a77ed75",
      "parameters": {
        "amount": 10
      },
      "typeVersion": 1.1
    },
    {
      "id": "ee3bce44-c556-42af-97aa-8e7fdae40285",
      "name": "对于外部平台:替换为Webhook触发器并配置您平台的Webhook URL",
      "type": "n8n-nodes-base.if",
      "position": [
        -128,
        96
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "db9a5dec-997b-4c3f-9582-37c9bbeb19ff",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "=true",
              "rightValue": "={{ $json.data.status == 'success' }}"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "d88742b4-960c-4bab-84da-557ec413f71e",
      "name": "支持平台:任何具有Webhook功能的平台(网站、Slack、Teams、Discord等)",
      "type": "n8n-nodes-base.set",
      "position": [
        64,
        80
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "fa5f375f-cddc-4f7b-a018-67c28015d18b",
              "name": "image_url",
              "type": "string",
              "value": "={{$json.data.result[0].image}}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "22e91f6d-13a5-474a-9f93-0c66ba8540e8",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1408,
        304
      ],
      "parameters": {
        "color": 4,
        "width": 400,
        "height": 576,
        "content": "## 输入图片 1"
      },
      "typeVersion": 1
    },
    {
      "id": "98a4119e-0e06-4a61-a215-b03cfc64058c",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -432,
        304
      ],
      "parameters": {
        "width": 640,
        "height": 608,
        "content": "### 步骤2:设置知识库"
      },
      "typeVersion": 1
    },
    {
      "id": "9df109b4-077a-425b-ad08-a1b6246d4c9d",
      "name": "转换为 JSON",
      "type": "n8n-nodes-base.code",
      "position": [
        -896,
        -48
      ],
      "parameters": {
        "jsCode": "/**\n * Encodes multiple binary files from an n8n input item into Base64 strings.\n *\n * This code assumes it is running in an n8n \"Code\" or \"Function\" node\n * where 'this' refers to the node's context and 'helpers' are available.\n *\n * @returns {object} An object containing an array of file objects,\n * each with a 'path' and 'data' (Base64 string).\n */\nconst results = {};\n\nconst getImageDataUrl = async (name) => {\n    const bin = $input.first().binary[name];\n    // Use n8n's helper function to get the file buffer.\n    const binBuffer = await this.helpers.getBinaryDataBuffer(0, name);\n    return `data:${bin.mimeType};base64,${Buffer.from(binBuffer).toString('base64')}`\n}\n\n// Push a new object to the results array.\nresults.img_url_01 = await getImageDataUrl('Image_01')\nresults.img_url_02 = await getImageDataUrl('Image_02')\nresults.api_key = $input.first().json['API Key']\nresults.prompt = $input.first().json['Prompt']\n\n// Return the final object in the expected format for the next node.\nreturn results;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "c128c65c-f435-43d4-9d50-719429fa9510",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1184,
        80
      ],
      "parameters": {
        "content": "关于创建和管理向量数据库,请遵循此综合指南:"
      },
      "typeVersion": 1
    },
    {
      "id": "bab5bb39-ecb4-41a7-9a31-06afed798ddd",
      "name": "上传 2 张图片",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -1104,
        -48
      ],
      "webhookId": "254a1336-57d2-4ba0-93e1-e8460fc94f00",
      "parameters": {
        "options": {},
        "formTitle": "Upload 2 Images",
        "formFields": {
          "values": [
            {
              "fieldLabel": "API Key",
              "requiredField": true
            },
            {
              "fieldLabel": "Prompt",
              "requiredField": true
            },
            {
              "fieldType": "file",
              "fieldLabel": "Image 01",
              "multipleFiles": false,
              "requiredField": true,
              "acceptFileTypes": "image/*"
            },
            {
              "fieldType": "file",
              "fieldLabel": "Image 02",
              "requiredField": true,
              "acceptFileTypes": "image/*"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "1dfb0d0e-0b2c-4aa1-9a10-3b6750f797c4",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1008,
        304
      ],
      "parameters": {
        "color": 4,
        "width": 400,
        "height": 576,
        "content": "观看Cole Medin关于文档向量化的教程"
      },
      "typeVersion": 1
    },
    {
      "id": "aaaa1a73-3682-49c4-b074-4ebb354abb6d",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1024,
        -192
      ],
      "parameters": {
        "height": 128,
        "content": "该视频展示如何在Supabase上构建完整知识库"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "43634557-84b0-4613-a82e-ff722c925dd8",
  "connections": {
    "Convert to JSON": {
      "main": [
        [
          {
            "node": "Send Image Generation Request to Defapi.org API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload 2 Images": {
      "main": [
        [
          {
            "node": "Convert to JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Obtain the generated status": {
      "main": [
        [
          {
            "node": "Check if Image Generation is Complete",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Image Processing Completion": {
      "main": [
        [
          {
            "node": "Obtain the generated status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if Image Generation is Complete": {
      "main": [
        [
          {
            "node": "Format and Display Image Results",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait for Image Processing Completion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Image Generation Request to Defapi.org API": {
      "main": [
        [
          {
            "node": "Wait for Image Processing Completion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 内容创作, 多模态 AI

需要付费吗?

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

工作流信息
难度等级
中级
节点数量13
分类2
节点类型7
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

外部链接
在 n8n.io 查看

分享此工作流