Hey, hoping someone can point me in the right direction. I want to get all the latest items from an RSS feed and post these in a specific Rocket.Chat channel. I only want items I’ve not posted before (could be more than 1 new RSS post at a time).
RSS URL - Free Games Finders RSS Feed
I’ve tried testing this with an RSS feed that posts every 30 seconds (see below for URL) to test it and it keeps on posting the same things over and over again (with multiple RSS feeds in one block of text instead of separate posts or sometimes posts an empty message).
This is what I’ve got so far:
{
"name": "Test",
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
-720,
-30
]
},
{
"parameters": {
"url": "=https://lorem-rss.herokuapp.com/feed?unit=second&interval=30"
},
"name": "RSS Feed Read",
"type": "n8n-nodes-base.rssFeedRead",
"typeVersion": 1,
"position": [
-440,
200
],
"executeOnce": true
},
{
"parameters": {
"channel": "internal-testing",
"text": "={{$node[\"Return RSS JSON\"].json[\"titleText\"]}}",
"options": {
"alias": "Test RSS",
"avatar": "https://imgur.com/U96w7xq.png"
},
"attachments": []
},
"name": "RocketChat",
"type": "n8n-nodes-base.rocketchat",
"typeVersion": 1,
"position": [
490,
190
],
"credentials": {
"rocketchatApi": "Bot"
}
},
{
"parameters": {
"triggerTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"name": "Cron",
"type": "n8n-nodes-base.cron",
"typeVersion": 1,
"position": [
-630,
200
]
},
{
"parameters": {
"functionCode": "const staticData = this.getWorkflowStaticData('global');\n\nlatestRead = staticData.latestRead;\n\nfor (let item of items) {\n item.json.latestRead = latestRead || '1970-01-01';\n}\n\nreturn items;"
},
"name": "Latest Read",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
-90,
200
]
},
{
"parameters": {
"functionCode": "const staticData = this.getWorkflowStaticData('global');\n\nif (items.length > 0) {\n staticData.latestRead = items[0].json.isoDate || staticData.latestRead;\n}\n\n\nreturn items;"
},
"name": "Write Latest Read",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
300,
50
]
},
{
"parameters": {
"conditions": {
"number": [
{
"value1": "={{new Date($node[\"Latest Read\"].data[\"latestRead\"]).getTime()}}",
"value2": "={{new Date($node[\"RSS Feed Read\"].data[\"isoDate\"]).getTime()}}"
}
]
}
},
"name": "IF",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
90,
200
]
},
{
"parameters": {
"functionCode": "let titleText = '';\nlet rssNum = 0;\n\nfor (let item of items) {\n rssNum = rssNum + 1;\n titleText += `${item.json.title}`;\n}\n\nreturn [{json: {titleText,rssNum}}];\n"
},
"name": "Return RSS JSON",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
300,
200
]
},
{
"parameters": {
"options": {}
},
"name": "SplitInBatches",
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 1,
"position": [
-260,
200
]
},
{
"parameters": {
"functionCode": "let titleText = '';\nlet rssNum = 0;\n\nfor (let item of items) {\n rssNum = rssNum + 1;\n titleText += `${item.json.title}`;\n}\n\nreturn [{json: {titleText,rssNum}}];\n"
},
"name": "Test RSS Results When False - IGNORE",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
300,
360
],
"disabled": true
}
],
"connections": {
"RSS Feed Read": {
"main": [
[
{
"node": "SplitInBatches",
"type": "main",
"index": 0
}
]
]
},
"Cron": {
"main": [
[
{
"node": "RSS Feed Read",
"type": "main",
"index": 0
}
]
]
},
"Latest Read": {
"main": [
[
{
"node": "IF",
"type": "main",
"index": 0
}
]
]
},
"IF": {
"main": [
[
{
"node": "Return RSS JSON",
"type": "main",
"index": 0
},
{
"node": "Write Latest Read",
"type": "main",
"index": 0
}
],
[
{
"node": "Test RSS Results When False - IGNORE",
"type": "main",
"index": 0
}
]
]
},
"Return RSS JSON": {
"main": [
[
{
"node": "RocketChat",
"type": "main",
"index": 0
}
]
]
},
"SplitInBatches": {
"main": [
[
{
"node": "Latest Read",
"type": "main",
"index": 0
}
]
]
},
"Test RSS Results When False - IGNORE": {
"main": [
[
{
"node": "RocketChat",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {},
"id": "2"
}
Example Output:
Any pointers would be appreciated!