RSS Feed a Telegram
Buildingblocks
JFC
(@JF_Car)
Este workflow te permite indicar cualqueir cantidad de feeds RSS para que los mensajes nuevos se envíen a un Chat o Canal de Telegram
Creado: 2024-11-27
17 nodos
Instrucciones
Editar Workflow
Visualización del Workflow
{
"meta": {
"instanceId": "08b7c45495aaa3612df600822e44f3d213ac41891a4f0921909837df27d3b120"
},
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
-1080,
360
],
"id": "26a9ba97-46ba-452b-a573-91256e8d5cec"
},
{
"parameters": {
"url": "={{$json[\"url\"]}}",
"options": {}
},
"name": "RSS Feed Read",
"type": "n8n-nodes-base.rssFeedRead",
"typeVersion": 1,
"position": [
-840,
740
],
"id": "a80514e6-ee95-4cd0-967e-3490d350e6de",
"retryOnFail": true,
"maxTries": 5,
"waitBetweenTries": 5000
},
{
"parameters": {
"amount": 5,
"unit": "seconds"
},
"name": "Wait",
"type": "n8n-nodes-base.wait",
"typeVersion": 1,
"position": [
-800,
1240
],
"webhookId": "f2bf5839-9445-4481-a31a-ad821c7067af",
"id": "87e7c4c5-d31c-44e4-b4e2-8789353a2484"
},
{
"parameters": {
"functionCode": "return [\n\n\n {\n json: {\n title: '\ud83d\ude80 Tenemos un nuevo RELEASE!',\n url: 'https://github.com/borgbackup/borg/releases.atom',\n }\n }\n\n\n];"
},
"name": "Set RSS Feeds",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
-840,
540
],
"id": "334c736f-2d6b-4267-b27b-33c3912f1eb0"
},
{
"parameters": {
"batchSize": 1,
"options": {
"reset": "={{$node[\"SplitInBatchesMessages\"].context[\"noItemsLeft\"]}}"
}
},
"name": "SplitInBatchesMessages",
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 1,
"position": [
-1020,
1240
],
"id": "4de2e4b2-024d-41b5-859f-00b56252423b"
},
{
"parameters": {
"batchSize": 1,
"options": {}
},
"name": "SplitInBatchesRSS",
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 1,
"position": [
-1060,
740
],
"id": "b497c29d-b536-4221-ba6b-5cb9f52fb85e"
},
{
"parameters": {
"operation": "sort",
"sortFieldsUi": {
"sortField": [
{
"fieldName": "isoDate"
}
]
},
"options": {}
},
"name": "Item Lists",
"type": "n8n-nodes-base.itemLists",
"typeVersion": 1,
"position": [
-140,
1040
],
"id": "62f77631-0cbe-4ca4-9461-c2ef4131974f",
"retryOnFail": false,
"alwaysOutputData": false,
"continueOnFail": true
},
{
"parameters": {
"conditions": {
"boolean": [
{
"value1": "={{true}}",
"value2": "={{$node[\"SplitInBatchesRSS\"].context[\"noItemsLeft\"]}}"
}
]
}
},
"name": "RSSLoopFinished",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
-140,
1300
],
"id": "3ec58ae1-0a27-4296-8f97-bceb20c51b06"
},
{
"parameters": {
"conditions": {
"boolean": [
{
"value1": "={{true}}",
"value2": "={{$node[\"SplitInBatchesMessages\"].context[\"noItemsLeft\"]}}"
}
]
}
},
"name": "MessagesLoopFinished",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
-380,
1240
],
"id": "aca36770-a01b-47dd-accd-53ada94e3a05"
},
{
"parameters": {
"functionCode": "return [{json: {empty: items.length == 1 && Object.keys(items[0].json).length == 0}}];"
},
"name": "Is Empty?",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
-800,
960
],
"id": "bdb660f1-9b4f-45c0-a838-d6d0877e403d"
},
{
"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]"
},
"id": "aa19aae0-81da-4022-97db-5a486bcf4c6e",
"name": "clear",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
-140,
760
]
},
{
"parameters": {},
"id": "19d5e20b-53ae-4d22-92b2-2a1fe045806d",
"name": "NoOp",
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [
-380,
1040
]
},
{
"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"
},
"name": "only get new RSS",
"type": "n8n-nodes-base.function",
"position": [
-620,
740
],
"typeVersion": 1,
"id": "d70ea9b8-047d-433f-b2c9-5d6cfc0a4226",
"alwaysOutputData": false
},
{
"parameters": {
"functionCode": "const staticData2 = getWorkflowStaticData('global');\nconst newRSSIds2 = items.map(item => item.json[\"isoDate\"]);\nconst oldRSSIds2 = staticData2.oldRSSIds2; \n\nif (!oldRSSIds2) {\n staticData2.oldRSSIds2 = newRSSIds2;\n return items;\n}\n\n\nconst actualNewRSSIds2 = newRSSIds2.filter((id) => !oldRSSIds2.includes(id));\nconst actualNewRSS2 = items.filter((data) => actualNewRSSIds2.includes(data.json['isoDate']));\nstaticData2.oldRSSIds2 = [...actualNewRSSIds2, ...oldRSSIds2];\n\nreturn actualNewRSS2;\n"
},
"name": "only get new RSS CONTROL",
"type": "n8n-nodes-base.function",
"position": [
-1020,
960
],
"typeVersion": 1,
"id": "7ff41e59-1428-4a9d-891a-e13da501f7ec",
"alwaysOutputData": true
},
{
"parameters": {
"conditions": {
"boolean": [
{
"value1": "={{$json[\"empty\"]}}"
}
],
"number": []
}
},
"name": "Is not Empty",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
-600,
960
],
"id": "a9baa689-18a5-43e4-ba35-9479a004032c",
"executeOnce": true
},
{
"parameters": {
"text": "={{ $('SplitInBatchesRSS').item.json[\"title\"] }}:\n{{$json[\"title\"]}}\n\n{{$json[\"contentSnippet\"].slice(0,500).replaceAll(/<\\/?[^>]+(>|$)/gi, \"\").slice()}}...\n\n{{$json[\"link\"]}}",
"additionalFields": {
"parse_mode": "HTML"
}
},
"name": "channel",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1,
"position": [
-600,
1240
],
"retryOnFail": true,
"maxTries": 5,
"waitBetweenTries": 5000,
"id": "6d8b877d-22b0-49c8-abdc-48e2323ec9d8",
"executeOnce": true,
"credentials": {
"telegramApi": {
"id": "0oAdbqW4gS3AxcIx",
"name": "Borg-bot"
}
}
},
{
"parameters": {
"triggerTimes": {
"item": [
{
"hour": 4
}
]
}
},
"name": "Cron 0400H",
"type": "n8n-nodes-base.cron",
"typeVersion": 1,
"position": [
-1080,
540
],
"id": "84730314-5dc5-4851-9410-3521de25ace8"
}
],
"connections": {
"Start": {
"main": [
[
{
"node": "Set RSS Feeds",
"type": "main",
"index": 0
}
]
]
},
"RSS Feed Read": {
"main": [
[
{
"node": "only get new RSS",
"type": "main",
"index": 0
},
{
"node": "only get new RSS CONTROL",
"type": "main",
"index": 0
}
]
]
},
"Wait": {
"main": [
[
{
"node": "channel",
"type": "main",
"index": 0
}
]
]
},
"Set RSS Feeds": {
"main": [
[
{
"node": "SplitInBatchesRSS",
"type": "main",
"index": 0
}
]
]
},
"SplitInBatchesMessages": {
"main": [
[
{
"node": "Wait",
"type": "main",
"index": 0
}
]
]
},
"SplitInBatchesRSS": {
"main": [
[
{
"node": "RSS Feed Read",
"type": "main",
"index": 0
}
]
]
},
"Item Lists": {
"main": [
[
{
"node": "SplitInBatchesMessages",
"type": "main",
"index": 0
}
]
]
},
"RSSLoopFinished": {
"main": [
null,
[
{
"node": "SplitInBatchesRSS",
"type": "main",
"index": 0
}
]
]
},
"MessagesLoopFinished": {
"main": [
[
{
"node": "RSSLoopFinished",
"type": "main",
"index": 0
}
],
[
{
"node": "SplitInBatchesMessages",
"type": "main",
"index": 0
}
]
]
},
"Is Empty?": {
"main": [
[
{
"node": "Is not Empty",
"type": "main",
"index": 0
}
]
]
},
"only get new RSS": {
"main": [
[
{
"node": "Item Lists",
"type": "main",
"index": 0
}
]
]
},
"only get new RSS CONTROL": {
"main": [
[
{
"node": "Is Empty?",
"type": "main",
"index": 0
}
]
]
},
"Is not Empty": {
"main": [
[
{
"node": "NoOp",
"type": "main",
"index": 0
}
],
[
{
"node": "SplitInBatchesRSS",
"type": "main",
"index": 0
}
]
]
},
"channel": {
"main": [
[
{
"node": "MessagesLoopFinished",
"type": "main",
"index": 0
}
]
]
},
"Cron 0400H": {
"main": [
[
{
"node": "Set RSS Feeds",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {}
}