How do I compare and deduplicate output from two different nodes?

Workflow Overview and Issue Summary

This n8n workflow is designed to isolate newly posted RFPs from the Food System Network website and create new AITable records for them. To do this, the workflow consists of two parallel paths:

  1. Retrieving recent RFP records from AITable: This path fetches the RFPs that have already been processed and stored.
  2. Scraping RFPs from the Food System Network website: This path collects the most recent RFPs available on the website.

These paths converge at a Merge node, followed by a Code node for final processing. The critical task here is to compare the newly scraped RFPs against the existing AITable records to identify truly new entries. This comparison is essential to prevent duplicating RFPs that have already been processed.

The main challenge lies in configuring these final two nodes to:

  1. Correctly combine the data streams from both paths (Merge node).
  2. Efficiently compare the combined data to identify new RFPs (Code node).
  3. Remove any duplicates, ensuring only unique, new RFPs are output for addition to AITable.

This process of comparison and deduplication is crucial for maintaining the integrity of the AITable records and ensuring that only genuinely new RFPs are added to the system. The difficulty arises in implementing this logic effectively within the n8n environment, particularly in structuring the comparison process and handling the data manipulation required for deduplication.

Goal: To produce a final list of unique, new RFPs that are not already present in AITable, ready for insertion as new records.

Workflow

Once this output is achieved, the workflow would proceed to add the necessary nodes to write new records in AITable for th1. Scraping RFPs from the Food System Network website: This path collects the most recent RFPs available on the website.ese new RFPs. This final step would complete the automation process by updating the AITable with the newly identified RFPs from the Food System Network website.

Request for Assistance

I’m seeking guidance on how to properly configure the Merge and Code nodes to achieve this desired output. Specifically:

  1. How should the Merge node be set up to effectively combine the two data streams?
  2. What logic should be implemented in the Code node to perform the deduplication and produce the final list of new RFPs?

Any insights or code snippets that could help achieve this would be greatly appreciated. Thank you in advance for your assistance!

Alternative Approaches Welcome

While I’ve outlined a specific workflow and issue above, I’m completely open to suggestions for entirely different approaches. If you believe there’s a more efficient or elegant way to achieve the same goal of identifying and isolating new RFPs from the Food System Network website for addition to AITable, I’d be very interested in hearing about it.

Some questions I’m considering:

  1. Is there a better way to structure this workflow?
  2. Are there n8n nodes or features I’m not utilizing that could simplify this process?
  3. Could this be accomplished more effectively with a different combination of nodes or fewer steps?

I’m eager to learn and improve my n8n skills, so any alternative solutions or best practices you can share would be greatly appreciated. Don’t hesitate to suggest a complete redesign if you think it would lead to a more robust or maintainable solution. Thank you for your insights!

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

n8n version: 1.63.4
Running n8n via self-hosted cloud (elest.io)

hello @SaltationAI

I’ve added some fixes to return the records, which are not present in the aiTable

or you can do the same with the Merge node

BTW did you use the ChatGPT for the topic description? :sweat_smile:

2 Likes

This did the trick, thank you so much!

I’m going through your work here to understand, but I think I’d still really benefit from a quick explanation of what I was doing wrong and what your fixes were?

And yes, I just started working with n8n this weekend so I worked with Claude to compose the topic, which felt complicated and overwhelming to try and explain on my own!

You were almost correct, but I didn’t get the point of why you have chosen to return records from both sources as distinct arrays. Instead of that I’ve returned them as separate items, so the merge node could be used in compare mode and it’s easier to compare items.

However, your option is also doable within the Code node (my first method)

1 Like

Thank you so much, I’m grateful for your assistance with this!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.