Filtering RSS to HTTP

I’m trying to figure out what I would need to filter by newest post, and to make it so that it won’t post again unless there’s new content. Below, you can see what I have currently setup from an example I’ve found, but every time I run the workflow it returns an error that items[0].json is not iterable. I am trying to use this workflow.

filter javascript code

const newItems = [];

for (const item of items[0].json) {
     newItems.push(`- [${item.reason}] => ${item.subject.title} @ ${item.subject.url.replace('api.','').replace('/repos','')}`);
  }

return [{json: {reportMessage: `${newItems.join('\r\n')}`, hasNotifications: items[0].json.length > 0}}];

My workflow

An example of what I’m looking to end up with/TLDR:

Hey @Fenton,

Can you share the input data for your Function node? You maybe getting this error due to incorrect data structure.

Sorry for the late response and thanks for tackling my issue!

Thanks for sharing the workflow!

You’re using a Function node to calculate time, and another one to transform data. The Function node that you’re using to transform data uses item[0].json instead of items. The former points to an individual item, and from what I could understand from your code, you want to iterate through all the items. Since items[0].json is not an error, you get the error. The other thing that I’ve noticed is that the code refers to values that are not present in your workflow eg. subject.title.

Instead of connecting the Function node after the @Get Date 1 ago node, I suggest you connect it right after the RSS Feed Read node. This is because it will allow you to refer to the items, without specifying the node (this is what your current node does).

You can also use the Date and Time node to calculate the time, instead of using a Function node.

Out of curiosity, what exactly is your workflow supposed to do?

1 Like

Hello, hopefully I can fare with this and mark that answer as a solution momentarily, but for an end result id just like it to post a new webhook whenever it detects new RSS content.

Since RSS is not a trigger, you will have to make requests to it at a regular interval, check if the content is new, and then post the new content. This is the concept of pooling. You can read more about it, and learn how you can implement it in n8n in this blogpost: Creating triggers for n8n workflows using polling ⏲