8
n8n 中文网amn8n.com

使用 Dumpling AI 和 GPT-4 根据关键词生成博客文章

中级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 9 个节点。主要使用 If, Code, Gmail, Filter, Wordpress 等节点。 使用 Dumpling AI 和 GPT-4 根据关键词研究并生成博客文章到 WordPress

前置要求
  • Google 账号和 Gmail API 凭证
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "hUVV8GAakci58M8p",
  "meta": {
    "instanceId": "a1ae5c8dc6c65e674f9c3947d083abcc749ef2546dff9f4ff01de4d6a36ebfe6",
    "templateCredsSetupCompleted": true
  },
  "name": "使用 Dumpling AI 和 GPT-4 根据关键词生成博客文章",
  "tags": [],
  "nodes": [
    {
      "id": "8d72a1ca-42cf-40eb-9b08-d69901beef75",
      "name": "触发器:从表单接收关键词",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -432,
        -80
      ],
      "webhookId": "7b1a6959-6114-441a-9b9e-d852ec9e3fcb",
      "parameters": {
        "options": {},
        "formTitle": "ideas",
        "formFields": {
          "values": [
            {
              "fieldLabel": "search key"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "fdafc512-8d73-4679-ba2c-77148c88efe6",
      "name": "通过 Dumpling AI 搜索 Google",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -208,
        -80
      ],
      "parameters": {
        "url": "https://app.dumplingai.com/api/v1/search",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "query",
              "value": "={{ $json['search key'] }}"
            },
            {
              "name": "scrapeResults",
              "value": "true"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {}
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "RLFzAcGRepr5eXZB",
          "name": "Dumpling AI-n8n"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "1d5ebcd4-944c-42a1-bf98-fe2ff07f9ea8",
      "name": "提取顶部结果、PAA 和相关搜索",
      "type": "n8n-nodes-base.code",
      "position": [
        16,
        -80
      ],
      "parameters": {
        "jsCode": "// n8n JavaScript Code to Extract Search Results Data\n\n// Get the input data (assuming it's in $input.all()[0].json)\nconst inputData = $input.all()[0].json;\n\n// Initialize the output object\nconst output = {\n  query: inputData.searchParameters?.q || \"N/A\",\n  topTwoResults: [],\n  peopleAlsoAskExists: \"No\",\n  topThreeRelatedSearches: []\n};\n\n// Extract top 2 search results\nif (inputData.organic && Array.isArray(inputData.organic)) {\n  const topTwo = inputData.organic.slice(0, 2);\n  \n  output.topTwoResults = topTwo.map(result => ({\n    position: result.position,\n    title: result.title,\n    url: result.link,\n    snippet: result.snippet,\n    date: result.date || \"N/A\",\n    sitelinks: result.sitelinks || [],\n    scrapeOutput: result.scrapeOutput ? {\n      title: result.scrapeOutput.title,\n      description: result.scrapeOutput.metadata?.description || \"N/A\",\n      ogTitle: result.scrapeOutput.metadata?.ogTitle || \"N/A\",\n      ogDescription: result.scrapeOutput.metadata?.ogDescription || \"N/A\",\n      url: result.scrapeOutput.url,\n      language: result.scrapeOutput.metadata?.language || \"N/A\"\n    } : null\n  }));\n}\n\n// Check if \"People Also Ask\" exists and extract questions\nif (inputData.peopleAlsoAsk && Array.isArray(inputData.peopleAlsoAsk) && inputData.peopleAlsoAsk.length > 0) {\n  output.peopleAlsoAskExists = \"Yes\";\n  output.peopleAlsoAskQuestions = inputData.peopleAlsoAsk.map(item => ({\n    question: item.question,\n    snippet: item.snippet,\n    title: item.title,\n    link: item.link\n  }));\n} else {\n  output.peopleAlsoAskQuestions = [];\n}\n\n// Extract top 3 related searches\nif (inputData.relatedSearches && Array.isArray(inputData.relatedSearches)) {\n  output.topThreeRelatedSearches = inputData.relatedSearches\n    .slice(0, 3)\n    .map(search => search.query);\n}\n\n// Return the output\nreturn output;"
      },
      "typeVersion": 2
    },
    {
      "id": "5c7c27bb-debc-45b8-954f-96932eb0f831",
      "name": "检查是否存在\"用户还问了\"",
      "type": "n8n-nodes-base.filter",
      "position": [
        240,
        -80
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "664cac06-e941-41cb-8ef1-e3345a5dd68d",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.peopleAlsoAskExists }}",
              "rightValue": "Yes"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "66ad7710-c5a1-4abf-95da-417d1f39e7f9",
      "name": "使用 GPT-4 生成博客文章",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        464,
        -80
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "chatgpt-4o-latest",
          "cachedResultName": "CHATGPT-4O-LATEST"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "=You are given the following data:\n\nA search key representing the topic of interest.\n\nThe top two ranking search results for that search key, including their descriptions.\n\nA list of People Also Ask (PAA) questions and their answers from the same search.\n\nYour task:\nCarefully review the People Also Ask questions and their answers. Choose one question that is insightful, unique, or has the potential to generate a valuable and engaging blog post. Using that question as the core theme, write a detailed, well structured, and original blog post that is informative, clear, and engaging.\n\nThe blog post must reflect the context of the search key and take into account the top ranking pages and their descriptions, ensuring the final content is competitive and provides additional value to readers.\n\nThe output must be returned strictly in this JSON format:\n\n{\n  \"title\": \"string\",\n  \"blog_post\": \"string\"\n}"
            },
            {
              "content": "=Data provided:\nSearch Key:{{ $('Check if People Also Ask Exists').item.json.query }}\nTop Results:\n\nTitle: {{ $json.topTwoResults[0].title }} \nDescription: {{ $json.topTwoResults[0].scrapeOutput.description }}\n\nTitle: {{ $json.topTwoResults[1].title }}\nDescription: {{ $json.topTwoResults[1].scrapeOutput.description }}\n\nPeople Also Ask:{{ JSON.stringify($json.peopleAlsoAskQuestions) }}\n"
            }
          ]
        },
        "jsonOutput": true
      },
      "credentials": {
        "openAiApi": {
          "id": "dd8NvMC6rvx8RITo",
          "name": "OpenAi account 2"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "dd1f86fb-f6b0-4e9b-8a9b-84a42abf198a",
      "name": "通过 Gmail 发送博客文章以供审核",
      "type": "n8n-nodes-base.gmail",
      "position": [
        816,
        -80
      ],
      "webhookId": "6f25b44e-06e7-4e9f-8eb3-5ec06e9e90f0",
      "parameters": {
        "sendTo": "example@gmail.com",
        "message": "=<body bgcolor=\"#f6f9fc\" style=\"margin:0; padding:0;\">\n  <table width=\"100%\" bgcolor=\"#f6f9fc\" cellpadding=\"0\" cellspacing=\"0\">\n    <tr>\n      <td align=\"center\">\n        <table width=\"620\" bgcolor=\"#ffffff\" cellpadding=\"0\" cellspacing=\"0\" style=\"border:1px solid #e5e7eb;\">\n          <tr>\n            <td align=\"left\" style=\"padding:24px;\">\n              <font face=\"Arial, Helvetica, sans-serif\" size=\"5\" color=\"#111827\">\n                Workflow review needed\n              </font>\n            </td>\n          </tr>\n\n          <tr>\n            <td align=\"left\" style=\"padding:0 24px 8px 24px;\">\n              <font face=\"Arial, Helvetica, sans-serif\" size=\"3\" color=\"#374151\">\n                Hello, please review this workflow run carefully. Your input will determine the next step in the process.\n              </font>\n            </td>\n          </tr>\n\n          <tr>\n            <td align=\"left\" style=\"padding:8px 24px 16px 24px;\">\n              <font face=\"Arial, Helvetica, sans-serif\" size=\"3\" color=\"#6b7280\">\n                Below is the generated blog content for your review.\n              </font>\n            </td>\n          </tr>\n\n          <tr>\n            <td style=\"padding:0 24px 16px 24px;\">\n              <table width=\"100%\" cellpadding=\"8\" cellspacing=\"0\" style=\"border:1px solid #e5e7eb;\">\n                <tr bgcolor=\"#f9fafb\">\n                  <td width=\"30%\">\n                    <font face=\"Arial, Helvetica, sans-serif\" size=\"2\" color=\"#6b7280\">Blog Title</font>\n                  </td>\n                  <td>\n                    <font face=\"Arial, Helvetica, sans-serif\" size=\"2\" color=\"#111827\">\n                      {{ $json.message.content.title }}\n                    </font>\n                  </td>\n                </tr>\n                <tr>\n                  <td width=\"30%\" valign=\"top\">\n                    <font face=\"Arial, Helvetica, sans-serif\" size=\"2\" color=\"#6b7280\">Blog Body</font>\n                  </td>\n                  <td>\n                    <font face=\"Arial, Helvetica, sans-serif\" size=\"2\" color=\"#111827\">\n                      {{ $json.message.content.blog_post }}\n                    </font>\n                  </td>\n                </tr>\n              </table>\n            </td>\n          </tr>\n\n          <tr>\n            <td align=\"left\" style=\"padding:0 24px 24px 24px;\">\n              <font face=\"Arial, Helvetica, sans-serif\" size=\"3\" color=\"#111827\">\n                Thank you for reviewing. Please use the provided approval options in the workflow to continue.\n              </font>\n            </td>\n          </tr>\n\n        </table>\n      </td>\n    </tr>\n  </table>\n</body>\n",
        "options": {
          "appendAttribution": false
        },
        "subject": "Workflow review needed",
        "operation": "sendAndWait",
        "approvalOptions": {
          "values": {
            "approvalType": "double"
          }
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "j70r3RTMED1pgN3R",
          "name": "Gmail account 2"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "f6ba8847-b50e-46f7-9d96-c6fbd738fcb0",
      "name": "检查是否批准",
      "type": "n8n-nodes-base.if",
      "position": [
        1040,
        -80
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "a3de7dcb-5fc4-4ef8-a37f-a0f53e8a6fc8",
              "operator": {
                "type": "boolean",
                "operation": "equals"
              },
              "leftValue": "={{ $json.data.approved }}",
              "rightValue": true
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "8ea14b45-7c8a-491d-9d0a-e3d9a4d35eff",
      "name": "将博客文章发布到 WordPress",
      "type": "n8n-nodes-base.wordpress",
      "position": [
        1216,
        -240
      ],
      "parameters": {
        "title": "={{ $('Generate Blog Post with GPT-4').item.json.message.content.title }}",
        "additionalFields": {
          "content": "={{ $('Generate Blog Post with GPT-4').item.json.message.content.blog_post }}"
        }
      },
      "credentials": {
        "wordpressApi": {
          "id": "5yQLqsJQinZwA89m",
          "name": "Wordpress account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "409fa6a7-4655-4fee-9ed8-7bcfadcb2661",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -416,
        -560
      ],
      "parameters": {
        "width": 736,
        "height": 688,
        "content": "## 📝 使用 Dumpling AI + GPT-4 根据关键词生成博客文章"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "4b63b037-77e1-4fd5-928c-ce4aff0ac039",
  "connections": {
    "Check if Approved": {
      "main": [
        [
          {
            "node": "Publish Blog Post to WordPress",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Generate Blog Post with GPT-4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Blog Post with GPT-4": {
      "main": [
        [
          {
            "node": "Send Blog Post for Review via Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Google via Dumpling AI": {
      "main": [
        [
          {
            "node": "Extract Top Results, PAA & Related Searches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if People Also Ask Exists": {
      "main": [
        [
          {
            "node": "Generate Blog Post with GPT-4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger: Receive Keyword from Form": {
      "main": [
        [
          {
            "node": "Search Google via Dumpling AI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Blog Post for Review via Gmail": {
      "main": [
        [
          {
            "node": "Check if Approved",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Top Results, PAA & Related Searches": {
      "main": [
        [
          {
            "node": "Check if People Also Ask Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

工作流信息
难度等级
中级
节点数量9
分类2
节点类型9
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

外部链接
在 n8n.io 查看

分享此工作流