8
n8n 中文网amn8n.com

博客写作与编辑器

高级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 18 个节点。主要使用 If, Code, Filter, Summarize, GoogleSheets 等节点。 基于Google Sheets记忆的博客写作与编辑器 (GPT-4)

前置要求
  • Google Sheets API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "ad0113c344ee237399e44e9f11798b05baeb83a6196d514a9ae9d2ad71c3b5c9",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "817d6ddb-2cf6-4505-9ddb-22c55de574f2",
      "name": "结构化输出解析器",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -368,
        1488
      ],
      "parameters": {
        "jsonSchemaExample": "{\n\t\"items\": 5, \n  \"session\": \"sessionid\",\n  \"blog\": \"blog\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "f0ab2c2d-16b6-4f83-8648-dc7e162bf60b",
      "name": "OpenAI 聊天模型2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -912,
        1520
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5",
          "cachedResultName": "gpt-5"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "4l6TDfLZVFS24g3X",
          "name": "OpenAi account 4"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "1577bd89-b6b4-4c5c-a8cd-39e7ca7bc2cc",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -544,
        1408
      ],
      "parameters": {
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "8053e2f5-5042-4d54-826b-dc80fb11cbb9",
      "name": "当被其他工作流执行时",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        176,
        1440
      ],
      "parameters": {
        "inputSource": "passthrough"
      },
      "typeVersion": 1.1
    },
    {
      "id": "4537aa85-c0f3-4a24-9d76-5e524bbba647",
      "name": "google",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        0,
        1456
      ],
      "parameters": {
        "source": "parameter",
        "description": "调用此工具统计会话 ID 的行数。仅将会话 ID 传递给该工具",
        "workflowJson": "{\n  \"nodes\": [\n    {\n      \"parameters\": {\n        \"inputSource\": \"passthrough\"\n      },\n      \"type\": \"n8n-nodes-base.executeWorkflowTrigger\",\n      \"typeVersion\": 1.1,\n      \"position\": [\n        1040,\n        1152\n      ],\n      \"id\": \"8053e2f5-5042-4d54-826b-dc80fb11cbb9\",\n      \"name\": \"When Executed by Another Workflow\"\n    },\n    {\n      \"parameters\": {\n        \"documentId\": {\n          \"__rl\": true,\n          \"value\": \"1NwnABaQIReMmG2sRGrC-lv-5kpmsKJkUlRm-KmvPsCE\",\n          \"mode\": \"list\",\n          \"cachedResultName\": \"n8n Memory\",\n          \"cachedResultUrl\": \"https://docs.google.com/spreadsheets/d/1NwnABaQIReMmG2sRGrC-lv-5kpmsKJkUlRm-KmvPsCE/edit?usp=drivesdk\"\n        },\n        \"sheetName\": {\n          \"__rl\": true,\n          \"value\": \"gid=0\",\n          \"mode\": \"list\",\n          \"cachedResultName\": \"Sheet1\",\n          \"cachedResultUrl\": \"https://docs.google.com/spreadsheets/d/1NwnABaQIReMmG2sRGrC-lv-5kpmsKJkUlRm-KmvPsCE/edit#gid=0\"\n        },\n        \"options\": {}\n      },\n      \"type\": \"n8n-nodes-base.googleSheets\",\n      \"typeVersion\": 4.7,\n      \"position\": [\n        1232,\n        1152\n      ],\n      \"id\": \"9df87454-5e48-494f-af01-82197750341f\",\n      \"name\": \"Get row(s) in sheet\",\n      \"alwaysOutputData\": true,\n      \"credentials\": {\n        \"googleSheetsOAuth2Api\": {\n          \"id\": \"HlBW2puZbuCCq8jJ\",\n          \"name\": \"Google Sheets account 3\"\n        }\n      }\n    },\n    {\n      \"parameters\": {\n        \"fieldsToSummarize\": {\n          \"values\": [\n            {\n              \"field\": \"row_number\"\n            }\n          ]\n        },\n        \"options\": {}\n      },\n      \"type\": \"n8n-nodes-base.summarize\",\n      \"typeVersion\": 1.1,\n      \"position\": [\n        1648,\n        1152\n      ],\n      \"id\": \"0ab8f131-b8ec-44f1-851f-0c08d202cf4e\",\n      \"name\": \"Summarize1\",\n      \"alwaysOutputData\": true\n    },\n    {\n      \"parameters\": {\n        \"conditions\": {\n          \"options\": {\n            \"caseSensitive\": true,\n            \"leftValue\": \"\",\n            \"typeValidation\": \"strict\",\n            \"version\": 2\n          },\n          \"conditions\": [\n            {\n              \"id\": \"2278feea-3c0a-407b-84dc-5d6c0591fde9\",\n              \"leftValue\": \"={{ $json.session }}\",\n              \"rightValue\": \"={{ $('When Executed by Another Workflow').item.json.query }}\",\n              \"operator\": {\n                \"type\": \"string\",\n                \"operation\": \"equals\",\n                \"name\": \"filter.operator.equals\"\n              }\n            }\n          ],\n          \"combinator\": \"and\"\n        },\n        \"options\": {}\n      },\n      \"type\": \"n8n-nodes-base.filter\",\n      \"typeVersion\": 2.2,\n      \"position\": [\n        1440,\n        1152\n      ],\n      \"id\": \"ff5158fd-60bb-4a43-b8f9-c07971c03fe5\",\n      \"name\": \"Filter\",\n      \"alwaysOutputData\": true\n    }\n  ],\n  \"connections\": {\n    \"When Executed by Another Workflow\": {\n      \"main\": [\n        [\n          {\n            \"node\": \"Get row(s) in sheet\",\n            \"type\": \"main\",\n            \"index\": 0\n          }\n        ]\n      ]\n    },\n    \"Get row(s) in sheet\": {\n      \"main\": [\n        [\n          {\n            \"node\": \"Filter\",\n            \"type\": \"main\",\n            \"index\": 0\n          }\n        ]\n      ]\n    },\n    \"Filter\": {\n      \"main\": [\n        [\n          {\n            \"node\": \"Summarize1\",\n            \"type\": \"main\",\n            \"index\": 0\n          }\n        ]\n      ]\n    }\n  },\n  \"pinData\": {\n    \"When Executed by Another Workflow\": [\n      {\n        \"query\": \"ccde0f38fdeb4b64a49f541041ec64f1\"\n      }\n    ]\n  },\n  \"meta\": {\n    \"templateCredsSetupCompleted\": true,\n    \"instanceId\": \"ad0113c344ee237399e44e9f11798b05baeb83a6196d514a9ae9d2ad71c3b5c9\"\n  }\n}"
      },
      "typeVersion": 2.2
    },
    {
      "id": "0ab8f131-b8ec-44f1-851f-0c08d202cf4e",
      "name": "Summarize1",
      "type": "n8n-nodes-base.summarize",
      "position": [
        688,
        1440
      ],
      "parameters": {
        "options": {},
        "fieldsToSummarize": {
          "values": [
            {
              "field": "row_number"
            }
          ]
        }
      },
      "typeVersion": 1.1,
      "alwaysOutputData": true
    },
    {
      "id": "ff5158fd-60bb-4a43-b8f9-c07971c03fe5",
      "name": "过滤器",
      "type": "n8n-nodes-base.filter",
      "position": [
        528,
        1440
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "2278feea-3c0a-407b-84dc-5d6c0591fde9",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.session }}",
              "rightValue": "={{ $('When Executed by Another Workflow').item.json.query }}"
            }
          ]
        }
      },
      "typeVersion": 2.2,
      "alwaysOutputData": true
    },
    {
      "id": "20311124-4a86-4116-8c0b-168e2ef607e0",
      "name": "便签 6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1552,
        624
      ],
      "parameters": {
        "width": 400,
        "height": 1072,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "355d3a9e-3bcd-4734-ad71-2f3c1254ed2f",
      "name": "便签55",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1120,
        624
      ],
      "parameters": {
        "color": 7,
        "width": 2032,
        "height": 1072,
        "content": "# ✍️ 带 Google Sheets 记忆功能的 AI 博客撰写与编辑器(n8n + OpenAI)"
      },
      "typeVersion": 1
    },
    {
      "id": "111dcbb9-73a9-49e6-9c53-b861cf37df5b",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        1328
      ],
      "parameters": {
        "color": 3,
        "width": 912,
        "height": 304,
        "content": "## Google 子工作流工具"
      },
      "typeVersion": 1
    },
    {
      "id": "8d974459-83a5-4b2b-b57b-9df1bda22196",
      "name": "便签 7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1008,
        1328
      ],
      "parameters": {
        "color": 3,
        "width": 288,
        "height": 304,
        "content": "### 1️⃣ 设置OpenAI连接"
      },
      "typeVersion": 1
    },
    {
      "id": "045e87e8-da89-495e-bfb6-cdb0bc8d45d5",
      "name": "博客撰写与编辑器",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -656,
        1040
      ],
      "parameters": {
        "text": "={{ $json.user_prompt }}",
        "options": {
          "systemMessage": "={{ $json.system_prompt }}"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "a3218909-349f-4f26-8403-1c8fd8d38c44",
      "name": "选择撰写或编辑博客",
      "type": "n8n-nodes-base.code",
      "position": [
        -768,
        832
      ],
      "parameters": {
        "jsCode": "// Code node: build prompts using fields from \"When chat message received\"\n// Behavior:\n// - If `output` exists => system: \"Reword the blog...\" ; user prompt uses `output` + `sessionId`\n// - Else               => system: \"Write a blog...\"  ; user prompt uses `chatInput` + `sessionId`\n// Both instruct to use the Google tool (sub-workflow) to count rows, passing ONLY the session id.\n//\n// Output fields:\n//   - system_prompt\n//   - user_prompt\n\n// Pull from the trigger node if needed\nconst triggerItems = $items('Ask about blog topic', 0, 0) || [];\nconst trigger = triggerItems[0]?.json || {};\n\nconst schemaExample = JSON.stringify(\n  { items: 5, session: \"sessionid\", blog: \"blog\" },\n  null,\n  0\n);\n\nreturn items.map(item => {\n  const j = item.json || {};\n\n  // Resolve chat and session from either the current item or the trigger node\n  const chatInput = j.chatInput ?? j.chat ?? trigger.chatInput ?? \"\";\n  const sessionId = j.sessionId ?? j.sessionid ?? trigger.sessionId ?? \"\";\n\n  const hasOutput =\n    j.output !== undefined &&\n    j.output !== null &&\n    String(j.output).trim() !== \"\";\n\n  if (hasOutput) {\n    // Reword existing blog\n    item.json.system_prompt =\n      \"Reword the blog. Use the Google tool (sub-workflow) to count how many rows exist for this session. Pass ONLY the session id to the Google tool. it will send back the number.Include the session id from the input. Return ONLY valid JSON with the required keys.\";\n    item.json.user_prompt = [\n      `sessionid: ${sessionId}`,\n      `blog_to_reword: \"\"\"${String(j.output)}\"\"\"`,\n      `Respond as JSON exactly like: ${schemaExample}`\n    ].join(\"\\n\");\n  } else {\n    // Write a new blog from chat\n    item.json.system_prompt =\n      \"Write a blog. Use the Google tool (sub-workflow) to see how many rows exist for this session. Pass ONLY the session id to the Google tool. it will send back the number.  Include the session id from the input. Return ONLY valid JSON with the required keys.\";\n    item.json.user_prompt = [\n      `sessionid: ${sessionId}`,\n      `blog_topic_or_chat: \"\"\"${String(chatInput)}\"\"\"`,\n      `Respond as JSON exactly like: ${schemaExample}`\n    ].join(\"\\n\");\n  }\n\n  // Optional debug\n  item.json._resolved = { sessionId, chatInput, fromTrigger: !!triggerItems.length };\n\n  return item;\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "6eec6156-3360-4caa-b9bd-92dbdb289dce",
      "name": "便签10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -304,
        768
      ],
      "parameters": {
        "color": 3,
        "width": 352,
        "height": 384,
        "content": "### 2️⃣ 准备您的 Google 表格"
      },
      "typeVersion": 1
    },
    {
      "id": "bbb5baca-6411-4d41-8530-3aff0a228513",
      "name": "询问博客主题",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -1040,
        816
      ],
      "webhookId": "d38a0072-420b-4de8-86b6-03a8f9a6e254",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "7f76b93d-b4aa-461a-8789-be99f54660fa",
      "name": "n8n 历史记录",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -176,
        1024
      ],
      "parameters": {
        "columns": {
          "value": {
            "Rows": "={{ $json.output.items }}",
            "output": "={{ $json.output.blog }}",
            "session": "={{ $json.output.session }}"
          },
          "schema": [
            {
              "id": "session",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "session",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "output",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "output",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Rows",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Rows",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1NwnABaQIReMmG2sRGrC-lv-5kpmsKJkUlRm-KmvPsCE/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1NwnABaQIReMmG2sRGrC-lv-5kpmsKJkUlRm-KmvPsCE",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1NwnABaQIReMmG2sRGrC-lv-5kpmsKJkUlRm-KmvPsCE/edit?usp=drivesdk",
          "cachedResultName": "n8n Memory"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "HlBW2puZbuCCq8jJ",
          "name": "Google Sheets account 3"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "5d61f20f-c559-431f-9fbf-ddbd764c77d6",
      "name": "检查是否运行 4 次以上",
      "type": "n8n-nodes-base.if",
      "position": [
        240,
        1088
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "6dd3ba6e-400a-45bf-80d7-830594683094",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $json.Rows }}",
              "rightValue": 3
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "9df87454-5e48-494f-af01-82197750341f",
      "name": "获取历史记录",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        352,
        1440
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1NwnABaQIReMmG2sRGrC-lv-5kpmsKJkUlRm-KmvPsCE/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1NwnABaQIReMmG2sRGrC-lv-5kpmsKJkUlRm-KmvPsCE",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1NwnABaQIReMmG2sRGrC-lv-5kpmsKJkUlRm-KmvPsCE/edit?usp=drivesdk",
          "cachedResultName": "n8n Memory"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "HlBW2puZbuCCq8jJ",
          "name": "Google Sheets account 3"
        }
      },
      "typeVersion": 4.7,
      "alwaysOutputData": true
    }
  ],
  "pinData": {
    "When Executed by Another Workflow": [
      {
        "query": "ccde0f38fdeb4b64a49f541041ec64f1"
      }
    ]
  },
  "connections": {
    "Filter": {
      "main": [
        [
          {
            "node": "Summarize1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "google": {
      "ai_tool": [
        [
          {
            "node": "Blog Writer & Editor",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get History": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "n8n History": {
      "main": [
        [
          {
            "node": "Check if Ran 4+ times",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Blog Writer & Editor",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Blog Writer & Editor",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Ask about blog topic": {
      "main": [
        [
          {
            "node": "Choose to Write or Edit Blog",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Blog Writer & Editor": {
      "main": [
        [
          {
            "node": "n8n History",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if Ran 4+ times": {
      "main": [
        [],
        [
          {
            "node": "Choose to Write or Edit Blog",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Blog Writer & Editor",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Choose to Write or Edit Blog": {
      "main": [
        [
          {
            "node": "Blog Writer & Editor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Get History",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 内容创作, 多模态 AI

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量18
分类2
节点类型13
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Robert Breen

Robert Breen

@rbreen

Professional 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 查看

分享此工作流