用 n8n + 阿里云百炼打造创意海报自动化流程

本教程介绍如何使用 n8n 搭配阿里云百炼 API,实现从内容提取、创意设计到自动发布的创意海报工作流。

阅读时长: 5 分钟
共 2063字
作者: eimoon.com

本期视频将手把手带你搭建一个强大的自动化工作流: 使用 n8n + 阿里云百炼 API,实现从文本提取、AI图像生成、自动下载到上传云盘的全流程创意海报制作!

✅ 自动抓取文章内容(支持网页或自定义输入) ✅ 文本摘要 + Markdown 整理 ✅ 调用阿里云百炼生成创意海报 ✅ 查询任务状态并自动下载图像 ✅ 图片一键上传 Google Drive,轻松分享

📌 适合场景:知识图文号运营、心理学/文学内容可视化、短视频封面设计等

🎁 教程中还介绍了如何生成多张图的循环机制 + 异常处理技巧!

📦 相关链接 & 模板将在评论区置顶分享,别忘了点赞+订阅获取更多AI自动化干货!

工作流:

{
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -3240,
        120
      ],
      "id": "efb2a938-feb9-4c0f-8e08-a2c0fb609dc6",
      "name": "When clicking ‘Test workflow’"
    },
    {
      "parameters": {
        "modelName": "models/gemini-2.0-flash-exp",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -2740,
        320
      ],
      "id": "a001f0a5-59c9-480e-9614-757dcafa4700",
      "name": "Google Gemini Chat Model",
      "credentials": {
        "googlePalmApi": {
          "id": "ZNBiXgkP6HbWeUYn",
          "name": "Google Gemini(PaLM) Api account"
        }
      }
    },
    {
      "parameters": {
        "modelName": "models/gemini-2.0-flash-001",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -2380,
        320
      ],
      "id": "ca88df32-d982-4271-a394-6e3b59bf575d",
      "name": "Google Gemini Chat Model1",
      "credentials": {
        "googlePalmApi": {
          "id": "ZNBiXgkP6HbWeUYn",
          "name": "Google Gemini(PaLM) Api account"
        }
      }
    },
    {
      "parameters": {
        "url": "https://readc.info/bedtime-story/the-fool/",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -2940,
        100
      ],
      "id": "bd0d915e-12e9-42c5-8b13-6820d63c88d6",
      "name": "获取文章"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.data }}",
        "options": {
          "systemMessage": "去除无关的内容,把正文总结成一篇markdown格式的文章"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.9,
      "position": [
        -2660,
        100
      ],
      "id": "7544503d-884a-490f-9ce8-e59b800c2874",
      "name": "提取文章内容"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://dashscope.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-DashScope-Async",
              "value": "enable"
            },
            {
              "name": "Authorization",
              "value": "Bearer {{YOUR_DASHSCOPE_API_KEY}}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ $json.text }}",
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -1900,
        100
      ],
      "id": "4f3dc705-943b-48af-bdfd-6559426546e8",
      "name": "请求生成图片"
    },
    {
      "parameters": {
        "url": "=https://dashscope.aliyuncs.com/api/v1/tasks/{{$json.output.task_id }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer {{YOUR_DASHSCOPE_API_KEY}}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -1460,
        100
      ],
      "id": "29ddfa17-8124-4cc2-999f-8b4c818e0225",
      "name": "查询结果"
    },
    {
      "parameters": {
        "url": "={{ $json.output.render_urls[0] }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -1240,
        100
      ],
      "id": "cf77bdd5-bfc8-48c2-80e8-ef92d110a98a",
      "name": "下载图片"
    },
    {
      "parameters": {
        "amount": 30
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        -1680,
        100
      ],
      "id": "ad206caf-7fcf-44da-839a-601812a88965",
      "name": "等待一下",
      "webhookId": "4c967170-cf22-4dee-838e-d3de7277a82a"
    },
    {
      "parameters": {
        "name": "={{ $json.request_id }}.png",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "value": "root",
          "mode": "list",
          "cachedResultName": "/ (Root folder)",
          "cachedResultUrl": "https://drive.google.com/drive"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        -1020,
        100
      ],
      "id": "9dd9f02c-73d7-4a16-b7d1-9481c348fe00",
      "name": "Google Drive",
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "6q3I9UHER6dmhI6G",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.output }}",
        "messages": {
          "messageValues": [
            {
              "message": "=你是一个专业的海报设计创意师,擅长将寓言故事转化为具有视觉冲击力和哲理性的海报内容。请根据我提供的一个寓言或小故事,提取以下信息,并生成符合指定 JSON 格式的数据:\n\t1.\ttitle:用简洁有力的方式概括故事标题,最多30个字符;\n\t2.\tsub_title:提炼故事的核心寓意,用一句话表达哲理或情感(如:“把困境踩在脚下,走出人生低谷”),最多30个字符;\n\t3.\tbody_text:简明地描述故事情节 + 精炼寓意,最多50个字符;\n\t4.\tprompt_text_zh:列出适合绘图的关键词(中文),描述画面元素、角色、环境、氛围;\n\t5.\twh_ratios:海报的尺寸比例,默认使用“竖版”;\n\t6.\tlora_name:从这些风格(如“童话油画”、“国风水墨”、“2D插画”、“浩瀚星云”、“浓郁色彩”、“光线粒子”、“透明玻璃”、“剪纸工艺”、“折纸工艺”、“中国水墨”、“中国刺绣”、“真实场景”、“2D卡通”、“儿童水彩”、“赛博背景”、“浅蓝抽象”、“抽象点线”)选择建议使用的视觉风格;\n\t7.\tlora_weight:风格控制权重,默认 0.8;\n\t8.\tctrl_ratio:构图控制权重,默认 0.7;\n\t9.\tctrl_step:生成步骤控制,默认 0.7;\n\t10.\tgenerate_mode:默认设为 “generate”;\n\t11.\tgenerate_num:默认生成数量设为 1;\n\n示例模板:\n{\n    \"model\": \"wanx-poster-generation-v1\",\n    \"input\": {\n        \"title\": \"春节快乐\",\n        \"sub_title\": \"家庭团聚,共享天伦之乐\",\n        \"body_text\": \"春节是中国最重要的传统节日之一,它象征着新的开始和希望\",\n        \"prompt_text_zh\": \"灯笼,小猫,梅花\",\n        \"wh_ratios\": \"竖版\",\n        \"lora_name\": \"童话油画\",\n        \"lora_weight\": 0.8,\n        \"ctrl_ratio\": 0.7,\n        \"ctrl_step\": 0.7,\n        \"generate_mode\": \"generate\",\n        \"generate_num\": 1\n    },\n    \"parameters\": {}\n}\n直接返回结果,去掉```json ``` 这样的包裹"
            }
          ]
        }
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.6,
      "position": [
        -2280,
        100
      ],
      "id": "42c81699-6718-401f-bcaa-94639818a35e",
      "name": "Basic LLM Chain"
    }
  ],
  "connections": {
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "获取文章",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "提取文章内容",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "获取文章": {
      "main": [
        [
          {
            "node": "提取文章内容",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "提取文章内容": {
      "main": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "请求生成图片": {
      "main": [
        [
          {
            "node": "等待一下",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "查询结果": {
      "main": [
        [
          {
            "node": "下载图片",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "下载图片": {
      "main": [
        [
          {
            "node": "Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "等待一下": {
      "main": [
        [
          {
            "node": "查询结果",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive": {
      "main": [
        []
      ]
    },
    "Basic LLM Chain": {
      "main": [
        [
          {
            "node": "请求生成图片",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "3886e1e9c6c0e6eb98d84479b90e355a5a967e32c17c84fdacb4e070bf126374"
  }
}

关注我获取更多资讯

公众号
📢 公众号
个人号
💬 个人号
使用 Hugo 构建
主题 StackJimmy 设计