RSS contains a value from an array

Hi there

I have a JSON array, eg:

[
{
"name": "Aaron Molinas"
},
{
"name": "Adailton"
},
{
"name": "Adam Buksa"
},
{
"name": "Agustín Rossi"
}
]

I want to consume an RSS Feed: Bulinews.com
And check if anything in the RSS feed, eg: the content of the RSS feed, contains one of the names from my name array above, eg: Aaron Molinas

Any advice on how to achieve this?
My brain hurts - especially when I may want to consume many RSS feeds, and the list of names is over 250 right now

Hey @Arno_Nel, so this is a bit tricky and will require a bit of code as n8n’s Merge node will only be able to compare exact matches. Bulinews does however return articles which might (or might not contain) one of the names you’re interested in.

So my suggestion would be to first read the feed, then fetch the names, and at the end run a Function node with code like this (where RSS Feed Read is the name of your RSS node and Get Names is your node returning names).

const rss_posts = $items("RSS Feed Read");
const names = $items("Get Names").map(e => e.json.name);

for (post of rss_posts) {
  post.json.found_name = names.some(name => post.json.contentSnippet.includes(name));
}

return rss_posts;

This code simply adds a new property found_name to each item from your RSS feed indicating whether the post contains a matching name or not. It uses the .some() method.

Here’s an example workflow with FC Köln as an additional name for testing purposes (since the feed items didn’t currently include the names you have provided):

At the end I get both articles including FC Köln currently available in your feed:

Hope this helps!

2 Likes

That gave me everything I needed. Thanks

Next step is to have many many more RSS feeds, but think I am good for now. Thank you so much !

1 Like

Hi @Arno_Nel, @MutedJam beat me to it … I was working on a solution last night, but could not finish it. And today I was buzzy doing other things up to now. Although Thomas has already given you a elegant solution, I could not keep my workflow to myself …

What I hope that this illustrates, is that there are plenty of different solutions to the same challenge :sunglasses:

2 Likes