Getting values from multiple input nodes

I apparently still don’t get how to do this.

I have multiple code nodes going into a single slack node. i want to use the output of those code nodes to create a slack message. The issue is that in the message, I’m trying to refer to the different code nodes, but they end up not returning.

The data coming in is something like:

    "Users": 172,
    "oldUsers": 145,
    "ChangeDecimal": 0.18620689655172418,
    "ChangeString": "18.62%"

and the code node names are user_code and contract_code

in the slack node, if iI select the user_code as the input, I can do {{ $json.Users }}, but then (as expected) if I switch to contract_code I’m not getting users, I’m getting contracts.

I thought I could do something like {{ $('contracts_code').item.json.Contracts }} and {{ $('users_code').item.json.Users }}, but those are invalid.

What am I missing here?

If I do {{ $('users_code') }} even when I have it selected it previews as [Object: {}] which is odd since there are values in the left hand side of the node when I’m building.

{{ $('users_code').$input.item.json.totalUsersNow}}

That’s undefined even though on the left I see:

These expressions look good to me in principle. Is there a chance these aren’t executed sequentially (so only one of the two Code nodes actually has data whenever your Slack node runs)? If so, you might need a Merge node to bring these two together before your Slack node. For example like so:

This way, you can simply reference the Merge node instead of your individual code nodes which should be easier.

So, I think it ended up being something more like {{ $('Users3').all()[0].json.total_users_now}}

The trial and error methodology of this (i.e., knowing I needed to reference an array) and then all the n8n specific terms like all and json isn’t ideal. A great feature would be the same drag and drop from the previous nodes into the query builder versus having to write these references by hand.

1 Like

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