Search JSON Results for ID

I changed {{$node["HTTP Request2"].json["body"]["external_number"].match(/\d+/g)[0]}} for {{$item(0).$node["HTTP Request2"].json["body"]["external_number"].match(/\d+/g)[0]}}.

The problem is that in the IF node, you are referencing data from nodes that have 2 different output lengths. The HTTP Request2 returns just one item, and the function1 returns more than one item.

In the first iteration it will work because both outputs have index 0, but after that, the expression {{$node["HTTP Request2"].json["body"]["external_number"].match(/\d+/g)[0]}} is going to return undefined because it does not have data for an index > 0. By adding the $item(0), we tell the expression to always use the the index 0 no matter the iteration index.

I hope that makes sense.