8
n8n 中文网amn8n.com

测试 - Bannerbear图像生成器 同步/异步

中级

这是一个自动化工作流,包含 15 个节点。主要使用 If, Set, Webhook, Bannerbear, HttpRequest 等节点。 使用Bannerbear创建品牌社交媒体图片(同步/异步模式)

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

分类

-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "F3mTq6rX9I4XydnO",
  "meta": {
    "instanceId": "313b93d489cbc0ae87ad93f25c395bbdc59c46c632d00f395c3586a8fbbb7a34",
    "templateCredsSetupCompleted": true
  },
  "name": "测试 - Bannerbear 图像生成器 同步/异步",
  "tags": [
    {
      "id": "WaI3hC9FrokRTdiV",
      "name": "Bannerbear",
      "createdAt": "2025-10-12T16:01:05.619Z",
      "updatedAt": "2025-10-12T16:01:05.619Z"
    }
  ],
  "nodes": [
    {
      "id": "c8bd9d3d-8b8b-4a34-a6bb-c864ca4b5b15",
      "name": "当点击\"执行工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -496,
        0
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "1a16d617-daa4-4798-bc3e-3f1ebbe983c4",
      "name": "设置参数",
      "type": "n8n-nodes-base.set",
      "position": [
        -208,
        0
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "{\n  \"bannerbear_api_key\": \"your_bannerbear_api_key\",\n  \"banner_bear_template_id\": \"your_banner_bear_template_id\",\n  \"title\": \"This image is AI generated\",\n  \"subtitle\": \"Made in n8n with BannerBear\",\n  \"call_mode\": \"sync\"\n}\n"
      },
      "typeVersion": 3.4
    },
    {
      "id": "e275b1cc-0dd7-44ec-b7e7-bebd09780090",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1168,
        -368
      ],
      "parameters": {
        "width": 496,
        "height": 864,
        "content": "## 如何设置此工作流"
      },
      "typeVersion": 1
    },
    {
      "id": "b7ed9313-8ac6-4f12-a39c-3907234d5a7c",
      "name": "同步创建图像",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        480,
        -112
      ],
      "parameters": {
        "url": "https://sync.api.bannerbear.com/v2/images",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"template\": \"{{ $('SetParameters').item.json.banner_bear_template_id }}\",\n  \"modifications\": [\n    {\n      \"name\": \"title\",\n      \"text\": \"{{ $('SetParameters').item.json.title }}\",\n      \"color\": null,\n      \"background\": null\n    },\n    {\n      \"name\": \"pretitle\",\n      \"text\": \"{{ $('SetParameters').item.json.subtitle }}\",\n      \"background\": null\n    }\n  ],\n  \"webhook_url\": null,\n  \"transparent\": false,\n  \"metadata\": null\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('SetParameters').item.json.bannerbear_api_key }}"
            }
          ]
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2,
      "waitBetweenTries": 5000
    },
    {
      "id": "3d8a40d5-79a8-4371-88dd-a276f8a4246d",
      "name": "获取图像 URL 和大小",
      "type": "n8n-nodes-base.set",
      "position": [
        704,
        -112
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={\n  \"uid\": \"{{ $json.uid }}\",\n  \"status\": \"{{ $json.status }}\",\n  \"image_url_png\": \"{{ $json.image_url_png }}\",\n  \"image_url_jpg\": \"{{ $json.image_url_jpg }}\",\n  \"width\": {{ $json.width }},\n  \"height\": {{ $json.height }}\n}\n"
      },
      "typeVersion": 3.4
    },
    {
      "id": "b776d8f5-ce48-4d52-ba5b-809b229953eb",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        336,
        -240
      ],
      "parameters": {
        "color": 6,
        "width": 608,
        "height": 352,
        "content": "## 同步调用(特定 API URL)"
      },
      "typeVersion": 1
    },
    {
      "id": "2e0c9929-728c-4f91-abcd-afc78074cdbf",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        336,
        144
      ],
      "parameters": {
        "color": 5,
        "width": 608,
        "height": 352,
        "content": "## 异步调用"
      },
      "typeVersion": 1
    },
    {
      "id": "b5b54ead-b4d0-4786-a741-5f86e8c92767",
      "name": "Webhook_图像创建时",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -512,
        560
      ],
      "webhookId": "ac6a6723-1876-4f43-af4c-411a0f1f4ad3",
      "parameters": {
        "path": "ac6a6723-1876-4f43-af4c-411a0f1f4ad3",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2.1
    },
    {
      "id": "e312e19a-22eb-4dec-ae58-5f71894513b3",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1168,
        512
      ],
      "parameters": {
        "color": 5,
        "width": 496,
        "height": 192,
        "content": "## Webhook 异步模式"
      },
      "typeVersion": 1
    },
    {
      "id": "867be1aa-e4a1-4a39-9662-a89a0248b2e5",
      "name": "获取 Uid 和状态",
      "type": "n8n-nodes-base.set",
      "position": [
        720,
        272
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={\n  \"uid\": \"{{ $json.uid }}\",\n  \"status\": \"{{ $json.status }}\"\n}\n"
      },
      "typeVersion": 3.4
    },
    {
      "id": "faf15aff-2df8-40b4-b11f-da9284c7ef5f",
      "name": "获取已完成图像信息",
      "type": "n8n-nodes-base.set",
      "position": [
        -304,
        560
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={\n  \"uid\": \"{{ $json.uid }}\",\n  \"status\": \"{{ $json.status }}\",\n  \"image_url_png\": \"{{ $json.image_url_png }}\",\n  \"image_url_jpg\": \"{{ $json.image_url_jpg }}\",\n  \"width\": {{ $json.width }},\n  \"height\": {{ $json.height }}\n}\n"
      },
      "typeVersion": 3.4
    },
    {
      "id": "a17932d9-0e0d-4733-80f2-fa4a92225637",
      "name": "便签 12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        16,
        -144
      ],
      "parameters": {
        "color": 7,
        "width": 288,
        "height": 352,
        "content": "## 在同步和异步调用之间选择"
      },
      "typeVersion": 1
    },
    {
      "id": "f7c801d4-29a0-451a-8669-6aa3b89ea2d9",
      "name": "如果是同步调用",
      "type": "n8n-nodes-base.if",
      "position": [
        80,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "3be86245-4fbc-4b3c-b5e8-cdf55830a364",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.call_mode }}",
              "rightValue": "=sync"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "21604f70-04fd-4d3e-a63c-71d40b63370b",
      "name": "异步创建图像",
      "type": "n8n-nodes-base.bannerbear",
      "position": [
        480,
        272
      ],
      "parameters": {
        "templateId": "={{ $json.banner_bear_template_id }}",
        "modificationsUi": {
          "modificationsValues": [
            {
              "name": "title",
              "text": "={{ $json.title }}"
            },
            {
              "name": "pretitle",
              "text": "={{ $json.subtitle }}"
            }
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "bannerbearApi": {
          "id": "3TRGZU5Fz9n1UAvW",
          "name": "Bannerbear account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6cb031e3-e3fd-469c-ba22-e64818811b68",
      "name": "便签 6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -288,
        -144
      ],
      "parameters": {
        "color": 7,
        "width": 272,
        "height": 352,
        "content": "## 设置 BannerBear 参数和数据"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {
    "SynchronouslyCreateImage": [
      {
        "json": {
          "uid": "5nDZ3xmVezbm8BNJYy2qpdWj9",
          "self": "https://api.bannerbear.com/v2/images/5nDZ3xmVezbm8BNJYy2qpdWj9",
          "width": 1000,
          "height": 1000,
          "status": "completed",
          "pdf_url": null,
          "metadata": null,
          "template": "Kp21rAZj1BVab6eLnd",
          "image_url": "https://images.bannerbear.com/direct/lPOmJb1Yvv8Xz60g4G/requests/000/109/151/708/5nDZ3xmVezbm8BNJYy2qpdWj9/114db5f59243f056dca6207c7c8940c5fa6708d5.png",
          "created_at": "2025-10-12T16:22:59.013Z",
          "render_pdf": false,
          "transparent": false,
          "webhook_url": null,
          "image_url_jpg": "https://images.bannerbear.com/direct/lPOmJb1Yvv8Xz60g4G/requests/000/109/151/708/5nDZ3xmVezbm8BNJYy2qpdWj9/114db5f59243f056dca6207c7c8940c5fa6708d5.jpg",
          "image_url_png": "https://images.bannerbear.com/direct/lPOmJb1Yvv8Xz60g4G/requests/000/109/151/708/5nDZ3xmVezbm8BNJYy2qpdWj9/114db5f59243f056dca6207c7c8940c5fa6708d5.png",
          "modifications": [
            {
              "name": "title",
              "text": "This image is AI generated",
              "color": null,
              "background": null
            },
            {
              "name": "pretitle",
              "text": "Sorry not sorry",
              "background": null
            }
          ],
          "template_name": "LinkedId Post",
          "template_version": null,
          "pdf_url_compressed": null,
          "webhook_response_code": null
        }
      }
    ]
  },
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "b1fbbe44-ab95-4159-8c46-46084790d26c",
  "connections": {
    "SetParameters": {
      "main": [
        [
          {
            "node": "IfSynchrounousCall",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IfSynchrounousCall": {
      "main": [
        [
          {
            "node": "SynchronouslyCreateImage",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AsynchronouslyCreateImage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook_OnImageCreated": {
      "main": [
        [
          {
            "node": "GetCompletedImageInfo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SynchronouslyCreateImage": {
      "main": [
        [
          {
            "node": "GetImageUrlAndSize",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AsynchronouslyCreateImage": {
      "main": [
        [
          {
            "node": "GetUidAndStatus",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "SetParameters",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级

需要付费吗?

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

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

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

作者
Elodie Tasia

Elodie Tasia

@ladypixl

Web designer & AI automation creator. I build clean, conversion-ready sites and n8n workflows that take your content from idea to publish, on autopilot, in your voice. Grab my templates or message me for a custom build.

外部链接
在 n8n.io 查看

分享此工作流