首页 / 浏览内容

精华「n8n 教程」从 0 到 1 搭建 Blog Writing 工作流

目录

「n8n 教程」从 0 到 1 搭建 Blog Writing 工作流

哈喽喽,大家好,我是殷小样,目前在运营一个外贸独立站。独立站自然流量的获取离不开 SEO,而内容创作是 SEO 提升流量不可或缺的环节,如何高效且持续地产出优质 Blog 内容,是我一直在摸索的问题。脑袋里时不时就会出现问号,比如:到底该写什么?用户关心的到底是啥?他们还有什么问题需要解决?图片到底放哪儿才算“刚刚好”?还有素材库永远不够用……

最近参加了小排老师的 idea to business 的课程学习到“积木式创新”,突然开窍了:“写博客这事儿,能不能像搭积木一样自动化?”于是我抱着试试看的心态,叫上 n8n,开始了我的自动化写作之旅。

这篇帖子不聊虚的,只聊怎么把流程搭起来,怎么让写作变得像流水线一样高效。内容主要包括:

一、准备阶段(包括创建 Google 相关 API 凭证 & 可能遇到的错误) 二、Blog Writing 工作流搭建思路 三、“搭积木游戏”完整流程,包括但不限于: (1)选题到底怎么找?怎么保证有源源不断的内容灵感,而不是写到一半就卡壳? (2)标题和结构怎么自动生成,才能既抓住用户需求,又不千篇一律? (3)图片和素材怎么自动配齐,不让正文光秃秃,也不让图片风格跑偏? 四、内容“疗效”如何? 五、以前的我 vs 现在的我(Blog Writing 经历的阶段)

接下来是飞书好读版 👇🏼 :https://rqwl0k608z.feishu.cn/wiki/JRZrweTLdimlVnkHqYQc0Pw6nwf?from=from_copylink​​​「n8n 教程」从 0 到 1 搭建 Blog Writing 工作流 哈喽,大家好,我是殷小样,目前在运营一个外贸独立站。

在日常的运营工作中,内容创作是 SEO 中提升流量不可缺少的环节。如何高效且持续地产出优质 Blog 内容,是我一直都在思考的问题。因为过程中,有很痛很痛的点:

关键词背后,用户真正关心的问题是什么? 这个话题下有哪些子话题相关? 应该在哪个位置插入图片,让它成为一篇高质量的有丰富媒体信息(图/表)的内容? 自有的素材库有限且匹配性不确定? ......

最近参加了小排老师的 idea to business 课程,了解到“积木式创新”思路后,我尝试用 n8n 来自动化整个写作流程。接下来,我将详细分享从零开始搭建 Blog writing 自动化工作流的实操方法,希望能对大家有帮助。 准备阶段 在开始搭建之前,先保证你已经完成了“基建”工作。 n8n 官网 / 本地部署 / 云端部署 n8n 官网新注册用户赠送 14 天免费体验期 可通过此链接 https://n8n.io/ 注册,0 技术最小成本顺滑体验。温馨提示:若后续无官网续费计划,14 天内记得把自己的工作流导出,避免后续超过体验期工作区被删除,需要费力借助 magic link 登录导出(出现体验不顺滑,邮件发送卡顿延时,不能及时收到的问题~别问为啥我知道,问就是因为我之前忘了,操作过,哈哈)。 image.png

本地部署 已经有圈友写了手把手教部署的帖子,具体可查看下面这篇帖子跟着操作

云端部署 也可以跟着下面这个视频,同时介绍了如何在「本地安装」/「云端部署」n8n。

API 准备 & 创建 Credential 接下来的工作流演示会用到以下 API:

用于文本内容生成:OpenAI API,可以替换为 Claude API 或者 OpenRouter API 用于图片生成:Fal.ai API 用作内容输入来源:Google Sheets 用作内容输出承接:Google Drive & Google Docs 如何创建 Google Drive & Google Sheets & Google Docs API 凭证 工作流选择 Google Sheets 作为数据内容的输入端,那你必须要获得人家的允许嘛,你不能“擅闯民宅”,对不~

之所以选择 Google Sheets,是因为它易用且好协作,我也看到国外博主们有推荐 Airtable 的,它虽功能强大,但对我自己来说需要再多学一个软件,学习成本高,不利于快速应用,大家可以结合自己的情况自行考量。

具体的分步操作步骤: 打开 Google Cloud Console:https://console.cloud.google.com 新建项目:点击「Select a project(选择一个项目」」➡️「New project(新项目)」,并为新项目命名,例如我写的「n8n blog writing」,然后点击Create。 image.png

待项目完成创建,进入「APIs & Services(API 与服务)」➡️ 「Enable APIs and services(启用 API 与服务)」 image.png

在输入框中输入并搜索启用:Google Sheets API / Google Drive API / Google Docs API。 image.png

然后,点击左侧菜单栏「Credentials(凭证)」➡️ 「Create credentials(创建凭证)」 ➡️ 「OAuth client ID(OAuthor 客户端 ID)」 image.png

点击「Configure consent screen(配置同意屏幕)」➡️ 点击 Get started,填写 App name 和收件邮箱、选择 External、填写联系邮箱(可添加不止一个,需要收到项目变化的邮箱)、☑️ 同意点击「Continue(继续)」➡️ 点击「Create(创建)」 image.png

点击左侧菜单栏「Clients(客户端)」➡️ 「Create client」,选择「Web application(Web 应用)」、完成命名,点击「Add URI」为 http://localhost:5678/rest/oauth2-credential/callback,点击 Create 完成创建,获得 Client ID 以及 Client Secret。

这个 Client ID 可以在 同一个 Google Cloud 项目 下同时给 n8n 的 Google Sheets、Docs、Drive 节点使用。 因为它们走的都是同一套 OAuth2 授权流程(Scope 决定访问权限,Client ID/Secret 不需要分开)。 image.png

然后在 n8n 中配置 Google Sheets Credential(Google Sheets OAuth2 API)& Google Drive Credential( Google Drive OAuth2 API)& Google Docs Credential(Google Docs OAuth2 API) 如何创建 Credential 自行部署 n8n 的话,可以通过以下步骤进行 Credential 的创建添加:

第一步:点击「Create Credential」 image.png

第二步:在弹窗输入框中输入要添加的 API,从下拉框的搜索结果中选择后,点击「Continue」

Tips:若使用的是第三方 API,可以自行查看文档,是选择 Header Auth 还是 Basic Auth。 image.png

第三步:去对应的平台生成 API Key 填进来,点击「Save」保存即可。 image.png

补充说明 1:创建 Google Sheets/Docs Credential Sign in Google 时遇到 403 错误 Hold on hold on,不要惊慌,都能拿捏~~ 这是因为你的 Google OAuth 还在「测试模式(Testing)」,当前登录账号不在测试用户白名单里,所以被拦下(403 access_denied)

此时回到 https://console.cloud.google.com/auth/audience,把用来授权的 Google 账号邮箱加进去(可最多加 100人)。保存后,回 n8n 里重新点击该 Google 凭证重新连接授权。 image.png

补充说明 2:创建 Google OAuth Credential Sign in Google 时遇到 400 错误 这是因为选用的是 Google OAuth2 API,OAuth 请求里没有带 Scope(权限范围) image.png

把下面的内容填入 Scope 中,就能成功连接并授权。

https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/documents https://www.googleapis.com/auth/drive.file 我之前这样子操作过,但发现节点不接受通用的这个 Google OAuth2 API,就还是每个单独配置。 工作流搭建思路

填表(Google Sheets,预设关键词、初步主题以及对主题的简要描述) ➡️ n8n 触发(表格新增行触发) ➡️ AI 根据表格项调研分析,生成写作策略,确定 Blog 标题(H1) ➡️ AI 生成分级大纲(Outline,H2/H3) ➡️ AI 生成正文(包括标准化图片占位符,如%[image placeholder]) ➡️ AI 逐个解析占位符上下文生成对应配图 ➡️ 将图片 URL 替换正文占位符 ➡️ 输出到 Google Docs 游戏开始 第一步:创建 Google Sheets 表格 首先,创建一个 Google Sheets 表格,在表格中添加下列字段,作为每一列的表头名称,包括:

Keyword:Blog 围绕的核心关键词 Title:初步标题,即核心关键词高相关的话题 Description:对文章话题内容的想法以及独到见解(Insight) Create Articles?:复选框形式。作为工作流的一个信号,当设置为 ✅ ,表示这一行的内容需要完成。 Status:复选框形式,但由系统进行填写,✅ 表示内容完成。 Google Docs URL:内容完成后,系统自动将 URL 填写到 Google Sheets 对应单元格中。 第二步:怎么源源不断找到能写的内容? 完成表头内容的信息,就需要填入具体要写的内容。但你可能也会挠头,脑袋里有很多个问号❓❓比如写点啥呀?写了这多,还有啥可写的呢?别担心,你不是一个人😊

这个部分的 keyword 和 title 我目前是这样处理的,借助 Google People Also Ask / Things to Know 或者 Semrush 主题研究(Topic Research)。

Google People Also Ask image.png

Google Things to Know image.png

Semrush Topic Research 路径:左侧菜单栏 SEO ➡️ 「主题研究」➡️ 输入要研究的主题,可以针对特定国家选择。 image.png

等待完成后,可以查看内容创意。可以把「优先显示热门副主题」开关打开,你看,是不是有好多话题可以写」 image.png

通过这几个方法,可以完成 keyword 和 title 的内容,description 目前我没有完全交给 AI 来研究分析完成,因为不同的垂类行业有行业内才了解的信息。但这一点,我认为 title 以及 description 可以结合「内部知识库+AI 调研分析搜索结果」后续升级实现自动化,只是我还没有做好。 第三步:让 n8n 监听 Google Sheets 表格,触发流程 我们的目的是希望通过监听到 Google Sheets 中 Create Articles?的复选框变成 ✅,就知道开始工作。n8n 本身提供了 Google Sheets Trigger 节点,我们来看一下是否能够实现。 image.png

现实情况是,仅支持「新增行/更新行」触发,并不能直接监听某一行的复选框变化触发,所以我就换了一个方案——用 「n8n 定时触发器 + Google Sheets 读取新增行 + IF 条件判断」。

具体操作步骤如下: 添加 Schedule Trigger 节点 根据自己的实际情况设置具体的时间间隔(如每分钟、每小时、每天、每周等)来自动触发整个工作流。 image.png

点击 + 添加 Google Sheets Get row(s) in sheet 节点 按照下图配置好信息后,点击右上角的 Execute Step,就能够从表格中都有所有行并显示在右侧的Output 区域。 也可以点击 Output 区域的 📌 固定数据, image.png

我们来验证一下是否我建立的 Google Sheets 中是否如右侧输出的一样 image.png

完全没问题~

完成了表格内容的读取,就需要筛选出符合条件的行,条件如下: Create Article? = ✅ Status 是空(表示没被处理过) 第四步:添加 IF 节点进行筛选 在 Google Sheets Get row(s) in sheet 节点右侧点击 +添加 If 节点,并设置条件: 条件 1:Create Article? 字段为 true

字段

值

Value

{{ $json['Create Article?'] }}

Type

Boolean

Operation

is true 条件 2:Status 是空

字段

值

Value

{{ $json['Create Article?'] }}

Type

String

Operation

is empty Combine with: AND 完成配置后,同样点击右上角的 Execute Step,Output 区域会出现筛选结果 image.png

Create Article? = ✅ 且 Status 为空的第 2 行数据出现在 true 分支,当前工作流节点结构如下:(记得随时保存工作流) image.png

接下来要让 true 分支继续走接下来的 Blog 内容创作流程。 第五步:生成 Blog 写作策略(分析搜索意图、确定标题) 这部分需要用 AI 来分析 true 分支数据的 keyword、title、description,然后生成: 最终的标题 搜索意图 写作风格、语气以及目标受众 话题的核心洞察(Insight)

点击 true 分支右边 + 添加 AI Agent 节点,填入 Prompt。 image.png

Prompt 如下,供大家参考:

You are an expert SEO content strategist. Based on the following input, analyze search intent and generate a complete writing blueprint in JSON format. Do not include commentary or markdown.

Inputs:

  • Title: {{ $json["Title"] }}
  • Keyword: {{ $json.Keywords }}
  • Description: {{ $json["Description"] }}

Output JSON structure: { "refined_title": "string", "search_intent": "informational | commercial | transactional | navigational", "writing_style": "engaging and storytelling | concise and professional | data-driven and analytical | ...", "writing_tone": "friendly | persuasive | authoritative | ...", "target_audience": "string", "goal_of_article": "string", "hidden_insight": "string", "semantic_analysis": { "common_subtopics": [ "string", "string", "..." ], "related_questions": [ "string", "string", "..." ] }, "keywords": { "primary_keyword": "string", "secondary_keywords": [ "string", "..." ], "semantic_keywords": [ "string", "..." ], "long_tail_keywords": [ "string", "..." ] } }

Respond only in JSON. No commentary. 此处添加的 Chat Model 是 OpenAI Chat Model,配置如下: image.png

点击 Execute Step 执行测试后,输出的 JSON 数据如下:

[ { "output": "{ "refined_title": "How to Use AI Video Generators to Create High-Quality Videos People Actually Watch", "search_intent": "informational", "writing_style": "data-driven and analytical", "writing_tone": "authoritative", "target_audience": "MicroSaaS founders, content creators, marketers, and entrepreneurs exploring AI video tools", "goal_of_article": "To educate readers on how to create engaging and effective AI-generated videos by focusing on user psychology, speed, and specific use cases rather than technical specs", "hidden_insight": "High-quality AI videos are defined more by user trust, speed, and contextual relevance than by resolution or features; vertical focus and urgency-based pricing are key differentiators", "semantic_analysis": { "common_subtopics": [ "psychology of user engagement in video content", "vertical positioning for AI video tools", "importance of speed and reliability over 4K quality", "pricing strategy based on urgency", "building data flywheels for AI video personalization" ], "related_questions": [ "What makes an AI-generated video high-quality?", "How do users define value in AI video content?", "Is 4K resolution necessary for effective AI videos?", "How can MicroSaaS products leverage AI video generators?", "What are the best strategies for monetizing AI-generated videos?" ] }, "keywords": { "primary_keyword": "ai video generator", "secondary_keywords": [ "ai video creation", "automated video production", "microSaaS video tools", "ai content tools" ], "semantic_keywords": [ "video engagement psychology", "vertical SaaS", "data flywheel", "AI video personalization", "video content strategy" ], "long_tail_keywords": [ "how to make AI videos people actually watch", "best ai video generator for startups", "ai video tools for niche markets", "how to price ai-generated video services", "create fast and reliable ai videos" ] }}" } ] Memory 和 Tool 不需要配置。

接下来,需要处理一下数据,把字段拆分出来,用于后续的内容创作。当前工作流节点结构如下:(记得随时保存工作流) image.png

第六步:提取写作策略字段并保存到变量中 点击 生成写作策略 AI Agent 右边 + 添加 Edit Fields (Set) 节点,设置字段,用 JSON.parse(...) 把生成写作策略 AI Agent 生成的字符串形式的 JSON 解析:

name(Fixed)

type

value(Expression)

refined_title

String

{{ JSON.parse($json["output"]).refined_title }}

search_intent

String

{{ JSON.parse($json["output"]).search_intent }}

writing_style

String

{{ JSON.parse($json["output"]).writing_style }}

writing_tone

String

{{ JSON.parse($json["output"]).writing_tone }}

target_audience

String

{{ JSON.parse($json["output"]).target_audience }}

goal_of_article

String

{{ JSON.parse($json["output"]).goal_of_article }}

hidden_insight

String

{{ JSON.parse($json["output"]).hidden_insight }}

subtopics

Array

{{ JSON.parse($json["output"]).semantic_analysis.common_subtopics }}

questions

Array

{{ JSON.parse($json["output"]).semantic_analysis.related_questions }} 点击 Execute Step 执行测试后,Output 数据正确输出格式如下: image.png

当前工作流节点结构如下:(记得随时保存工作流) image.png

第七步:生成 Blog 内容大纲 现在,我们已经完成了内部字段信息提取,接下来依据这些信息来设计 Blog 的大纲(Outline)。

点击提取写作策略关键字段右边的+ 添加 AI Agent 节点,填入 Prompt。 image.png

Prompt 如下,供大家参考:

You are an experienced SEO blog content planner. Based on the following inputs, generate a structured outline for a blog post.

Inputs:

  • Title: {{ $json["refined_title"] }}
  • Writing Style: {{ $json["writing_style"] }}
  • Tone: {{ $json["writing_tone"] }}
  • Target Audience: {{ $json["target_audience"] }}
  • Goal of Article: {{ $json["goal_of_article"] }}
  • Key Insight: {{ $json["hidden_insight"] }}
  • Subtopics: {{ $json["subtopics"].join(", ") }}
  • Questions to cover: {{ $json["questions"].join(", ") }}

Output: Respond in the following JSON format only:

{ "title": "string", "intro": "string (2-3 sentences)", "outline": [ { "h2": "Section title", "h3": ["Subsection 1", "Subsection 2"] }, ... ], "cta": "short closing paragraph" } 此处添加的 Chat Model 依然是 OpenAI Chat Model,配置如下: image.png

与上一步一样, Output 的数据是字符串形式的,依然需要处理一下数据,让它变成真正的结构化 JSON。

当前工作流节点结构如下:(记得随时保存工作流) image.png

第八步:提取 Outline 结构化字段 点击生成 Blog 大纲右边的 + 添加Edit Fields (Set) 节点,设置字段,用 JSON.parse(...) 把生成 Blog 大纲 AI Agent 式的 JSON 解析:

name(Fixed)

type

value(Expression)

title

String

{{ JSON.parse($json["output"]).title }}

intro

String

{{ JSON.parse($json["output"]).intro }}

outline

Array

{{ JSON.parse($json["output"]).outline }}

cta

String

{{ JSON.parse($json["output"]).cta }} 点击 Execute Step 执行测试后,Output 数据正确输出格式如下: image.png

当前工作流节点结构如下:(记得随时保存工作流) image.png

到这里,我们已经成功完成了一篇 Blog 的“骨架”了,接下来就是开始“长血肉”了。 第九步:生成 Blog 正文内容 前面一步我们已经拿到了 title、intro、Outline、cta 这四个结构数据,接下来就以它们为背景信息,继续完成生成 Blog 正文 AI Agent 这一节点的搭建。

点击提取标题、intro、Outline、CTA 字段 右边的 + 添加 AI Agent 节点,把打磨好的 Prompt 填进去。 image.png

这里的 Prompt 很重要,可以借助和 AI 讨论好好打磨,下面是我写的:

You are a professional content writer for my AI tools website. I'm a tech entrepreneur and AI enthusiast who curates, reviews, and recommends the best AI tools for businesses and creators. Based on the following structured outline, write a complete blog article in first-person point of view, using a knowledgeable yet approachable tone.

Write in Markdown and wrap the entire output in a single markdown code block.


My Role

  • Brand: AI Tools Expert / Independent AI Consultant / [Your Personal Brand]
  • Platform: LinkedIn / Medium / Personal Blog / Newsletter
  • Mission: Help businesses and creators discover, evaluate, and implement AI tools that boost productivity and innovation
  • About Me: I'm passionate about AI technology and have been testing and using AI tools since the early days. I've helped hundreds of businesses integrate AI into their workflows, from startups to Fortune 500 companies. I write detailed reviews, comparisons, and guides to help others navigate the rapidly evolving AI landscape. My content focuses on practical insights and real-world applications, not hype.

Blog Structure Input:

  • Title: {{ $json["title"] }}
  • Introduction: {{ $json["intro"] }}
  • Outline: {{ JSON.stringify($json["outline"]) }}
  • CTA: {{ $json["cta"] }}

Instructions:

  1. Start with the H1 title: # {{ $json["title"] }}
  2. Follow this structure for the introduction:

Intro Section

  1. Lead paragraph (≤30 words): Use the PAS formula (Problem - Agitation - Solution) to capture attention, focusing on AI-related challenges.
  2. Snippet paragraph (≤50 words): Answer the title question directly with actionable AI tool recommendations. This is designed to compete for Google Featured Snippets.
  3. [image placeholder]
  4. Add a short transition paragraph that motivates the reader to continue, mentioning your hands-on experience with these tools.
  5. Weave in the following hidden insight naturally in the introduction section, either as a separate sentence or integrated into the flow:
    • {{ $('提取写作策略关键字段').item.json.hidden_insight }}

LOOP: For each H2 section in Outline Repeat the following for each item in outline:

${section.h2}

Lead paragraph
Use PAS formula here, focusing on specific AI tool challenges or opportunities. (≤30 words)

Snippet paragraph
Answer the H2 question directly with specific tool names and key benefits. (≤50 words)

%image placeholder

Dive Deeper

${sub}

Your detailed explanation here (~150-200 words). Include:

  • Specific AI tool names and features
  • Pricing information (if relevant)
  • Personal testing experience
  • Pros and cons
  • Use case examples
  • Screenshots or feature descriptions
  • Comparison with alternatives (when helpful)

Use lists, comparison tables, or step-by-step guides when appropriate.


Tool Recommendation Box (if applicable) Insert this after relevant sections:

🚀 My Top Pick: Claude or ChatGPT Plus Best For: Content creation and technical writing Pricing: $20/month (ChatGPT Plus) / $20/month (Claude Pro) Why I Recommend It: After testing 15+ AI writing tools, Claude excels at long-form content while ChatGPT Plus is unmatched for creative brainstorming. Both maintain context well and produce human-like writing. Get Started: Visit openai.com or claude.ai - start with free versions first


Conclusion Wrap up the article with:

  1. A concise summary of key insights (≤30 words)
  2. Your personal recommendation or prediction about AI tool trends
  3. Encouragement for readers to experiment with the tools mentioned

Add the CTA: {{ $json["cta"] }}


Formatting Rules

  • Use clear, tech-savvy language that's accessible to business users
  • Keep the first-person voice consistent throughout (e.g., "I've tested...", "In my experience with...")
  • Include specific tool names, features, and pricing when relevant
  • No section labels like "Lead paragraph:", just directly write the text
  • Use [image placeholder] exactly as below each time: %[AI tool screenshot/interface](https://placehold.co/600x400 "descriptive image title")
  • Add tool comparison tables or feature lists when helpful
  • Include affiliate disclosure if mentioning paid tools: "Note: Some links may be affiliate links, but all opinions are based on my genuine testing experience."

Content Focus Areas Focus your writing on these AI tool categories:

  • Productivity AI: Writing assistants, scheduling, automation, project management
  • Creative AI: Design tools, video editors, audio generators, image creators
  • Business AI: Analytics, customer service, sales automation, lead generation
  • Developer AI: Code assistants, testing tools, deployment automation, debugging
  • Marketing AI: Content creation, ad optimization, social media management, SEO
  • Research AI: Data analysis, document processing, knowledge management
  • Workflow AI: Integration platforms, no-code automation, process optimization

Writing Guidelines

  • Start each section with a relatable problem that your target audience faces
  • Provide specific, actionable solutions with tool recommendations
  • Include personal anecdotes from your testing experience
  • Use data and metrics when available (user counts, efficiency improvements, cost savings)
  • Address common concerns (pricing, learning curve, integrations, support)
  • End sections with clear next steps or implementation advice
  • Maintain expertise while staying conversational and approachable

SEO Optimization

  • Naturally include relevant keywords throughout the content
  • Use tool names as keywords in headings when appropriate
  • Create content that answers specific questions users search for
  • Include long-tail keywords related to AI tool comparisons and reviews
  • Structure content to compete for featured snippets with direct answers

Output: A complete, high-quality Markdown article ready to be published on an AI tools website. 这个 Prompt 几个核心关键点,包括角色设定、结构框架规定、写作细则要求、格式约束以及 SEO 要求,然后根据需要补充其他的因素(比如上面提到的最佳 AI 工具、关注领域等)来进一步把握方向。

此处添加的 Chat Model 依然是 OpenAI Chat Model,配置与上一步一样: image.png

当前工作流节点结构如下:(记得随时保存工作流) image.png

现在我们已经获得了一个带 [image placeholder] 图片占位符的 Markdown 格式的 Blog,接下来我们就需要把占位符都换成真实的图片链接。

接下来需要做的是,先识别到 Blog 正文中所有的 %alt text with keywords图片占位符,提取占位符中的 alt 文本、title 信息,并抓取其上下文内容,为 AI 提供更充足地信息来生成最终的图像 Prompt。 第十步:生成 Blog 图片 Prompt 在 生成 Blog 正文右边的 + 添加 Code 节点,选择用 JavaScript 对上一步传输过来的数据进行处理,可以编写自己的逻辑。 image.png

这里 Javascript 我的思路就是:

先找到所有图片占位符,看它前后正文内容是啥,理解是在什么场景/背景下。然后在里面预先写了一些领域相关的关键词,根据关键词判断图片应该是什么风格(UI 截图?流程图?代码?图表?教程?),最后拼接成一条完整的英文 Prompt,等待传递给 AI,让 AI 去画图。 具体的 Javascript 内容是:

// 1) 输入:正文与标题 const markdown = $node["生成 Blog 正文"].json["output"] ?? ""; const refinedTitle = $node["提取标题、intro、Outline、CTA 字段"].json["title"] ?? "";

// 2) 匹配正文里的占位符 %alt const regex = /%[([^]]+)](([^ )]+)(?: "([^"]*)")?)/g; const matches = [...markdown.matchAll(regex)];

// 3) 获取上下文(占位符前后最近一行非空文本) function getContextLines(md, start, end) { const before = md .slice(0, start) .trimEnd() .split('') .reverse() .find(line => line.trim() !== '') || ''; const after = md .slice(end) .trimStart() .split('') .find(line => line.trim() !== '') || ''; return { before, after }; }

// 4) 定义 AI 工具领域关键词桶 const BUCKETS = [ { name: 'ui', terms: ['ui','interface','dashboard','panel','settings','toggle','chart','table','analytics'], style: 'clean webapp UI mockup, components grid, soft shadows, subtle gradients, high readability' }, { name: 'workflow', terms: ['workflow','pipeline','orchestration','node','trigger','webhook','cron','n8n','zapier','automation'], style: 'process flow diagram, node-link layout, clear arrows, whiteboard schematic, minimal color' }, { name: 'code', terms: ['api','sdk','endpoint','request','response','payload','cli','curl','typescript','python','json','oauth'], style: 'code editor mockup, monospace, syntax-like blocks, dark-on-light, crisp panels' }, { name: 'performance', terms: ['latency','throughput','token','context window','embedding','benchmark','accuracy','mmlu','speed','tps','qps'], style: 'performance chart infographic, line and bar charts, data-first minimal grid' }, { name: 'integrations', terms: ['integration','webhook','slack','github','notion','google sheets','drive','zapier','make','airtable'], style: 'integration network diagram, abstract app glyphs (no brand logos), connection lines' }, { name: 'security', terms: ['security','privacy','encryption','gdpr','soc2','hipaa','permissions','rbac','audit','compliance'], style: 'minimal policy infographic, abstract shield/lock shapes, sober palette' }, { name: 'pricing', terms: ['pricing','plans','tier','quota','credit','billing','seat','usage','limit'], style: 'pricing table infographic, clear columns, comparison layout, minimal hierarchy' }, { name: 'tutorials', terms: ['use case','tutorial','guide','example','template','quickstart','step-by-step'], style: 'step-by-step storyboard, numbered blocks, clean annotation style' }, ];

// 5) 简单打分函数:命中关键词次数 const scoreBucket = (bucket, text) => bucket.terms.reduce((acc, term) => acc + (text.includes(term) ? 1 : 0), 0);

// 6) 遍历所有占位符并生成 item const items = matches.map(m => { const original = m[0]; const alt = m[1]; const url = m[2]; const title = m[3] ?? ""; const start = m.index; const end = start + original.length; const { before, after } = getContextLines(markdown, start, end);

// 关键词拼接 const titleL = (title ?? '').toLowerCase(); const altL = (alt ?? '').toLowerCase(); const contextL = ${(before ?? '').toLowerCase()} ${(after ?? '').toLowerCase()}.trim(); const keywords = ${titleL} ${altL} ${contextL};

// 选择得分最高的桶 let best = { name: 'default', score: 0, style: 'clean product-tech visualization, neutral background, editorial-tech hybrid look' }; for (const b of BUCKETS) { const s = scoreBucket(b, keywords); if (s > best.score) best = { name: b.name, score: s, style: b.style }; }

let style_hint = best.style;

// 安全约束:不要真实 Logo 或可读文本 const style_guardrails = 'no real brand logos, no trademark icons, use abstract app shapes, avoid readable UI text blocks';

// 清洗上下文 const rawContext = ${before ?? ''} ${after ?? ''}; const cleanContext = rawContext .replace(/[\r]+/g, ' ') .replace(/#+/g, '') .replace(/\s+/g, ' ') .trim();

const cleanTitle = (title ?? '').replace(/["]/g, '').trim(); const cleanMainTitle = (refinedTitle ?? '').replace(/["]/g, '').trim();

// 最终 Prompt const prompt = Create a product-tech visualization for a blog article titled: ${cleanMainTitle}. Scene Description: ${cleanContext} Focus on illustrating the idea: ${cleanTitle}. Do not include readable text, logos, or brand names in the image. ${style_guardrails}. Style: ${style_hint} .replace(//g, ' ').replace(/\s+/g, ' ').trim();

return { json: { alt, url, title, original, refined_title: refinedTitle, start, end, context_before: before, context_after: after, keywords, style_hint, image_prompt: prompt, } }; });

// 7) 输出 return items; 现在,已经为每一个位置需要放置图片的地方写好了图片的 Prompt,当前工作流节点结构如下:(记得随时保存工作流) image.png

第十一步:生成真实图片链接 Prompt 是纯文本的,我选择了 fal.ai 上的文生图模型 fal-ai/imagen4/preview。因为 n8n 没有原生支持 fal.ai 平台,所以需要通过 HTTP Request 集成 API。

这一步涉及到图片生成的轮询逻辑,先附上一张这一步完成的时候从生成 Blog 图片 Prompt 节点开始之后新建的工作流节点结构: image.png

这个轮询逻辑是这样子搭起来的,我们用去餐厅点菜为比喻:

你和朋友一起去餐厅吃饭,落座之后拿手机扫码点餐,一通商量把你和朋友想吃的都添加进来,然后提交订单。 对应向 Fal.ai 提交需求节点

这时候你和朋友在座位上边聊天,边等着菜端上来,你两偶尔张望一下。 对应生图等待时间节点

此时,服务员端上来一道、两道。等了好长时间,第三道还没上来,你叫来了服务员,询问情况。过一会儿,第三道菜上来了。 这里是轮询,等好久 ➡️ 叫服务员询问,对应检查图片是否完成节点。服务员反馈,菜上来了,你和朋友继续吃。

但第四道菜磨磨唧唧的,还是一直不来,你又叫来了服务员,服务员解释说今天餐厅比较忙,会告诉后厨给加急。 (虽然一直不来,但是你不能跑到后厨盯着厨师给你做,只能叫来服务员再次询问。) 这里还是轮询,但叠加了一个逻辑。基础轮询逻辑是等菜➡️询问➡️菜来了结束。叠加轮询逻辑是你再次询问,就在内心记了一笔小账,是否在心理预期之内。但你若去后厨盯着,就会陷入死循环(站在厨师身边,一直碎碎念),影响餐厅整体运作,况且你也进不去,哈哈。这里对应计数器节点和计数+1节点

又又又过了好久,你和朋友的三道菜快吃完了,也要吃饱了,第四道菜还没来,你叫来服务员,说要把第四道菜取消。 对应次数≤15 次节点和超时退出节点,因为询问次数和等待时间超过心理预期,主动退出 通过比喻,图片生成工作流的搭建思路清晰了起来: 最基础的流程 生成 Blog 图片的 Prompt ➡️ 向 Fal.ai 提交需求【HTTP Request】 image.png

其中的信息要根据选择的模型 API 调用文档填写,现在需求提交上去了,那问题来了:它不能马上给你结果,你得等等 加一个等待 生图等待时间(6s)【Wait】 image.png

这个等待的时间间隔可以参考选择的模型 playground 生图的时间设定。 检查结果 检查图片是否完成【HTTP Request】 过了设定的时间间隔,我这里是 6s,去看看好了没? image.png

那问题又来了:没好的,咋整啊?那就需要继续等待咯~ 加循环逻辑 图片完成了?【If】 image.png

如果完成了 ➡️ true;如果没完成 ➡️ 进入循环。 那问题又来了:如果一直没完成,就会陷入无限循环中。我们该怎么办呢?有办法,设定一个限定值,避免陷入死循环,反复请求会浪费 API 且占用工作流运行资源。 加计数器 计数器【Set】:从 0 开始计数 image.png

计数+1【Set】:每检查一次,计数就加一 image.png

次数≤15 次【If】:这个次数也自己选择。 image.png

如果次数没超过限定,就继续(true);超过了(false),就退出。 加超时处理 超时退出【Set】 image.png

刚说完了检查图片没完成(false)要如何处理,可是还有图片完成了(true)。 加拿结果 获得图片链接【HTTP Request】 image.png

这一步 Output 的 JSON 数据是这样子的:

[ { "images": [ { "url": "https://v3.fal.media/files/koala/v9ig-GmWj63KLvNDpuhv6_output.png", "content_type": "image/png", "file_name": "output.png", "file_size": 552392 } ], "seed": 519655042 }, { "images": [ { "url": "https://v3.fal.media/files/penguin/SmPL3wGxOu0PsT9q188mC_output.png", "content_type": "image/png", "file_name": "output.png", "file_size": 532169 } ], "seed": 1475785855 }, { "images": [ { "url": "https://v3.fal.media/files/kangaroo/3A4ZEFa_MxYDvWG2EC5-r_output.png", "content_type": "image/png", "file_name": "output.png", "file_size": 446243 } ], "seed": 3030669080 }, { "images": [ { "url": "https://v3.fal.media/files/rabbit/vXVMonUYjfKeEQvX4-tyE_output.png", "content_type": "image/png", "file_name": "output.png", "file_size": 477114 } ], "seed": 1886825482 }, { "images": [ { "url": "https://v3.fal.media/files/lion/MXdbV5sX-5vqIQLxKxj-Z_output.png", "content_type": "image/png", "file_name": "output.png", "file_size": 372302 } ], "seed": 2163942301 }, { "images": [ { "url": "https://v3.fal.media/files/koala/4FFGE5TJXwHqAbeB4YRrA_output.png", "content_type": "image/png", "file_name": "output.png", "file_size": 160975 } ], "seed": 572441937 }, { "images": [ { "url": "https://v3.fal.media/files/panda/ovjkYbk1UMqxAxConq585_output.png", "content_type": "image/png", "file_name": "output.png", "file_size": 648993 } ], "seed": 2989384905 }, { "images": [ { "url": "https://v3.fal.media/files/elephant/vtUvKCPk-s-32CLKAeRvP_output.png", "content_type": "image/png", "file_name": "output.png", "file_size": 365729 } ], "seed": 3633955326 } ] 需要把其中的 images URL 都提取出来。 第十二步:提取图片链接 点击获得图片链接节点右边的 + 添加 Code 节点来提取图片链接,因为后面要与 Blog 正文内容进行合并,所以这里选择将图片链接合并成一个数组字段输出。

在生成 Blog 正文中,图片是这样子占位的:

第一段内容 ... %AI video generation workflow

第二段内容 ... %AI tool comparison dashboard

...... 这些包含 %alt_text是提前做好的「信号标记」,等着真实的图片链接替换进去。

如果图片链接是这样子的:

[ { "image_url": "https://img1.png" }, { "image_url": "https://https://img2.png" }, { "image_url": "https://img3.png" } ] 图片是一条条的 item,在后续节点与 Blog 正文合并的时候就比较难处理。如果合并成数组字段,就是下面这样子:

{ "image_urls": [ "https://img1.png", "https://img2.png", "https://img3.png" ] } 在后面做真实图片链接替换占位符的时候,就可以用 image_urls[index] 灵活替换了。

点击本节点的 Execute Step 执行测试,就得到了如下图的图片数组字段: image.png

第十三步:将 Blog 正文与图片链接数组合并 添加一个 Merge 节点,input 1 连接生成 Blog 正文节点,input 2 连接提取图片链接节点。节点的配置如下: image.png

Mode 节点一共有 4 种模式,分别是: Append:把 input 1 的内容放在前面,input 2 的内容接在 input 后面。只是简单拼接,不合并。 Combine:把 input 1 和 input 2 合成到一个对象中。 SQL Query:用类 SQL(数据库查询语法)来定义合并逻辑。 Choose Branch:只输出某个 input 项。 image.png

这个节点的目的是把 Blog 正文内容和图片链接数组合并到一起,所以选择 Combine 这个 Mode 模式。

选择 Combine 模式后,Combine By 有 3 种方式,分别是: Matching Fields(按字段匹配) Position(按顺序对应) All Possible Combinations(所有可能组合,交叉连接)

Blog 正文内容和图片链接数组没有公共字段,这里就选择按 Position。

因为只需要将 Blog 正文与图片链接数组合并,所以 Number of Input 设置为 2。

Settings 页面开启 Execute Once是指无论有多少输入项,此节点都只执行一次,这是为了避免得到一堆重复的正文内容和图片。

截止到目前,当前工作流节点结构如下:(记得随时保存工作流) image.png

第十四步:替换 Blog 正文中的占位符 这个部分的逻辑是先读取到 Blog 正文中的占位符图片链接(比如 https://placehold.co/600x400),然后用真实图片连接数组把占位符一个个替换成真实图片链接。

这里使用 Code 节点,经过多次调整,考虑到最终文件需要纯 Markdown、需要同时兼容 %alt 和 两种占位语法、不让 image_urls 数组继续传递弄脏数据、统计图片链接替换情况等,最终优化配置的 Javascript 内容如下:

return items.map(item => { const markdownRaw = (item.json.output ?? '').toString();

// 读取并清洗图片数组 const imageUrlsRaw = Array.isArray(item.json.image_urls) ? item.json.image_urls : []; const imageUrls = imageUrlsRaw.filter(Boolean).map(String);

// 当图片不够时是否强制使用备用图 const USE_FALLBACK = false; const FALLBACK_URL = 'https://placehold.co/600x400?text=Image+Missing';

// 输出里是否保留 image_urls(建议生产禁用,避免脏字段传下游) const KEEP_IMAGE_ARRAY = false;

// 去掉可选的 markdown 包裹,得到纯 Markdown const stripCodeFence = (text) => { return text .replace(/^(?:markdown)?\s*/i, '') .replace(/\s*```$/i, ''); }; let markdown = stripCodeFence(markdownRaw);

// 统计 let used = 0; const totalImages = imageUrls.length;

// 统计当前文档的占位符数量(双语法) const rePercent = /%[[^]]+](((?:https?://)?placehold.co/[^\s)]+)(\s+"[^"]")?)/g; const reBang = /![[^]]](((?:https?://)?placehold.co/[^\s)]+)(\s+"[^"]*")?)/g; const placeholdersCount = (markdown.match(rePercent) || []).length + (markdown.match(reBang) || []).length;

// 统一的替换辅助函数 const replaceWith = (match, altText, _placeholderUrl, titlePart = '', wrap) => { const nextUrl = imageUrls[used]; if (nextUrl) { used++; return ${wrap}[${altText}](${nextUrl}${titlePart || ''}); } if (USE_FALLBACK) { return ${wrap}[${altText}](${FALLBACK_URL}${titlePart || ''}); } return match; // 不足则保留占位符 };

// 先处理 %[Alt](placehold...) markdown = markdown.replace( /%[([^]]+)](((?:https?://)?placehold.co/[^\s)]+)(\s+"[^"]*")?)/g, (m, alt, url, title) => replaceWith(m, alt, url, title, '%') );

// 再处理 ![Alt](placehold...) markdown = markdown.replace( /![([^]])](((?:https?://)?placehold.co/[^\s)]+)(\s+"[^"]")?)/g, (m, alt, url, title) => replaceWith(m, alt, url, title, '!') );

// 质量标记:是否还有 placehold.co 遗留 const hasPlaceholderLeft = /(https?://)?placehold.co//i.test(markdown);

const base = { ...item.json, output: markdown, // 纯 Markdown _images_used: used, _images_total: totalImages, _placeholders_found: placeholdersCount, _placeholders_left: hasPlaceholderLeft };

// 是否保留 image_urls if (KEEP_IMAGE_ARRAY) { base.image_urls = imageUrls; } else { // 移除,避免“输出内容中还列出图片数组” delete base.image_urls; }

// 额外给一个总体验证标记,IF 节点可直接用 base._ok = (used === Math.min(placeholdersCount, totalImages)) && !hasPlaceholderLeft;

return { json: base }; }); 在这段 Javascript 代码的最后,用 base._ok 作为一个质量检查标志,只有在实际替换掉的数量等于理论上能替换的最大值且正文中不再有占位符的时候,base._ok= true。 第十五步:添加质量检查 添加 If 节点来检查是否实现base._ok= true?。只有实现的时候,才符合写入 Google Docs 或者直接发布。 image.png

第十六步:创建 Google Docs 并写入 Blog 内容 每个 Blog 需要一个单独的 Blog,先点击base._ok= true?节点 true 分支的 + 添加 Google Docs Create a document节点,先创建一个新的 Google Docs,获得一个 Doc ID。 image.png

然后在 Google Docs Create a document 右边的+ 添加 Google Docs Update a document节点,把内容写到刚刚那个 ID 的 Google Docs 中。 image.png

现在,可以查看一下刚创建的这个 Google Docs image.png

截止到目前,当前工作流节点结构如下:(记得随时保存工作流) image.png

第十七步:更新 Google Sheets 现在一篇完整的 Blog 就完成了,还记得游戏开始的那个 Google Sheets 中的「Status」和 「Google Docs URL」,我们要把这篇 Blog 的这两项填写好啦~

点击写入 Blog 内容节点右边的+ 添加Google Sheets Update row in sheet节点。这个节点配置的关键点在于,需要准确找到要填入信息的行。我这里选择了用 row_number 来匹配,原因是 天然唯一性:row_number 是 Google Sheet 中行的编号(第几行),天然唯一且稳定。 无需额外字段:工作流中使用了 Get row(s) in sheet 节点,它会自动带上 row_number。 不受后续编辑干扰:即便后来更新了 title、URL、status 等内容,仍能正确匹配。 image.png

现在表格中关于这篇 Blog 的信息就全部更新完成了。 image.png

经过这十七步走,这篇 Blog 的游戏就 Over 了,完整的工作流结构如下: image.png

看看“疗效” 我选取了在写这篇帖子的时候新出炉提交的一篇 Blog 内容来给大家展示一下。在写完 Blog 内容发布之后,我主动通过 GSC(Google Search Console)的网址检查进行了主动提交,这里显示的 image.png

从网站的站点地图查看一下, image.png

从上面两张截图的情况来看: 上次抓取时间:2025-08-28 13:39:56,说明 Googlebot 在这个时间访问了页面,确认能抓取并允许收录,但此时不一定是最终出现在搜索结果的时间。 Last update:2025-08-28T14:04:03+08:00,这是我的网站自动生成的 sitemap 文件里记录的时间,表示该 URL 在网站侧被标记为最近更新/创建的时间。 因为 sitemap 是定时生成的(比如 WordPress 插件每隔几分钟刷新),所以出现了 抓取时间稍早于 Last update 时间 的情况。这两个时间相差只有几十分钟,说明 Google 抓取非常及时,几乎实时响应了 sitemap 的提示。

接着来看一下搜索结果端,8月28日这篇 Blog 首次进入了 Google 搜索结果页(SERP)并被用户看见。 image.png

从发布 → 抓取 → 有展现,全部在同一天完成,这应该属于 非常快 的收录节奏了。 以前的我 vs 现在的我 Blog Writing 经历的 3 个阶段:

传统外包模式:外包平台招聘写手 image.png

AI 辅助模式 image.png

自动化工作流 image.png

一次工作流的搭建,能把更多的时间投入到「展示第一手知识和实践经验(经验),展示深刻的理解和资格(专业知识),通过来自可靠来源的链接和提及建立声誉(权威性),并通过提供安全、专业、透明和无错误的网站来建立信任(可信度)即 Google E-E-A-T」的内容创作中去。 写在最后 后续,在模型方面,计划把生文的模型替换成表现文字处理上更好的 Claude;文生图模型替换为 gpt-image-1 或者 Google 最新发布的 Nano Banana(大家反应信息图的表现上不错);生成 Blog 图片 Prompt 这个节点其实是结合标题、上下文对字段进行了处理,可以发送给 AI 生图之前,再添加一个 AI Agent 对 生成 Blog 图片 Prompt 进行处理,让图片 Prompt更专业、精准。

其次,base._ok= true?节点的 false 分支在工作流中没有搭建,后面可以接入 Gmail 或者飞书等接收出现异常的通知,进行人工排查处理。

另外,在前面提到过表格中 description 目前我没有完全交给 AI 来研究分析完成,会去思考如何用 AI 针对内容话题结合搜索结果情况有更好的表现。

以上,就是「从 0 到 1 搭建 Blog Writing 工作流」所有的内容了,如果对大家有帮助,是我的荣幸,我很开心。

工作流的搭建我也是一边摸索一边调整,也报名了新一期航海的 n8n 航线,希望和大家一起学习、摸索、搭建 better performance 的工作流,因为它跑起来的样子真的很 happy。欢迎大家多交流指正,一起来迭代优化让工作流有更好地表现。

你可能还想读

想了解生财有术?

先看看体验卡,再决定是否适合你。

查看生财体验卡