8
n8n 中文网amn8n.com

从多个 RSS 源获取数据到 Telegram

中级

这是一个Building Blocks领域的自动化工作流,包含 11 个节点。主要使用 If, Cron, Function, Telegram, RssFeedRead 等节点。 从多个 RSS 源获取数据到 Telegram

前置要求
  • Telegram Bot Token
工作流预览
可视化展示节点连接关系,支持缩放和平移

无法加载工作流预览

导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "nodes": [
    {
      "name": "RSS 源读取",
      "type": "n8n-nodes-base.rssFeedRead",
      "position": [
        420,
        -20
      ],
      "parameters": {
        "url": "={{$node[\"SplitInBatches\"].json[\"url\"]}}"
      },
      "typeVersion": 1
    },
    {
      "name": "分批处理",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        200,
        -20
      ],
      "parameters": {
        "options": {},
        "batchSize": 1
      },
      "typeVersion": 1
    },
    {
      "name": "定时任务",
      "type": "n8n-nodes-base.cron",
      "position": [
        -240,
        -20
      ],
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "mode": "everyX",
              "unit": "minutes",
              "value": 10
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "name": "仅获取新 RSS",
      "type": "n8n-nodes-base.function",
      "position": [
        640,
        -20
      ],
      "parameters": {
        "functionCode": "const staticData = getWorkflowStaticData('global');\nconst newRSSIds = items.map(item => item.json[\"isoDate\"]);\nconst oldRSSIds = staticData.oldRSSIds; \n\nif (!oldRSSIds) {\n  staticData.oldRSSIds = newRSSIds;\n  return items;\n}\n\n\nconst actualNewRSSIds = newRSSIds.filter((id) => !oldRSSIds.includes(id));\nconst actualNewRSS = items.filter((data) => actualNewRSSIds.includes(data.json['isoDate']));\nstaticData.oldRSSIds = [...actualNewRSSIds, ...oldRSSIds];\n\nreturn actualNewRSS;\n"
      },
      "typeVersion": 1
    },
    {
      "name": "Telegram_IT",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1220,
        460
      ],
      "parameters": {
        "text": "={{$json[\"title\"]}}\n{{$json[\"link\"]}}",
        "chatId": "TelegramID",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "2",
          "name": "IT_RSS"
        }
      },
      "typeVersion": 1
    },
    {
      "name": "Telegram_安全",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1220,
        220
      ],
      "parameters": {
        "text": "={{$json[\"title\"]}}\n{{$json[\"link\"]}}",
        "chatId": "TelegramID",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "4",
          "name": "Security_RSS"
        }
      },
      "typeVersion": 1
    },
    {
      "name": "RSS 源",
      "type": "n8n-nodes-base.function",
      "position": [
        -20,
        -20
      ],
      "parameters": {
        "functionCode": "return [\n  {\n    json: {\n      url: 'https://feeds.feedburner.com/UnikosHardware',\n    }\n  },\n  {\n    json: {\n      url: 'http://www.ithome.com.tw/rss.php',\n    }\n  },\n  {\n    json: {\n      url: 'http://feeds.feedburner.com/playpc',\n    }\n  },\n  {\n    json: {\n      url: 'https://lab.ocf.tw/feed/',\n    }\n  },\n  {\n    json: {\n      url: 'https://techcommunity.microsoft.com/plugins/custom/microsoft/o365/custom-blog-rss?tid=3754543230341459569&board=microsoft_365blog',\n    }\n  }\n];"
      },
      "typeVersion": 1
    },
    {
      "name": "Telegram_M365",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1220,
        -40
      ],
      "parameters": {
        "text": "={{$json[\"title\"]}}\n{{$json[\"link\"]}}",
        "chatId": "TelegramID",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "5",
          "name": "M365_RSS"
        }
      },
      "typeVersion": 1
    },
    {
      "name": "IF-2",
      "type": "n8n-nodes-base.if",
      "position": [
        880,
        240
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"title\"]}}",
              "value2": "資安|資訊安全|安全|外洩|監控|威脅|漏洞|封鎖|修補|攻擊|入侵|個資|隱私|私密|騙|社交工程|釣魚|駭|Security|security|Secure|secure",
              "operation": "regex"
            }
          ]
        },
        "combineOperation": "any"
      },
      "typeVersion": 1
    },
    {
      "name": "IF-1",
      "type": "n8n-nodes-base.if",
      "position": [
        880,
        -20
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"link\"]}}",
              "value2": "techcommunity.microsoft.com",
              "operation": "contains"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "name": "清除函数",
      "type": "n8n-nodes-base.function",
      "position": [
        -20,
        -180
      ],
      "parameters": {
        "functionCode": "// Get the global workflow static data\nconst staticData = getWorkflowStaticData('global');\n// Update its data\nstaticData.oldRSSIds = new Date().getTime();\n// Delete data\ndelete staticData.oldRSSIds;\n\nreturn [\n  {\n    json: {}\n  }\n]"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Cron": {
      "main": [
        [
          {
            "node": "RSS Source",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF-1": {
      "main": [
        [
          {
            "node": "Telegram_M365",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "IF-2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF-2": {
      "main": [
        [
          {
            "node": "Telegram_Security",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Telegram_IT",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "RSS Source": {
      "main": [
        [
          {
            "node": "SplitInBatches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "RSS Feed Read": {
      "main": [
        [
          {
            "node": "SplitInBatches",
            "type": "main",
            "index": 0
          },
          {
            "node": "only get new RSS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SplitInBatches": {
      "main": [
        [
          {
            "node": "RSS Feed Read",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "only get new RSS": {
      "main": [
        [
          {
            "node": "IF-1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 构建模块

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流