8
n8n 中文网amn8n.com

使用GPT-4.1为WordPress文章添加AI生成标题和结论

中级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 8 个节点。主要使用 Set, Code, HttpRequest, ManualTrigger, OpenAi 等节点。 使用GPT-4.1为WordPress文章添加AI生成标题和结论

前置要求
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "8e39b7468c6828f4a107b01649bad86d436b5b7484be7eb792fe15ba099d5821"
  },
  "nodes": [
    {
      "id": "37f90234-8233-495a-b9e5-394de7c76852",
      "name": "当点击\"执行工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        64,
        96
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "3b725892-b48f-42b1-b76f-13222f146ade",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        16,
        -48
      ],
      "parameters": {
        "color": 5,
        "width": 1776,
        "height": 320,
        "content": "## 带 AI 摘要的文章内容增强器"
      },
      "typeVersion": 1
    },
    {
      "id": "13591b8e-c2e3-45f3-b841-2e26c7ebe54c",
      "name": "获取文章内容(API)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        288,
        96
      ],
      "parameters": {
        "url": "=https://example.com/wp-json/wp/v2/posts?per_page=100",
        "options": {
          "batching": {
            "batch": {}
          }
        },
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth"
      },
      "credentials": {
        "httpBasicAuth": {
          "id": "a390F9PA3LRvL5DR",
          "name": "YOUR_API_KEY"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "bbb1b9e0-83ae-4145-8b28-989e10051fea",
      "name": "准备文章内容字段",
      "type": "n8n-nodes-base.set",
      "position": [
        544,
        96
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "2f9c26a8-4c05-4719-8027-d99943ec8a4c",
              "name": "id",
              "type": "string",
              "value": "={{$json[\"id\"]}}"
            },
            {
              "id": "f1fce4f9-7125-4c48-98f8-fa8ca9933714",
              "name": "=title",
              "type": "string",
              "value": "={{$json[\"title\"][\"rendered\"]}}"
            },
            {
              "id": "facdf038-65a1-408c-bdd6-fce4c73011db",
              "name": "content",
              "type": "string",
              "value": "={{$json[\"content\"][\"rendered\"]}}"
            },
            {
              "id": "0566adcc-82f7-4967-9d9a-d4a08c9c5c8d",
              "name": "plainContent",
              "type": "string",
              "value": "={{ $json[\"content\"][\"rendered\"] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "65ba1acf-a99f-455b-8583-09e43799d7c2",
      "name": "格式化文章内容用于提示",
      "type": "n8n-nodes-base.code",
      "position": [
        784,
        96
      ],
      "parameters": {
        "jsCode": "return items.map(item => {\n  const rawHtml = item.json.content;\n  const plainText = rawHtml.replace(/<[^>]+>/g, ' ').replace(/\\s+/g, ' ').trim();\n  return {\n    json: {\n      id: item.json.id,\n      title: item.json.title,\n      content: plainText\n    }\n  }\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "5c58ac22-c58b-48e3-a164-a977b8e61ce2",
      "name": "生成标题和摘要段落(AI)",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1024,
        96
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "GPT-4.1-MINI"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=Acting as a specialized content writer for a [Your Topic] website,\n\nThis is the text of a website article. Please write a suitable heading and a 3-line concluding paragraph (useful, experience-based, user-friendly content with high engagement) to add at the end of the article.  \nArticle text:  \n{{ $json.content }}\n\nPlease strictly follow these guidelines:  \n- The information must be accurate, reliable, specialized, up-to-date, and original.  \n- Pay special attention to user satisfaction and addressing their needs and questions.  \n- The content should be useful and practical; it must offer significant value compared to other web content and be trustworthy and citable. It should also go beyond obvious facts.  \n- Try to use copywriting and advertising techniques in the content; the brand name is [Your Brand] .  \n- The content should be structured with a clear outline, headings, paragraphs, etc., and must be clear and simple, not complicated.  \n- Include detailed and precise information as much as possible.  \n- The content must be comprehensive, covering various aspects of the user's questions and the topic, including points competitors have missed.  \n- Preferably, include the content’s keyword (such as the article title) in the produced text.  \n- The content aims to:  \n   1. Attract organic traffic  \n   2. Build branding  \n   3. Be visible in chatbots  \n   4. Increase conversion rate through copywriting  \n- The tone should match the rest of the website’s content.\n"
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "oETjE0hiLJ8SZxWX",
          "name": "YOUR_API_KEY"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "386099a2-583c-48ad-bdc3-d91d691cf385",
      "name": "格式化 AI 输出用于更新",
      "type": "n8n-nodes-base.code",
      "position": [
        1376,
        96
      ],
      "parameters": {
        "jsCode": "return items.map(item => {\n  const id = item.json.id;\n  const htmlContent = item.json.content; \n  const summary = item.json.message?.content || \"\";\n\n \n  const newContent = htmlContent + \"<hr />\" + summary; \n\n  return {\n    json: {\n      id,\n      content: newContent\n    }\n  };\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "bd7f690c-ac97-4c5a-8db5-524e4f8b2186",
      "name": "在 WordPress 中更新文章",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1616,
        96
      ],
      "parameters": {
        "url": "=https://example.com/wp-json/wp/v2/posts",
        "method": "PATCH",
        "options": {
          "batching": {
            "batch": {}
          }
        },
        "sendBody": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "content",
              "value": "={{ $json.content }}"
            },
            {
              "name": "post_id",
              "value": "={{ $('Fetch Article Content (API)').item.json.id }}"
            }
          ]
        },
        "genericAuthType": "httpBasicAuth"
      },
      "credentials": {
        "httpBasicAuth": {
          "id": "a390F9PA3LRvL5DR",
          "name": "YOUR_API_KEY"
        }
      },
      "typeVersion": 4.2
    }
  ],
  "pinData": {},
  "connections": {
    "Fetch Article Content (API)": {
      "main": [
        [
          {
            "node": "Prepare Article Content Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format AI Output for Update": {
      "main": [
        [
          {
            "node": "Update Article in WordPress",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Article Content Fields": {
      "main": [
        [
          {
            "node": "Format Article Content for Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Article Content for Prompt": {
      "main": [
        [
          {
            "node": "Generate Heading & Summary Paragraph (AI)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Fetch Article Content (API)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Heading & Summary Paragraph (AI)": {
      "main": [
        [
          {
            "node": "Format AI Output for Update",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

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

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

作者
Ali Khosravani

Ali Khosravani

@alikhosro

Automation & SEO Specialist with years of experience building smart workflows, AI-powered content solutions, and marketing automations. Skilled in n8n, WordPress, and API integrations to help businesses save time and grow faster.

外部链接
在 n8n.io 查看

分享此工作流