Hi all,
I’m a new user of n8n, and i’m trying to build a workflow where I collect daily news from multiple RSS feeds and want to filter out the items that have already been sent in the past (links stored in a Google Sheet).
My goal is to only send new items (i.e., not already present in the Google Sheet).
Workflow structure (simplified):
- Many RSS feeds merged together (Merge node, mode: Append)
- Google Sheets node (Get Rows) which returns all previous links
- Both branches (merged RSS items + Google Sheets) go into a Code node (JavaScript)
- In the Code node, I want to filter out any RSS items whose link is already in the sheet
My issue:
No matter what I try, the Code node always returns no output (“No output data returned”) or seems to not filter correctly.
I believe the problem is with how I’m handling multiple inputs in the Code node, or perhaps the order/structure of the data.
I tried multiple different versions of code from various LLMs, but the node always seems to return no output.
Here is a version of the code i have tried:
js
const allInputs = $input.all();
// (In this example, let’s assume allInputs[0] = new RSS items, allInputs[1] = Google Sheet)
// If order is reversed, tried the opposite as well
const newArticlesInput = allInputs[0];
const googleSheetInput = allInputs[1];
// Get all links from Google Sheet (may be empty)
const oldLinks = googleSheetInput && googleSheetInput.items
? googleSheetInput.items.map(i => i.json.link)
: ;
// Get all new RSS items
const newItems = newArticlesInput && newArticlesInput.items
? newArticlesInput.items.map(i => i.json)
: ;
// Filter out those that are already in the sheet
const filtered = newItems.filter(item => !oldLinks.includes(item.link));
// Return new (not already sent) items
return filtered.map(i => ({ json: i }));
What I have tried:
- Swapping the order of the inputs (using
[0]
/[1]
and[1]
/[0]
for newArticlesInput and googleSheetInput) - Printing (console.log) allInputs to see their contents (but output is limited)
- Testing with only one RSS feed + Google Sheets, or many
Question:
- Is there a recommended way to reliably handle multiple inputs in a Code node and distinguish which is which?
- Is there a best practice to ensure the Code node gets data from both RSS and Google Sheets in a predictable way?
- Am I missing something obvious in my code or input handling?
- How can I debug this further?
Any advice, examples, or corrections would be much appreciated! Thank you!