Comparing data from 2 AI nodes

I’m using gpt3.5 turbo to extract data from invoices, I’m trying to figure out the best way to validate the data.

I believe comparing the unit_price*qty summed up for all line items to determine a subtotal and then comparing that to the extracted subtotal should be nearly foolproof, question is how to do such validation in n8n (besides using javascript).

I tried using the IF module but it doesn’t allow me to validate data between different nodes/modules.

Here are some screenshots
IF node


Hi @Eden, from looking at your screenshot it appears you’re looking to compare data coming from your ParseJSON node and your AI Validator node with both nodes returning a different number of items.

Unfortunately I do not know how your exact data structure look like, but on a very general level the Merge node would allow you to compare data coming from two different branches. This could look like so:

In this example only one of the items in the second branch matches the grand_total value of the first branch. The Merge node will only pass through this single matching item and discard the non-matches.

Hope this helps :slight_smile: