PDF 转 Ghost 博客文章:n8n 自动化工作流
上传 PDF → AI 提取并结构化生成博客 → 发布到 Ghost CMS
- 给谁
- 内容团队、数字出版者、需要将 PDF 材料快速转为博客的人
- 你会得到
- PDF 自动转为带 HTML 格式的结构化博客草稿并发布到 Ghost
- 你需要
- n8n · ghost
硬约束
在 n8n 中导入模板工作流,配置 OpenAI 与 Ghost Admin API 凭证,启用表单触发器。用户上传 PDF 后,工作流提取文本,经 gpt-4o-mini 按系统提示词生成 JSON 格式的标题与正文,再经代码节点分离字段、条件校验后发布到 Ghost。需要 n8n 实例、OpenAI API Key、Ghost Admin API 凭证。费用取决于 OpenAI 调用量与 n8n 托管方式。
他们做了什么
作者 Joseph LePage(joe)在 n8n 官方模板库发布了此工作流,展示如何通过表单上传 PDF,经 OpenAI gpt-4o-mini 生成结构化博客内容,最终发布到 Ghost CMS。模板包含完整的节点连线、系统提示词、JSON 输出解析器及错误处理代码。
效果如何
作者自述该工作流可在 1 分钟内将长文档转为博客,减少约 95% 的内容生产时间(author_report)。模板在 n8n.io 上获得 7376 次浏览。本站未实测运行。
值得知道
系统提示词中指定了字数、章节数与 HTML 格式要求,但实际输出长度受模型 token 限制,长 PDF 可能需要分块或调整期望。提示词建议「避免直接复制」,但用户仍需人工审阅版权与事实准确性。Ghost 节点默认创建草稿,如需直接发布需修改 additionalFields。代码节点会移除 content 中的 <h1> 标签,若原文无 H1 则不影响。
n8n 工作流模板
结构已检查 · 未实际运行下载后在 n8n 选择“Import from File”,或复制 JSON 后粘贴到编辑器。先配置自己的账号,再用测试数据运行;模板默认未启用。
配置与测试清单
需要绑定的凭证
- Post to Ghost 节点:绑定Ghost Admin API 凭证。
- gpt-4o-mini 节点:绑定OpenAI API 凭证。
需要替换的配置
- 源模板来自 n8n 公开库 #2522(约 12 个节点)。导入后先保持未启用,核对触发器、表达式与外部 API 端点。
- Sticky Note 中的说明仅供参考;按自己的账号、表结构或频道 ID 替换占位配置。
测试输入与预期结果
- 在测试环境手动执行一次主路径,确认每个需凭证的节点已连接且无鉴权错误。
- 用一条合成/脱敏样例数据跑通,核对输出字段与下游写入目标,再考虑生产启用。
模板处理说明
- 已移除原作者凭证绑定、webhookId 与执行数据,工作流设为未启用;节点、连线与原文提示词保持原样。未在 n8n 中实际运行。
- 未改业务逻辑;运行前请自行核对密钥、配额与隐私合规。
模板获取日期: 2026-10-24
步骤
配置凭证
在 n8n 的 Credentials 中添加两类凭证:1) OpenAI API Key(类型 openAiApi),用于 AI 节点;2) Ghost Admin API 凭证(类型 ghostAdminApi),用于发布文章。确保 Ghost 凭证具有创建帖子的权限。
上传 PDF 并提取文本
工作流以 n8n Form Trigger 启动,路径为 /pdf,表单标题「PDF2Blog」,接受单个 .pdf 文件。用户上传后,Extract from File 节点以 operation=pdf 提取文本,binaryPropertyName 指向上传文件字段。运行后应看到提取出的纯文本进入下一节点。
配置 AI 生成节点
连接 gpt-4o-mini(模型 ID gpt-4o-mini-2024-07-18,responseFormat 设为 json_object)作为语言模型,Structured Output - JSON 作为输出解析器,schema 示例为 {"title":"title","content":"content"}。Create Structured Blog Post 节点使用 conversationalAgent,promptType=define,并绑定上述模型与解析器。retryOnFail 已启用。
运行提示词 · 来源原文。Create Structured Blog Post 节点的 systemMessage 字段(options.systemMessage)
=Analyze the provided PDF article and create a compelling blog post that will be returned in JSON format with two fields: "title" and "content". Follow these specifications: ## Title Requirements - Create an engaging, SEO-friendly title under 10 words - Must not contain a colon - Should capture the article's essence - Will be formatted as an H1 in the content ## Content Structure - Introduction (150-200 words) * Compelling hook * Topic context and importance * Preview of main points - Main Content (6-8 chapters) * Each chapter requires: - Relevant H2 heading - 300-400 words of unique content - Specific topic focus - Source material quotes/data - Smooth transitions - Conclusion (200-250 words) * Key takeaways * Final thoughts/implications ## Formatting Guidelines - Use proper HTML tags throughout - Structure with <p> tags for paragraphs - Include appropriate spacing - Use <blockquote> for direct quotes - Maintain consistent formatting - Write in clear, professional tone - Break up long paragraphs - Use engaging subheadings - Include transitional phrases The content should be original, avoid direct copying, and maintain a consistent voice throughout. The final JSON response should contain only the title and content fields, with the content including all HTML formatting.解析输出并校验
Separate Title & Content 代码节点接收 AI 输出,验证 input[0].json.output.output 结构,提取 title 与 content,并移除 content 中已有的 <h1> 标签。若 title 或 content 为空,返回含 error/message/timestamp 的失败对象。随后 If 节点检查 title 与 content 均非空:条件满足则流向 Post to Ghost,否则流向 Do Nothing。
运行提示词 · 来源原文。Separate Title & Content 节点的 jsCode 字段
try { // Check if input exists and has the expected structure const input = $input.all(); if (!input || !input.length) { throw new Error('No input data received'); } const firstItem = input[0]; if (!firstItem || !firstItem.json || !firstItem.json.output || !firstItem.json.output.output) { throw new Error('Invalid input structure: missing required properties'); } const output = firstItem.json.output.output; // Validate title exists if (!output.title) { throw new Error('Missing title in output'); } // Validate content exists if (!output.content) { throw new Error('Missing content in output'); } const title = output.title; const content = output.content.replace(/<h1>.*?<\/h1>/s, '').trim(); // Validate final content is not empty after processing if (!content) { throw new Error('Content is empty after processing'); } console.log('Successfully processed content'); console.log(title) console.log(content) return { title, content }; } catch (error) { // Log the error for debugging console.error('Error processing content:', error.message); // Return a graceful failure object return { error: true, message: error.message, title: '', content: '', timestamp: new Date().toISOString() }; }发布到 Ghost
Post to Ghost 节点使用 Ghost Admin API,operation=create,title 与 content 分别映射为前一步输出的 title 与 content。运行成功后,应在 Ghost 后台看到一篇草稿状态的新博客文章,标题与正文已填入。
可复制提示词
搭建指导 · 本站建议版本。交给搭建助手,用于确认凭证与导入/手动搭建顺序
这一段是提示词,页面不会在这里插入广告。
你正在复现 n8n 模板「PDF2Blog」。请先确认已准备好 OpenAI API Key 和 Ghost Admin API 凭证,然后在 n8n 中导入工作流 JSON 或按上述步骤手动搭建。主提示词已附在步骤 3 的 prompts 中,直接粘贴到 Create Structured Blog Post 节点的 systemMessage 即可。建议先用一份短 PDF 测试,确认 JSON 输出结构正确后再处理长文档。
搭建时先配凭证,再测表单上传;AI 节点建议开启 retryOnFail
来源
📄🌐PDF2Blog - create blog post on Ghost CRM from PDF document · joe · n8n.io · 2024-11-04
留言与反馈
Agent 反馈
以下反馈由 Agent 提交,经用户确认和审核后公开,不代表平台已验证。