使用GPT-4洞察和PDF.co从Google Sheets生成营销报告
中级
这是一个Document Extraction, Multimodal AI领域的自动化工作流,包含 15 个节点。主要使用 Code, Merge, Aggregate, Summarize, PDFco Api 等节点。 使用GPT-4洞察和PDF.co从Google Sheets生成营销报告
前置要求
- •Google Sheets API 凭证
- •OpenAI API Key
使用的节点 (15)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "ad0113c344ee237399e44e9f11798b05baeb83a6196d514a9ae9d2ad71c3b5c9",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "ab1b7d2d-7eac-45eb-9e0a-36f14c56df14",
"name": "当点击“执行工作流”时",
"type": "n8n-nodes-base.manualTrigger",
"position": [
1728,
288
],
"parameters": {},
"typeVersion": 1
},
{
"id": "2015e3a3-026b-46af-adfc-1fcff0031e66",
"name": "OpenAI 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
2720,
608
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "4l6TDfLZVFS24g3X",
"name": "OpenAi account 4"
}
},
"typeVersion": 1.2
},
{
"id": "3bce7fdc-3fe1-451f-9e3f-ed37563a8fb5",
"name": "结构化输出解析器",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
3072,
576
],
"parameters": {
"jsonSchemaExample": "{\n\t\"summary\": \"summary\"\n}"
},
"typeVersion": 1.3
},
{
"id": "93cb6107-c70b-4a48-95e4-1ddda24d87e1",
"name": "便签53",
"type": "n8n-nodes-base.stickyNote",
"position": [
1632,
-272
],
"parameters": {
"color": 7,
"width": 2144,
"height": 1056,
"content": "# 📊 营销支出报告 → Google Sheets + PDF"
},
"typeVersion": 1
},
{
"id": "00aba054-1dab-429e-beb4-2c18e21c7e3a",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
1184,
-272
],
"parameters": {
"width": 400,
"height": 1056,
"content": ""
},
"typeVersion": 1
},
{
"id": "2d0dba31-964f-4b8c-94e4-215b5448f2b4",
"name": "获取营销数据",
"type": "n8n-nodes-base.googleSheets",
"position": [
1952,
464
],
"parameters": {
"options": {},
"sheetName": {
"__rl": true,
"mode": "list",
"value": 365710158,
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1UDWt0-Z9fHqwnSNfU3vvhSoYCFG6EG3E-ZewJC_CLq4/edit#gid=365710158",
"cachedResultName": "Data"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1UDWt0-Z9fHqwnSNfU3vvhSoYCFG6EG3E-ZewJC_CLq4",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1UDWt0-Z9fHqwnSNfU3vvhSoYCFG6EG3E-ZewJC_CLq4/edit?usp=drivesdk",
"cachedResultName": "Sample Marketing Data - n8n"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "HlBW2puZbuCCq8jJ",
"name": "Google Sheets account 3"
}
},
"typeVersion": 4.7
},
{
"id": "385bdda8-e751-4c71-8ddc-ff1b93eb5698",
"name": "按渠道汇总支出",
"type": "n8n-nodes-base.summarize",
"position": [
2256,
288
],
"parameters": {
"options": {},
"fieldsToSplitBy": "Channel",
"fieldsToSummarize": {
"values": [
{
"field": "Spend ($)",
"aggregation": "sum"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "433d72c6-032c-43b9-9c34-36191d3181b5",
"name": "汇总支出",
"type": "n8n-nodes-base.summarize",
"position": [
2256,
128
],
"parameters": {
"options": {},
"fieldsToSummarize": {
"values": [
{
"field": "Spend ($)",
"aggregation": "sum"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "dbcd16cf-f023-467b-bc92-d70c9110cf1b",
"name": "撰写摘要",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
2832,
304
],
"parameters": {
"text": "={{ $json.data }}",
"options": {
"systemMessage": "You are writing a daily update message about the marketing data. The data is provided. Output a 4 sentance summary. \n\nOutput like this. \n\n{\n\t\"summary\": \"summary\"\n}"
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 2.2
},
{
"id": "4d2c9c31-7fc8-4a4b-a6ca-3b36777ff96b",
"name": "合并所有数据",
"type": "n8n-nodes-base.merge",
"position": [
3136,
48
],
"parameters": {
"mode": "combine",
"options": {},
"combineBy": "combineByPosition",
"numberInputs": 3
},
"typeVersion": 3.2
},
{
"id": "d6a77a5d-c9c4-4496-8a8e-520425b54400",
"name": "转换为 PDF 并上传",
"type": "n8n-nodes-base.code",
"position": [
3504,
-160
],
"parameters": {
"jsCode": "// n8n Code node (JavaScript)\n// Input: ONE item whose .json is the array you posted\n// Output: ONE item in correct n8n shape: [{ json: <object for HTML/Mustache> }]\n\nconst fmtUSD = (n) => Number(n || 0).toLocaleString('en-US', { style: 'currency', currency: 'USD' });\n\nconst items = $input.all();\nif (!items.length) {\n return [{ json: { error: 'No input data' } }];\n}\n\n// Handle your exact incoming shape (array with one object)\nlet root = items[0].json;\nif (Array.isArray(root)) root = root[0] || {};\n\nconst totalSpendRaw = Number(root[\"sum_Spend_($)\"] || 0);\nconst channelsRaw = Array.isArray(root.data) ? root.data : [];\nconst summary = (typeof root.output?.summary === 'string') ? root.output.summary : '';\n\n// Build channels list for the HTML template\nconst channels = channelsRaw.map(r => ({\n channel: r.Channel || 'Unknown',\n spendFmt: fmtUSD(Number(r[\"sum_Spend_($)\"] || 0)),\n}));\n\n// Final object expected by your HTML/Mustache\nconst out = {\n generatedDate: new Date().toISOString().slice(0, 10),\n totalSpendFmt: fmtUSD(totalSpendRaw),\n channelCount: channels.length,\n channels,\n summary,\n};\n\n// ✅ Return in proper n8n format\nreturn [{ json: out }];\n"
},
"typeVersion": 2
},
{
"id": "5d147144-87a1-4e6c-a03c-4366896deffe",
"name": "创建 PDF",
"type": "n8n-nodes-pdfco.PDFco Api",
"position": [
3552,
560
],
"parameters": {
"operation": "URL/HTML to PDF",
"templateId": "12011",
"convertType": "htmlTemplateToPDF",
"templateData": "={{ JSON.stringify($json) }}\n",
"advancedOptions": {}
},
"credentials": {
"pdfcoApi": {
"id": "wGorcCULfsY1va25",
"name": "PDF.co account"
}
},
"typeVersion": 1
},
{
"id": "0a330ed9-9b83-4915-a867-432752e0a6fc",
"name": "转换为单行",
"type": "n8n-nodes-base.aggregate",
"position": [
2496,
224
],
"parameters": {
"options": {},
"aggregate": "aggregateAllItemData"
},
"typeVersion": 1
},
{
"id": "a3ecc29f-ef2f-4325-b477-b4a536dc86d6",
"name": "便签59",
"type": "n8n-nodes-base.stickyNote",
"position": [
3440,
64
],
"parameters": {
"color": 3,
"width": 288,
"height": 624,
"content": "### 2️⃣ 连接 PDF.co"
},
"typeVersion": 1
},
{
"id": "2fe228de-8f55-4f3f-8856-a2d0216c3dd3",
"name": "便签60",
"type": "n8n-nodes-base.stickyNote",
"position": [
1888,
32
],
"parameters": {
"color": 3,
"width": 224,
"height": 576,
"content": "### 1️⃣ 准备您的 Google Sheet"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"Sum Spend": {
"main": [
[
{
"node": "Combine All",
"type": "main",
"index": 0
}
]
]
},
"Combine All": {
"main": [
[
{
"node": "Convert to PDF Upload",
"type": "main",
"index": 0
}
]
]
},
"Write Summary": {
"main": [
[
{
"node": "Combine All",
"type": "main",
"index": 2
}
]
]
},
"Covert to 1 row": {
"main": [
[
{
"node": "Combine All",
"type": "main",
"index": 1
},
{
"node": "Write Summary",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Write Summary",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Get Marketing Data": {
"main": [
[
{
"node": "Sum Spend",
"type": "main",
"index": 0
},
{
"node": "Sum Spend by Channel",
"type": "main",
"index": 0
}
]
]
},
"Sum Spend by Channel": {
"main": [
[
{
"node": "Covert to 1 row",
"type": "main",
"index": 0
}
]
]
},
"Convert to PDF Upload": {
"main": [
[
{
"node": "Create PDF",
"type": "main",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "Write Summary",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"When clicking ‘Execute workflow’": {
"main": [
[
{
"node": "Get Marketing Data",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 文档提取, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
使用Google Sheets、GPT-4o和电子邮件生成营销活动ROI报告
使用Google Sheets、GPT-4o和电子邮件生成营销活动ROI报告
Code
Merge
Aggregate
+7
16 节点Robert Breen
AI 摘要总结
初学者数据分析:使用 GPT-4o 在 Google Sheets 中合并、筛选和汇总
初学者数据分析:使用 GPT-4o 在 Google Sheets 中合并、筛选和汇总
If
Set
Code
+9
21 节点Robert Breen
文档提取
播客笔记记录器
使用GPT和Gemini结合性能数据创建高转化率Meta广告脚本
Set
Code
Merge
+7
24 节点Robert Breen
文档提取
AI生成LinkedIn帖子含人工审批
使用GPT-4、GoToHuman和Blotato的AI生成LinkedIn帖子含人工审批
Code
Merge
Filter
+10
19 节点Robert Breen
社交媒体
冷线索重新参与邮件生成器:GPT-4o-mini、Outlook和Sheets
冷线索重新参与邮件生成器:GPT-4o-mini、Outlook和Sheets
Code
Aggregate
Google Sheets
+6
15 节点Robert Breen
客户培育
使用 Apify + GPT-4o-mini 从标签分析生成 Instagram 标题
使用 Apify + GPT-4o-mini 从标签分析生成 Instagram 标题
Set
Code
Merge
+8
17 节点Robert Breen
内容创作
工作流信息
难度等级
中级
节点数量15
分类2
节点类型11
作者
Robert Breen
@rbreenProfessional services consultant with over 10 years of experience solving complex business problems across industries. I specialize in n8n and process automation—designing custom workflows that integrate tools like Google Calendar, Airtable, GPT, and internal systems. Whether you need to automate scheduling, sync data, or streamline operations, I build solutions that save time and drive results.
外部链接
在 n8n.io 查看 →
分享此工作流