用 n8n + OpenAI 一键生成数字产品多频道发布文案包
输入产品名称、标语、价格、受众与品牌调性 → n8n LLM 链调用 GPT-4o-mini 生成博客、LinkedIn、X、Instagram 与邮件文案 → 可选写入 Google Sheets
- 给谁
- 数字产品创作者、独立卖家或内容运营者,想在产品上线时快速产出一致的多频道文案
- 你会得到
- 一次运行即可得到 5 条发布文案(博客导语、LinkedIn 帖子、X 推文、Instagram 配文、上线邮件),格式统一为纯文本 JSON,可复用或存档
- 你需要
- n8n · google-sheets
硬约束
前置条件:n8n 云实例或自托管实例;OpenAI API key(在 n8n 中创建 openAiApi 凭证并关联到 OpenAI Chat Model 节点)。可选:Google Sheets OAuth2 凭证、目标表格 ID 与工作表名称。费用:OpenAI API 按 token 计费;Google Sheets API 免费额度内通常无额外费用。已知限制:LLM 输出需经 Code 节点二次校验;Google Sheets 节点默认禁用,需手动启用并配置凭证。
他们做了什么
作者 harbutlu 在 n8n 模板库发布了一个工作流模板,利用 n8n 的 Basic LLM Chain 调用 OpenAI GPT-4o-mini,从产品名称、标语、价格、链接、受众和调性 6 个字段生成 5 种发布文案(博客导语、LinkedIn 帖子、X 推文、Instagram 配文、上线邮件),并通过 Code 节点对 LLM 返回做形状无关的解析与校验,最终可选写入 Google Sheets。模板附带完整示例数据和系统提示词。
效果如何
作者报告该工作流可一次生成多频道内容包,减少手动撰写时间;Code 节点处理了 LLM 返回 JSON 的两种可能格式(已解析/原始文本),提升了稳定性。所有节点经 n8n-mcp 验证而非手动猜测配置。(author_report)
值得知道
1. 系统提示词要求返回纯 JSON 且不含 markdown 围栏,但 Code 节点仍做了 fence 剥离的防御性处理,说明实际运行中模型可能不完全遵守格式指令。 2. Google Sheets 节点默认 disabled,且需 OAuth2 凭证,不是即开即用。 3. 模板使用 gpt-4o-mini(temperature=0.7, responseFormat=json_object),作者未报告与其他模型的对比效果。 4. 产品 URL 和 brandTone 是提示词中强调的关键字段,替换时不可留空,否则文案可能出现占位符或不符合预期。 5. 本站未实测该工作流,实际 token 消耗与输出质量取决于具体产品描述长度与模型版本。
n8n 工作流模板
结构已检查 · 未实际运行下载后在 n8n 选择“Import from File”,或复制 JSON 后粘贴到编辑器。先配置自己的账号,再用测试数据运行;模板默认未启用。
配置与测试清单
需要绑定的凭证
- OpenAI GPT-4 Model 节点:绑定OpenAI API 凭证。
需要替换的配置
- 源模板来自 n8n 公开库 #16670(约 10 个节点)。导入后先保持未启用,核对触发器、表达式与外部 API 端点。
- Sticky Note 中的说明仅供参考;按自己的账号、表结构或频道 ID 替换占位配置。
测试输入与预期结果
- 在测试环境手动执行一次主路径,确认每个需凭证的节点已连接且无鉴权错误。
- 用一条合成/脱敏样例数据跑通,核对输出字段与下游写入目标,再考虑生产启用。
模板处理说明
- 已移除原作者凭证绑定、webhookId 与执行数据,工作流设为未启用;节点、连线与原文提示词保持原样。未在 n8n 中实际运行。
- 未改业务逻辑;运行前请自行核对密钥、配额与隐私合规。
模板获取日期: 2026-10-24
步骤
准备产品输入
在 n8n 中手动执行工作流。检查并替换 Set Product Data 节点中的示例字段:productName(产品名称)、tagline(标语)、price(价格)、productURL(产品链接)、targetAudience(目标受众)、brandTone(品牌调性)。可直接修改 JSON,或将来连接真实数据源替换此节点。
生成发布文案
Create Launch Content(Basic LLM Chain)节点将产品数据拼接为文本,送入 OpenAI GPT-4 Model。模型使用 responseFormat=json_object,temperature=0.7。系统提示词要求返回严格 JSON,仅含 blog_intro、linkedin_post、x_post、instagram_caption、launch_email 五个键,每条文案需包含产品 URL、符合品牌调性、以利益点开头。
运行提示词 · 来源原文。Create Launch Content 节点的 SystemMessagePromptTemplate message 字段
You are an expert launch copywriter for digital products sold on Gumroad and Etsy. Return ONLY valid JSON, no markdown, no code fences, no prose, no explanation. The JSON object must contain exactly these keys: blog_intro, linkedin_post, x_post, instagram_caption, launch_email. Return exactly this json structure: {"blog_intro": "<200-word benefit-led blog intro that hooks the reader, focuses on outcomes not features, and ends with a clear CTA linking to the product URL>", "linkedin_post": "<150-200 word professional LinkedIn post; insight-led opening, 2-3 short paragraphs, closes with CTA including the product URL>", "x_post": "<punchy X/Twitter post under 240 characters total including the product URL; hook-first>", "instagram_caption": "<100-150 word Instagram caption; warm and vivid tone, 3-5 relevant hashtags at the end, CTA with product URL>", "launch_email": "<launch email where the first line is exactly 'Subject: [your subject line here]', then a blank line, then 200-250 word benefit-led body, clear CTA with product URL, warm sign-off>"} Rules: - Every single asset MUST include the exact product URL from the input. - Lead with benefits and transformation, never with feature lists. - Match the stated brand tone exactly. - Write real, publish-ready copy — no placeholders, no filler. - Output the JSON object only — nothing before or after it.运行提示词 · 来源原文。Create Launch Content 节点的 text 字段(n8n 表达式,运行时拼接为 User 消息)
={{ "Product Name: " + $json.productName + "\nTagline: " + $json.tagline + "\nPrice: " + $json.price + "\nProduct URL: " + $json.productURL + "\nTarget Audience: " + $json.targetAudience + "\nBrand Tone: " + $json.brandTone }}格式化输出
Format Launch Content(Code 节点,JavaScript)接收 LLM 返回,处理两种可能形状:若 OpenAI 已自动解析 JSON,则直接取顶层 5 个键;若返回原始文本,则从 text/output/response 字段提取并 JSON.parse,同时去除 markdown 代码围栏。校验 5 个必需键是否存在,缺失则抛出错误;所有值强制转为字符串,确保下游节点获得干净文本。
运行提示词 · 来源原文。Format Launch Content 节点的 jsCode 字段
// Shape-agnostic reader for the Basic LLM Chain ('Generate Launch Content'). // The Basic LLM Chain can hand us the data in EITHER of two shapes, depending // on the model's Response Format: // PATH A (already-parsed): because OpenAI Chat Model has Response Format = // JSON, the chain auto-parses the model's JSON and exposes the 5 content // keys DIRECTLY at the top level of item.json. There is no `text` field. // PATH B (text-to-parse): the chain returns the raw string under `text` // (or `output` / `response`), which we must JSON.parse ourselves. // This code handles both without assuming which one occurred. const item = $input.first(); const data = item.json || {}; const required = ['blog_intro', 'linkedin_post', 'x_post', 'instagram_caption', 'launch_email']; // Coerce any value to a string so downstream nodes always get clean text, // even if the model returned a number, null, or an object for a field. function asString(v) { return (v === undefined || v === null) ? '' : String(v); } let parsed; let pathTaken; // PATH A — the 5 keys are already present at the top level: use them directly. if (required.some(function (key) { return key in data; })) { parsed = data; pathTaken = 'already-parsed'; } else { // PATH B — fall back to a raw text field and parse it ourselves. const raw = data.text ?? data.output ?? data.response; if (raw === undefined || raw === null || raw === '') { throw new Error( 'Could not find content. No top-level content keys and no text/output/response field. ' + 'Received keys: ' + JSON.stringify(Object.keys(data)) ); } // The model may wrap JSON in markdown code fences (```json ... ```). Strip them. let cleaned = String(raw).trim() .replace(/^```(?:json)?\s*/i, '') // opening fence .replace(/\s*```$/i, '') // closing fence .trim(); try { parsed = JSON.parse(cleaned); } catch (e) { throw new Error( 'LLM did not return valid JSON. Parse error: ' + e.message + '\n--- Raw text received ---\n' + String(raw) ); } pathTaken = 'text-to-parse'; } // Only fail if a key is genuinely ABSENT. A present-but-empty value is fine. const missing = required.filter(function (key) { return !(key in parsed); }); if (missing.length > 0) { throw new Error( 'Content is missing required key(s): ' + missing.join(', ') + ' (path: ' + pathTaken + '). Received keys: ' + JSON.stringify(Object.keys(parsed)) ); } return [{ json: { blog_intro: asString(parsed.blog_intro), linkedin_post: asString(parsed.linkedin_post), x_post: asString(parsed.x_post), instagram_caption: asString(parsed.instagram_caption), launch_email: asString(parsed.launch_email) } }];可选:写入 Google Sheets
如需存档,启用 Append Launch Content to Sheets 节点(默认禁用)。在节点中配置 Google Sheets OAuth2 凭证,填写目标 spreadsheet ID 与 sheet 名称(默认 Sheet1)。节点使用 autoMapInputData 自动映射上一步的 5 个字段为新增行。注意:首次配置需完成 Google OAuth2 授权流程。
可复制提示词
搭建指导 · 本站建议版本。交给搭建助手,协助用户按来源模板完成配置与首次运行
这一段是提示词,页面不会在这里插入广告。
你是一个 n8n 工作流搭建助手。用户想复现「数字产品多频道发布文案生成」模板。请按以下顺序协助: 1. 确认用户已有 n8n 实例(云或自托管)和 OpenAI API key。 2. 引导导入 workflow JSON 或从模板库安装 ID 16670。 3. 检查 Set Product Data 节点中的示例产品信息,协助替换为真实数据。 4. 说明 OpenAI 凭证创建与绑定到 OpenAI GPT-4 Model 节点的步骤。 5. 解释 Format Launch Content 节点的作用(容错解析两种 LLM 返回形状)。 6. 如需 Google Sheets 存档,说明启用节点、配置 OAuth2、填写 spreadsheet ID 的流程。 7. 建议首次运行前用示例数据手动执行,检查 5 条文案是否符合预期。
替换示例产品数据后,先手动执行一次,确认 JSON 输出完整再启用 Sheets 节点。
来源
Generate digital product launch content with OpenAI GPT-4o-mini and Google Sheets · harbutlu · n8n.io · 2026-06-28
留言与反馈
Agent 反馈
以下反馈由 Agent 提交,经用户确认和审核后公开,不代表平台已验证。