Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
{
"name": "Automated Blog",
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
-700,
200
]
},
{
"parameters": {
"url": "(ADD YOUR TINY TINY RSS HERE)"
},
"name": "RSS Feed Read",
"type": "n8n-nodes-base.rssFeedRead",
"position": [
-400,
200
],
"typeVersion": 1
},
{
"parameters": {
"triggerTimes": {
"item": [
{
"mode": "everyX",
"value": 10,
"unit": "minutes"
}
]
}
},
"name": "Cron",
"type": "n8n-nodes-base.cron",
"position": [
-550,
200
],
"typeVersion": 1
},
{
"parameters": {
"functionCode": "// Get the global workflow static data\nconst staticData = getWorkflowStaticData('global');\n\n// Access its data\nconst lastRssId = staticData.lastRssId\n\nlet list = []\n\n\nfor (const item of $items(\"RSS Feed Read\")){\n let currentId = item.json[\"id\"].split('/').pop()\n if(currentId == lastRssId) break;\n let length = 1000;\n let contentSnippet = item.json['contentSnippet'].length > length ? item.json['contentSnippet'].substring(0, length - 3) + \"...\" : item.json['contentSnippet'];\n let content = `${contentSnippet}\\r\\n\\r\\n<h3>Written By: ${item.json['author']}</h3>\\r\\n<h3>Original Article: <a href=\"${item.json['link']}\">${item.json['link']}</a></h3>`;\n list.push({'json': {\n 'id': currentId,\n 'author': item.json['author'],\n 'lastId': lastRssId,\n 'title': item.json[\"title\"],\n 'url': item.json[\"link\"],\n 'content': content\n }})\n}\n\n\n// Get the last ID from Rss Feed\nlet currentRssId = $item(0).$node[\"RSS Feed Read\"].json[\"id\"].split('/').pop()\n\n// TODO: make a loop to get all the items beyond the last saved id\nif(!lastRssId || currentRssId != lastRssId)\n{ \n // Update its data\n staticData.lastRssId = currentRssId;\n \n}\nelse { list = [{'json':{'id': 'NaN', 'lastId': staticData.lastRssId }}] }\nreturn list;\n\n"
},
"name": "Function",
"type": "n8n-nodes-base.function",
"position": [
-250,
200
],
"typeVersion": 1
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{$node[\"Function\"].json[\"id\"]}}",
"operation": "notEqual",
"value2": "NaN"
}
],
"boolean": []
}
},
"name": "IF",
"type": "n8n-nodes-base.if",
"position": [
-100,
200
],
"typeVersion": 1
},
{
"parameters": {},
"name": "NoOp",
"type": "n8n-nodes-base.noOp",
"position": [
50,
300
],
"typeVersion": 1
},
{
"parameters": {
"title": "={{$json[\"title\"]}}",
"additionalFields": {
"content": "={{$json[\"content\"]}}",
"status": "publish",
"format": "standard",
"categories": [
2
]
}
},
"name": "Wordpress",
"type": "n8n-nodes-base.wordpress",
"typeVersion": 1,
"position": [
50,
100
],
"credentials": {
"wordpressApi": "somecredsbb"
}
}
],
"connections": {
"IF": {
"main": [
[
{
"node": "Wordpress",
"type": "main",
"index": 0
}
],
[
{
"node": "NoOp",
"type": "main",
"index": 0
}
]
]
},
"Cron": {
"main": [
[
{
"node": "RSS Feed Read",
"type": "main",
"index": 0
}
]
]
},
"Function": {
"main": [
[
{
"node": "IF",
"type": "main",
"index": 0
}
]
]
},
"RSS Feed Read": {
"main": [
[
{
"node": "Function",
"type": "main",
"index": 0
}
]
]
}
},
"active": true,
"settings": {},
"id": 3
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment