8
n8n 中文网amn8n.com

使用Gemini从WordPress生成AI驱动的每周邮件通讯

中级

这是一个Social Media, Multimodal AI领域的自动化工作流,包含 8 个节点。主要使用 If, Code, EmailSend, Wordpress, Agent 等节点。 使用Gemini从WordPress生成AI驱动的每周邮件通讯

前置要求
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "2000c64071c20843606b95c63795bb0797c41036047055a6586498e855b96efc",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "88ced829-6881-4846-93b1-b2f7d1779841",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        768,
        80
      ],
      "parameters": {
        "width": 380,
        "height": 460,
        "content": "## 每周电子邮件通讯生成器"
      },
      "typeVersion": 1
    },
    {
      "id": "c6dd067a-b2b4-4fc4-b14d-d300aa789437",
      "name": "每周五上午10点",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        976,
        192
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 10 * * 5"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "396b5f52-a71c-4235-9409-25850114eda3",
      "name": "获取近期文章",
      "type": "n8n-nodes-base.wordpress",
      "position": [
        1168,
        192
      ],
      "parameters": {
        "options": {},
        "operation": "getAll"
      },
      "typeVersion": 1
    },
    {
      "id": "08ae5166-ef2d-47db-9138-6de7a1621d95",
      "name": "检查文章是否存在",
      "type": "n8n-nodes-base.if",
      "position": [
        1376,
        192
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c0a1b2c3-d4e5-f6g7-h8i9-j0k1l2m3n4o5",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{$json.length}}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "97d30b53-49ab-4e86-910e-a23550a9cb4e",
      "name": "AI 通讯创建器",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1568,
        192
      ],
      "parameters": {
        "options": {
          "systemMessage": "You are an email newsletter writer. Create an engaging weekly newsletter based on the provided blog posts. Include: 1) Catchy subject line, 2) Personal greeting, 3) Brief intro about this week's content, 4) Formatted summaries of each post with compelling descriptions, 5) Call-to-action to read full posts, 6) Friendly sign-off. Keep it conversational and engaging. Format in HTML for email."
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "aa3ee18d-2858-456b-a3de-c3ec6888d87f",
      "name": "解析通讯内容",
      "type": "n8n-nodes-base.code",
      "position": [
        1952,
        192
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\n\nreturn items.map(item => {\n  // Remove markdown code blocks and parse JSON\n  let aiOutput = item.json.output;\n  \n  // Remove ```json and ``` markers if present\n  aiOutput = aiOutput.replace(/```json\\s*/, '').replace(/```\\s*$/, '');\n  \n  // Try to parse as JSON, fallback to plain text\n  let parsedOutput;\n  try {\n    parsedOutput = JSON.parse(aiOutput.trim());\n  } catch (e) {\n    // If not JSON, treat as plain text\n    parsedOutput = {\n      subject: \"Weekly Newsletter - \" + new Date().toLocaleDateString(),\n      content: aiOutput\n    };\n  }\n  \n  return {\n    json: {\n      subject: parsedOutput.subject || \"Weekly Newsletter - \" + new Date().toLocaleDateString(),\n      content: parsedOutput.content || aiOutput,\n      date: new Date().toISOString()\n    }\n  };\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "759e35de-6eaa-4b3e-b1a1-94d9d029a4d3",
      "name": "发送通讯",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        2144,
        192
      ],
      "webhookId": "0dd49cd6-d161-4597-adbb-1abedc6f0248",
      "parameters": {
        "html": "={{$json.content}}",
        "options": {},
        "subject": "={{$json.subject}}",
        "toEmail": "=subscribers@yourlist.com,subscriber2@email.com,subscriber3@email.com",
        "fromEmail": "newsletter@yoursite.com",
        "emailFormat": "html"
      },
      "credentials": {
        "smtp": {
          "id": "0xVva6dyyi5SuxBe",
          "name": "SMTP account"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "48dc6212-0580-40f5-94ba-5f6dc3f207d8",
      "name": "Google Gemini聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1472,
        384
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "id": "wNw45YZvXXpeocJ2",
          "name": "TST API"
        }
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Check Posts Exist": {
      "main": [
        [
          {
            "node": "AI Newsletter Creator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Recent Posts": {
      "main": [
        [
          {
            "node": "Check Posts Exist",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Weekly Friday 10AM": {
      "main": [
        [
          {
            "node": "Fetch Recent Posts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Newsletter Creator": {
      "main": [
        [
          {
            "node": "Parse Newsletter Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Newsletter Creator",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Parse Newsletter Content": {
      "main": [
        [
          {
            "node": "Send Newsletter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 社交媒体, 多模态 AI

需要付费吗?

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

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

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

作者
David Olusola

David Olusola

@dae221

I help ambitious businesses eliminate operational bottlenecks and scale faster with AI automation. My clients typically see 40-60% efficiency gains within 90 days. Currently accepting 3 new projects this quarter - david@daexai.com

外部链接
在 n8n.io 查看

分享此工作流