Fixing the N8N RSS Feed Trigger

Fixing the N8N RSS Feed Trigger

Jan 08, 2024    

I suspect I’m going to write a fair number of posts about N8N as I work through replacing a lot of my older script and SaaS tool based automations.

One thing that has always been frustrating to implement is automated cross posting of social media and blog publishing to other socials. While I’ve backed off of most social media compared to say 2013 when I was posting just about everything to Facebook, I still like putting up links to my non-tech blog posts and youtube to an personal discord. Previously I was using Zapier for this, which had the best user interface to set up and test this kind of automation that I had seen at that point.

Naively, it should be this simple in N8N:

it should be this simple
It should be this simple ... but it isn't

Unfortunately, because I publish articles on a cron that runs at 6:40 AM but the date of the articles, which is mirrored to the RSS XML, may be many hours before hand the built in RSS polling feature of N8N ignores posts that are older than the polling time minus the polling frequency.

To fix this, there are recommendations on the N8N forums to use a dedicated SaaS RSS reader. I have one of those - Inoreader. But I’d prefer a solution that isn’t reliant on a paid service that I can’t entirely self-host. to fix this we’ll need to make a workflow that remembers the state. This is what I came up with:

more complex
more complex, but it works

Here’s how it works

  • I use a normal trigger and parse the RSS feed using the RSS reader, which gets me the last 10 articles
  • One by one I loop through the items. I need a loop because some of the nodes need to pull from previous steps without getting confused on which index in an item array is being used.
  • for each Item, I make an check to my database (I’m using Elasticsearch but you can use anything) to see if I’ve seen the link before.
  • if I have seen the link before I move on to the next item in the loop
  • if I have not seen the link before I save it into my database and also post a link in discord

The Elasticsearch lookup HTTP GET looks like this (initialize the index with a POST /n8nrss in Elastic DevTools)

  "query": {
      "id.keyword":"\{\{ $json["id"] \}\}"
  "_source": false

The IF statement uses the hits total from the Elastic search results

if statement
checking the hits

when saving in the Elasticsearch node we just have to make sure we write an id property that uses an expression to get a value that looks back to the previous named step

when it's done
there we go it works.