8
n8n 中文网amn8n.com

自动WordPress博客生成器(GPT + Postgres + WP媒体)

高级

这是一个AI, Marketing领域的自动化工作流,包含 46 个节点。主要使用 Set, Code, Merge, Postgres, HttpRequest 等节点,结合人工智能技术实现智能自动化。 使用GPT-4和Postgres跟踪自动生成并发布SEO文章到WordPress

前置要求
  • PostgreSQL 数据库连接信息
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "17j2efAe10uXRc4p",
  "meta": {
    "instanceId": "95e5c2dbf167bd62714d47d959f677d4c29b5fcbb7d183f4fe2396c33badeac6",
    "templateCredsSetupCompleted": true
  },
  "name": "自动 WordPress 博客生成器 (GPT + Postgres + WP 媒体)",
  "tags": [
    {
      "id": "k8Hqq1bbCQoesJjj",
      "name": "Wordpress",
      "createdAt": "2025-02-26T04:04:38.319Z",
      "updatedAt": "2025-02-26T04:04:38.319Z"
    }
  ],
  "nodes": [
    {
      "id": "f71a8a34-5d88-48b0-bf56-44c95d970abd",
      "name": "计划触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1120,
        -560
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "triggerAtMinute": {}
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "8ce11fcd-806c-44ea-aa5f-015599eacc98",
      "name": "OpenAI聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2060,
        -20
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-2025-04-14",
          "cachedResultName": "gpt-4.1-2025-04-14"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "BSiASwH9CasrT3uK",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c9450a63-a89e-46eb-b083-b0f40d7b797c",
      "name": "下载图片",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2620,
        100
      ],
      "parameters": {
        "url": "={{ $json.image_url }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file",
              "outputPropertyName": "imagedownloaded"
            }
          }
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "f477482d-d9b6-4d83-b707-dd19da90e25e",
      "name": "准备文章 JSON",
      "type": "n8n-nodes-base.code",
      "position": [
        3440,
        -520
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\n\nlet image = null;\nlet contentBlock = null;\nlet categoryBlock = null;\nlet titleBlock = null;\n\n// Inspect all incoming JSON\nfor (const item of items) {\n  const json = item.json;\n\n  // Detect image\n  if (json?.source_url && json?.media_type === 'image') {\n    image = json;\n    continue;\n  }\n\n  // Detect GPT-generated content\n  if (typeof json.content === 'string' && json.content.includes('<!-- wp:paragraph')) {\n    contentBlock = json;\n    continue;\n  }\n\n  // Detect category block\n  if (json?.category_id && json?.description) {\n    categoryBlock = json;\n    continue;\n  }\n\n  // Detect GPT-generated title from AI output\n  if (typeof json.output === 'string') {\n    titleBlock = json;\n    continue;\n  }\n\n  // Fallback title if nothing else matched\n  if (typeof json.title === 'string') {\n    titleBlock = json;\n  }\n}\n\nreturn [{\n  json: {\n    title: $input.first().json.title,\n    content: contentBlock?.content || '<p>No content</p>',\n    status: 'publish',\n    categories: [categoryBlock?.category_id || 1],\n    featured_media: image?.id || null,\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "12191b30-702c-44dd-bfaf-68de02f627b1",
      "name": "合并",
      "type": "n8n-nodes-base.merge",
      "position": [
        3200,
        -520
      ],
      "parameters": {
        "numberInputs": 3
      },
      "typeVersion": 3.1
    },
    {
      "id": "9c21f5ce-b353-4193-a93d-a034e025a1a0",
      "name": "OpenAI 聊天模型1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        640,
        -20
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini-2025-04-14",
          "cachedResultName": "gpt-4.1-mini-2025-04-14"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "BSiASwH9CasrT3uK",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "723d9202-7fb0-43ca-8945-8bd4b5030eb8",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2420,
        -1340
      ],
      "parameters": {
        "color": 4,
        "width": 1180,
        "height": 1780,
        "content": "# 🤖 WordPress 博客自动化工作流"
      },
      "typeVersion": 1
    },
    {
      "id": "550017b6-481b-4591-8d87-04761244ef3b",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1180,
        -740
      ],
      "parameters": {
        "color": 4,
        "width": 220,
        "height": 360,
        "content": "⏰ 每隔几小时触发此工作流。"
      },
      "typeVersion": 1
    },
    {
      "id": "8d6ae5db-3d88-4e3a-8567-6e38a6002acd",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -700,
        -740
      ],
      "parameters": {
        "color": 6,
        "width": 220,
        "height": 360,
        "content": "📥 加载所有 WordPress 分类。"
      },
      "typeVersion": 1
    },
    {
      "id": "3ef86b3a-18a1-42b7-896c-ef2352148b38",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -460,
        -740
      ],
      "parameters": {
        "width": 220,
        "height": 360,
        "content": "🧹 过滤掉排除的分类 ID。"
      },
      "typeVersion": 1
    },
    {
      "id": "3cc6a088-0698-478d-896b-9af0f5f03f00",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -220,
        -740
      ],
      "parameters": {
        "color": 5,
        "width": 220,
        "height": 360,
        "content": "🗃 从数据库加载最近使用的分类。"
      },
      "typeVersion": 1
    },
    {
      "id": "9eccdda9-1cee-42d1-8451-24b0104917b5",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        20,
        -740
      ],
      "parameters": {
        "width": 220,
        "height": 360,
        "content": "🎯 选择使用最少的分类用于下一篇文章。"
      },
      "typeVersion": 1
    },
    {
      "id": "1f9a4bb2-c482-47d2-9ebd-4ff1be58b3d8",
      "name": "便签 6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        340,
        -360
      ],
      "parameters": {
        "color": 5,
        "width": 220,
        "height": 360,
        "content": "📄 加载所选分类的 10 篇最新文章标题。"
      },
      "typeVersion": 1
    },
    {
      "id": "5faba628-67c5-4e1b-889e-7cc1b72a23d0",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        580,
        -360
      ],
      "parameters": {
        "color": 7,
        "width": 300,
        "height": 460,
        "content": "🧠 使用 GPT 生成独特的文章标题。"
      },
      "typeVersion": 1
    },
    {
      "id": "d23c4134-a06e-4630-a5e5-8a9b90259d4c",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        900,
        -360
      ],
      "parameters": {
        "width": 220,
        "height": 360,
        "content": "🧾 准备新的文章标题。"
      },
      "typeVersion": 1
    },
    {
      "id": "da20f973-6889-460c-84b8-cbff0c6ceaa2",
      "name": "便签9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1220,
        -740
      ],
      "parameters": {
        "width": 220,
        "height": 360,
        "content": "🔀 合并分类 + 标题数据。"
      },
      "typeVersion": 1
    },
    {
      "id": "2048e683-1b37-49e4-9bc5-2530becf26ee",
      "name": "便签 10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1460,
        -740
      ],
      "parameters": {
        "width": 220,
        "height": 360,
        "content": "📦 将所有文章元数据合并为一个对象。"
      },
      "typeVersion": 1
    },
    {
      "id": "a5aafb45-6e89-435b-9b41-63d2b5fd8cd5",
      "name": "便签11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1700,
        -740
      ],
      "parameters": {
        "color": 5,
        "width": 220,
        "height": 360,
        "content": "📝 将已使用的分类和标题保存到数据库。"
      },
      "typeVersion": 1
    },
    {
      "id": "f63a22c4-2f78-4820-87d4-eb1510f51bcc",
      "name": "便签12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2000,
        -360
      ],
      "parameters": {
        "color": 7,
        "width": 300,
        "height": 460,
        "content": "✍️ 编写完整的 WordPress 风格 HTML 文章。"
      },
      "typeVersion": 1
    },
    {
      "id": "24721fd7-cb69-44b6-a48d-91f195e861cc",
      "name": "便签 13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2320,
        -480
      ],
      "parameters": {
        "width": 220,
        "height": 360,
        "content": "🧾 从 AI 输出中提取内容块。"
      },
      "typeVersion": 1
    },
    {
      "id": "f5bd3e8b-c188-494e-b662-ce5722848ae4",
      "name": "便签14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2320,
        -100
      ],
      "parameters": {
        "width": 220,
        "height": 360,
        "content": "🖼 准备占位封面图片 URL。"
      },
      "typeVersion": 1
    },
    {
      "id": "933fe208-7c8e-4683-a09b-bfd91ed22bef",
      "name": "便签15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2560,
        -100
      ],
      "parameters": {
        "color": 6,
        "width": 220,
        "height": 360,
        "content": "⬇️ 下载封面图片。"
      },
      "typeVersion": 1
    },
    {
      "id": "78053d06-b008-403d-b6a1-d5546814d1e9",
      "name": "便签16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2800,
        -100
      ],
      "parameters": {
        "color": 6,
        "width": 220,
        "height": 360,
        "content": "📤 将图片上传到 WordPress 媒体库。"
      },
      "typeVersion": 1
    },
    {
      "id": "d11f85b0-664f-4c63-b34b-a510480957e7",
      "name": "便签17",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3140,
        -720
      ],
      "parameters": {
        "width": 220,
        "height": 360,
        "content": "🔗 合并图片 + 内容 + 分类信息。"
      },
      "typeVersion": 1
    },
    {
      "id": "01fcdc38-8627-4818-8f78-b45681d22d26",
      "name": "便签18",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3380,
        -720
      ],
      "parameters": {
        "width": 220,
        "height": 360,
        "content": "📬 准备 WP 文章的最终 JSON 主体。"
      },
      "typeVersion": 1
    },
    {
      "id": "10f89350-e129-41df-803c-450f3fb07193",
      "name": "便签19",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3620,
        -720
      ],
      "parameters": {
        "color": 6,
        "width": 220,
        "height": 360,
        "content": "🚀 将文章发布到您的 WordPress 网站。"
      },
      "typeVersion": 1
    },
    {
      "id": "bd082511-91aa-425f-9bf3-cadb3900c749",
      "name": "便签20",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -700,
        -360
      ],
      "parameters": {
        "color": 3,
        "width": 220,
        "height": 300,
        "content": "确保:"
      },
      "typeVersion": 1
    },
    {
      "id": "5f46d958-b7de-405e-a95e-57a9c0366b52",
      "name": "便签21",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -220,
        -360
      ],
      "parameters": {
        "color": 3,
        "width": 220,
        "height": 300,
        "content": "确保:"
      },
      "typeVersion": 1
    },
    {
      "id": "3f90d8c5-7dd9-41c4-a862-e21942fdc87d",
      "name": "加载分类",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -640,
        -560
      ],
      "parameters": {
        "url": "={{ $json.domain }}/wp-json/wp/v2/categories?per_page=100 ",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "8b2cb2f8-2a2e-4e92-81b6-36e9e2105f94",
      "name": "分类过滤器",
      "type": "n8n-nodes-base.code",
      "position": [
        -400,
        -560
      ],
      "parameters": {
        "jsCode": "const excludeIds = [1, 11, 12, 13, 15, 17, 18, 36, 37, 38, 39];\n\nreturn $input.all()\n  .filter(item => !excludeIds.includes(item.json.id))\n  .map(item => {\n    const { id, name, description, link } = item.json;\n    return {\n      json: { id, name, description, link }\n    };\n  });\n"
      },
      "typeVersion": 2
    },
    {
      "id": "083202d5-7053-4775-b053-2e503ce7d73f",
      "name": "选择最近使用的",
      "type": "n8n-nodes-base.postgres",
      "position": [
        -160,
        -560
      ],
      "parameters": {
        "query": "SELECT category_id, MAX(used_at) AS last_used_at\nFROM used_categories\nGROUP BY category_id\nORDER BY last_used_at ASC;",
        "options": {},
        "operation": "executeQuery"
      },
      "credentials": {
        "postgres": {
          "id": "JKCOXnEh1Bqg4Gad",
          "name": "YOUR_POSTGRES_CREDENTIAL"
        }
      },
      "executeOnce": true,
      "typeVersion": 2.6,
      "alwaysOutputData": true
    },
    {
      "id": "98f3ec81-f1f9-425b-83b0-2d5732acb19e",
      "name": "选择较少使用的",
      "type": "n8n-nodes-base.code",
      "position": [
        80,
        -560
      ],
      "parameters": {
        "jsCode": "const categories = $items(\"Category Filter\");\nconst usedRows = $items(\"Selecting recent\");\n\nif (!categories || categories.length === 0) {\n  throw new Error(\"No category in Code2\");\n}\n\nif (!usedRows || usedRows.length === 0) {\n  return [categories[0]];\n}\n\nconst usedMap = new Map(\n  usedRows.map(row => {\n    const id = row.json.category_id;\n    const time = new Date(row.json.last_used_at || row.json.used_at).getTime();\n    return [id, time];\n  })\n);\n\nlet selected = null;\nlet minTime = Infinity;\n\nfor (const cat of categories) {\n  const id = cat.json.id;\n  const lastUsed = usedMap.get(id) ?? 0;\n\n  if (lastUsed < minTime) {\n    minTime = lastUsed;\n    selected = cat;\n  }\n}\n\nreturn [selected || categories[0]];"
      },
      "typeVersion": 2
    },
    {
      "id": "8f94b488-d3fb-4016-a8ac-ed0e13f78190",
      "name": "10 条最新标题",
      "type": "n8n-nodes-base.postgres",
      "position": [
        400,
        -200
      ],
      "parameters": {
        "query": "SELECT name, description \nFROM used_categories \nWHERE category_id = {{ $json.id }}\nORDER BY used_at DESC \nLIMIT 10;",
        "options": {},
        "operation": "executeQuery"
      },
      "credentials": {
        "postgres": {
          "id": "JKCOXnEh1Bqg4Gad",
          "name": "YOUR_POSTGRES_CREDENTIAL"
        }
      },
      "typeVersion": 2.6,
      "alwaysOutputData": true
    },
    {
      "id": "04349d4d-06cc-48fc-88ae-588ec527fca4",
      "name": "新文章标题",
      "type": "n8n-nodes-base.code",
      "position": [
        960,
        -200
      ],
      "parameters": {
        "jsCode": "return [\n  {\n    json: {\n      title: $input.first().json.output\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "9d145f01-ff77-4c72-bec2-d8ead60d79e5",
      "name": "AI Agent SEO 标题",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        600,
        -200
      ],
      "parameters": {
        "text": "=Based on the category \"{{ $('Picks Less Used').item.json.name }}\"  \nwith the description:  \n{{ $('Picks Less Used').item.json.description }}\n\nHere are existing article titles already published:  \n{{ $items(\"10 latest headlines\").map(i => i.json.description).join(\"\\n\") }}\n\nYour task:  \n- Come up with a **new unique article title** that fits this category  \n- The topic should be narrow, practical, and not duplicate any existing titles  \n- Make it clickable, relevant, and professional  \n- Do **not** reuse or partially copy old titles  \n- Style should be expert-level, insightful, and engaging — no clickbait\n\nImportant:  \n- Output **only** the new title (no extra words, no formatting)  \n- The title must be ready for publication as-is (plain text)",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "29ad413c-4ee4-4d96-8793-3a8cb4a4ce1b",
      "name": "AI Agent SEO 写手",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2020,
        -200
      ],
      "parameters": {
        "text": "=You are writing a blog post using native WordPress HTML blocks.\n\n🧱 Follow this exact structure:\n\n- Paragraphs inside: <!-- wp:paragraph --> ... <!-- /wp:paragraph -->\n- Level 3 headings inside: <!-- wp:heading {\"level\":3} --> ... <!-- /wp:heading -->\n- Level 4 headings inside: <!-- wp:heading {\"level\":4} --> ... <!-- /wp:heading -->\n- Lists inside: <!-- wp:list --> ... <!-- /wp:list -->\n- Table of contents using: <!-- wp:yoast-seo/table-of-contents --> with anchor links\n- Final section: conclusion in list format\n- Final block: call-to-action with the link \"{{ $('Combines full post meta').item.json.link }}\" or {{$node[\"Config\"].json[\"domain\"]}}\n\n🎯 Use the topic info from:\n- name: {{ $json.name }}\n- description: {{ $json.description }}\n- link: {{ $('Combines full post meta').item.json.link }}\n\n---\n\n✍️ General writing guidelines:\n- The main theme always follows `name` and `description`\n- Each post must focus on a new subtopic (narrower than the main theme)\n- The article must be useful, professional, and well-structured\n- Avoid fluff or repetition — deliver actionable advice\n- Output should follow valid WordPress HTML blocks strictly\n\n---\n\n💡 Examples of subtopics for \"{{ $json.name }}\":\n- Top 5 beginner tools in {{ $json.name }}\n- How to choose the right {{ $json.name }} without risks\n- Common mistakes in using {{ $json.name }}\n- How to monetize with CPA or RevShare in {{ $json.name }}\n- Smart strategies to scale {{ $json.name }} traffic in 2025\n- Proven international platforms in {{ $json.name }} — worth trying?\n- What leads to account bans in {{ $json.name }}\n- Top scaling errors in {{ $json.name }}\n\nIn every post, generate a **new and unique** subtopic — no repeats.\n\n---\n\n🚨 Important:\nOnly output raw WordPress blocks — no additional formatting or notes.\n\n🧱 Structure Example:\n\n1. Introduction:\n<!-- wp:paragraph -->\n<p>A short, attention-grabbing intro explaining what the article covers and why it matters.</p>\n<!-- /wp:paragraph -->\n\n2. Table of Contents:\n<!-- wp:yoast-seo/table-of-contents -->\n<div class=\"wp-block-yoast-seo-table-of-contents yoast-table-of-contents\">\n  <h2>Contents</h2>\n  <ul>\n    <li><a href=\"#h-block-1\">Block 1</a></li>\n    <li><a href=\"#h-block-2\">Block 2</a></li>\n    <li><a href=\"#h-block-3\">Block 3</a></li>\n    <li><a href=\"#h-conclusion\">Conclusion</a></li>\n  </ul>\n</div>\n<!-- /wp:yoast-seo/table-of-contents -->\n\n3. Main Content Blocks:\n<!-- wp:heading {\"level\":3} -->\n<h3 class=\"wp-block-heading\" id=\"h-block-1\"><strong><mark style=\"background-color:var(--accent)\" class=\"has-inline-color has-base-3-color\">Block Title</mark></strong></h3>\n<!-- /wp:heading -->\n\n<!-- wp:paragraph -->\n<p>Informative paragraph with practical insights.</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>Optional second paragraph — avoid repetition.</p>\n<!-- /wp:paragraph -->\n\n4. Actionable Tips:\n<!-- wp:list -->\n<ul class=\"wp-block-list\">\n  <li><strong>Tip:</strong> Keep it short and valuable</li>\n  <li><strong>Example:</strong> Provide a link or quick example</li>\n</ul>\n<!-- /wp:list -->\n\n5. Conclusion:\n<!-- wp:heading {\"level\":3} -->\n<h3 class=\"wp-block-heading\" id=\"h-conclusion\"><strong><mark style=\"background-color:var(--accent)\" class=\"has-inline-color has-base-3-color\">Conclusion</mark></strong></h3>\n<!-- /wp:heading -->\n\n<!-- wp:paragraph -->\n<p>Summarize key takeaways and motivate the reader to take action.</p>\n<!-- /wp:paragraph -->\n\n6. Call to Action:\n<!-- wp:paragraph -->\n<p>Read more at <strong><mark style=\"background-color:var(--accent)\" class=\"has-inline-color has-base-3-color\">{{$node[\"Config\"].json[\"domain\"]}}/</mark></strong></p>\n<!-- /wp:paragraph -->",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "5b1efebe-f9e7-4088-9363-75280ba36528",
      "name": "合并标题",
      "type": "n8n-nodes-base.merge",
      "position": [
        1280,
        -540
      ],
      "parameters": {},
      "typeVersion": 3.1
    },
    {
      "id": "187423ce-b80a-4e28-bdd1-02818a6dcd8f",
      "name": "合并完整文章元数据",
      "type": "n8n-nodes-base.code",
      "position": [
        1520,
        -540
      ],
      "parameters": {
        "jsCode": "let data = {};\n$input.all().forEach(item => {\n  Object.assign(data, item.json);\n});\nreturn [{ json: data }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "85c0e9e2-6f2b-4bd4-9f71-f7efe940ed14",
      "name": "更新文章数据库",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1760,
        -540
      ],
      "parameters": {
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "used_categories",
          "cachedResultName": "used_categories"
        },
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "columns": {
          "value": {
            "name": "={{ $json.name }}",
            "title": "={{ $json.title }}",
            "used_at": "={{ new Date().toISOString() }}",
            "category_id": "={{ $json.id }}",
            "description": "={{ $json.description }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "number",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "category_id",
              "type": "number",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "category_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "name",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "used_at",
              "type": "dateTime",
              "display": true,
              "required": false,
              "displayName": "used_at",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "description",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "description",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "title",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "category_id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "upsert"
      },
      "credentials": {
        "postgres": {
          "id": "JKCOXnEh1Bqg4Gad",
          "name": "YOUR_POSTGRES_CREDENTIAL"
        }
      },
      "typeVersion": 2.6
    },
    {
      "id": "73975cf0-165c-4f53-aff9-12872a4dd228",
      "name": "提取输出",
      "type": "n8n-nodes-base.code",
      "position": [
        2380,
        -280
      ],
      "parameters": {
        "jsCode": "return [{\n  json: {\n    content: $input.first().json.output,\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "a5030427-0bc1-499a-903e-e10ba81a9b0d",
      "name": "占位符创建器",
      "type": "n8n-nodes-base.code",
      "position": [
        2380,
        100
      ],
      "parameters": {
        "jsCode": "const name = $('Updating posts DB').first().json.name || \"{{ $json.domain }}\";\nconst encoded = encodeURIComponent(name); \n\nreturn {\n  image_url: `https://placehold.co/1200x675/FF0000/FFFFFF.png?text=${encoded}&font=montserrat`\n};\n"
      },
      "typeVersion": 2
    },
    {
      "id": "6f0f0202-3803-48ef-b8f5-dd56a023c43f",
      "name": "媒体上传到 WP",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2860,
        100
      ],
      "parameters": {
        "url": "={{ $('Config').first().json.domain }}/wp-json/wp/v2/media",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "binaryData",
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Disposition",
              "value": "attachment; filename=crypto.webp"
            },
            {
              "name": "Content-Type",
              "value": "image/png"
            }
          ]
        },
        "inputDataFieldName": "imagedownloaded",
        "nodeCredentialType": "wordpressApi"
      },
      "credentials": {
        "wordpressApi": {
          "id": "7NOAxTvRC1RY2TSN",
          "name": "Wordpress account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "0621bad7-e7bf-4aae-bbf3-2e1f571d81d8",
      "name": "发布到 WP",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3680,
        -520
      ],
      "parameters": {
        "url": "={{ $('Config').first().json.domain }}/wp-json/wp/v2/posts",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "title",
              "value": "={{ $json[\"title\"] }}"
            },
            {
              "name": "content",
              "value": "={{ $json.content }}"
            },
            {
              "name": "status",
              "value": "={{ $json.status }}"
            },
            {
              "name": "featured_media",
              "value": "={{ $json[\"featured_media\"] }}"
            },
            {
              "name": "categories[0]",
              "value": "={{ $json[\"categories\"][0] }}"
            }
          ]
        },
        "nodeCredentialType": "wordpressApi"
      },
      "credentials": {
        "wordpressApi": {
          "id": "7NOAxTvRC1RY2TSN",
          "name": "Wordpress account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "28f3b69a-22a2-4448-a9d0-a5fd42e1ed2c",
      "name": "无操作,什么都不做",
      "type": "n8n-nodes-base.noOp",
      "position": [
        3900,
        -520
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "c98d9193-1dd9-493c-bf76-b72de8e53e28",
      "name": "便签22",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -940,
        -740
      ],
      "parameters": {
        "color": 4,
        "width": 220,
        "height": 360,
        "content": "!在“Config”Set 节点中设置您的 WordPress 域名。"
      },
      "typeVersion": 1
    },
    {
      "id": "1c881f9f-dcf1-4bf0-889b-0738d1ff49a4",
      "name": "配置",
      "type": "n8n-nodes-base.set",
      "position": [
        -880,
        -560
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "d7165db3-6fc8-4398-aa16-29a34ff27d78",
              "name": "domain",
              "type": "string",
              "value": "https://yourdomain.com"
            }
          ]
        }
      },
      "typeVersion": 3.4
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "f787c571-bcc3-47d6-82ca-f138fa2922e1",
  "connections": {
    "12191b30-702c-44dd-bfaf-68de02f627b1": {
      "main": [
        [
          {
            "node": "f477482d-d9b6-4d83-b707-dd19da90e25e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1c881f9f-dcf1-4bf0-889b-0738d1ff49a4": {
      "main": [
        [
          {
            "node": "3f90d8c5-7dd9-41c4-a862-e21942fdc87d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0621bad7-e7bf-4aae-bbf3-2e1f571d81d8": {
      "main": [
        [
          {
            "node": "28f3b69a-22a2-4448-a9d0-a5fd42e1ed2c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5b1efebe-f9e7-4088-9363-75280ba36528": {
      "main": [
        [
          {
            "node": "187423ce-b80a-4e28-bdd1-02818a6dcd8f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "c9450a63-a89e-46eb-b083-b0f40d7b797c": {
      "main": [
        [
          {
            "node": "6f0f0202-3803-48ef-b8f5-dd56a023c43f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "8b2cb2f8-2a2e-4e92-81b6-36e9e2105f94": {
      "main": [
        [
          {
            "node": "083202d5-7053-4775-b053-2e503ce7d73f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3f90d8c5-7dd9-41c4-a862-e21942fdc87d": {
      "main": [
        [
          {
            "node": "8b2cb2f8-2a2e-4e92-81b6-36e9e2105f94",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "98f3ec81-f1f9-425b-83b0-2d5732acb19e": {
      "main": [
        [
          {
            "node": "8f94b488-d3fb-4016-a8ac-ed0e13f78190",
            "type": "main",
            "index": 0
          },
          {
            "node": "5b1efebe-f9e7-4088-9363-75280ba36528",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f71a8a34-5d88-48b0-bf56-44c95d970abd": {
      "main": [
        [
          {
            "node": "1c881f9f-dcf1-4bf0-889b-0738d1ff49a4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "083202d5-7053-4775-b053-2e503ce7d73f": {
      "main": [
        [
          {
            "node": "98f3ec81-f1f9-425b-83b0-2d5732acb19e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "73975cf0-165c-4f53-aff9-12872a4dd228": {
      "main": [
        [
          {
            "node": "12191b30-702c-44dd-bfaf-68de02f627b1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "04349d4d-06cc-48fc-88ae-588ec527fca4": {
      "main": [
        [
          {
            "node": "5b1efebe-f9e7-4088-9363-75280ba36528",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "8ce11fcd-806c-44ea-aa5f-015599eacc98": {
      "ai_languageModel": [
        [
          {
            "node": "29ad413c-4ee4-4d96-8793-3a8cb4a4ce1b",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "f477482d-d9b6-4d83-b707-dd19da90e25e": {
      "main": [
        [
          {
            "node": "0621bad7-e7bf-4aae-bbf3-2e1f571d81d8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "85c0e9e2-6f2b-4bd4-9f71-f7efe940ed14": {
      "main": [
        [
          {
            "node": "29ad413c-4ee4-4d96-8793-3a8cb4a4ce1b",
            "type": "main",
            "index": 0
          },
          {
            "node": "12191b30-702c-44dd-bfaf-68de02f627b1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6f0f0202-3803-48ef-b8f5-dd56a023c43f": {
      "main": [
        [
          {
            "node": "12191b30-702c-44dd-bfaf-68de02f627b1",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "9c21f5ce-b353-4193-a93d-a034e025a1a0": {
      "ai_languageModel": [
        [
          {
            "node": "9d145f01-ff77-4c72-bec2-d8ead60d79e5",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "8f94b488-d3fb-4016-a8ac-ed0e13f78190": {
      "main": [
        [
          {
            "node": "9d145f01-ff77-4c72-bec2-d8ead60d79e5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "29ad413c-4ee4-4d96-8793-3a8cb4a4ce1b": {
      "main": [
        [
          {
            "node": "a5030427-0bc1-499a-903e-e10ba81a9b0d",
            "type": "main",
            "index": 0
          },
          {
            "node": "73975cf0-165c-4f53-aff9-12872a4dd228",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a5030427-0bc1-499a-903e-e10ba81a9b0d": {
      "main": [
        [
          {
            "node": "c9450a63-a89e-46eb-b083-b0f40d7b797c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "9d145f01-ff77-4c72-bec2-d8ead60d79e5": {
      "main": [
        [
          {
            "node": "04349d4d-06cc-48fc-88ae-588ec527fca4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "187423ce-b80a-4e28-bdd1-02818a6dcd8f": {
      "main": [
        [
          {
            "node": "85c0e9e2-6f2b-4bd4-9f71-f7efe940ed14",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 人工智能, 营销

需要付费吗?

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

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

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

作者
AlexWantMoreB

AlexWantMoreB

@alexwmb

Automation consultant helping growth teams, agencies, and founders scale with AI + no-code. I specialize in building GPT-powered content systems, lead gen automations, and PostgreSQL-enhanced flows. 📬 Book custom n8n work or DM for collabs.

外部链接
在 n8n.io 查看

分享此工作流

分类

分类: 34