Looking up a value from a series of items

Describe the issue/error/question

I have a series of items flowing through a workflow (usually 2-6 per run) and some or all of these items will generate a Google Chat message. On each of these items there are two relevant names, the assignee name and the actor name. I need to find out their Google Chat user ID and pass it to a node later on.

The Google Chat node does not let me look up a specific user without knowing their ID, but I can “Get All” and return one item per user. I don’t see a reason to return this information multiple time so I select “execute once”. Now I have two problems:

  1. how do I select the specific items I want?
  2. how do I feed them back into the workflow?

1 seems pretty obvious if I was looking for a static value, but I’m trying to find two dynamic values. I probably could do it if I did a Lists node and merged the output into a single node, but since there are 2-6 items running through the workflow, outputting only a single item causes problems later when I want to output a chat per item.

2 is also a problem, if I have 20 users I don’t want to output 20 chat messages, just the 2-6 I started the workflow with. I need to make sure I end this part of the workflow with exactly as many items as I had going into the workflow.

What is the error message (if any)?

Please share the workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version:

EDIT: Follow-up question: if multiple items are running through a workflow, and you have an expression in a node reference an earlier node, which item’s value is selected from that earlier node? Does the second item get value form the second item of the earlier node? If the number of items has changed since that earlier node, how does it know which item to get the value from?

Hi @EricSGS, I am afraid it’s not clear to me how your data looks like from looking at your workflow.

Can you share an example dataset with the JSON data you want to extract the User ID from as well as a the JSON data you want to use for the lookup? We might then be able to put together a quick example workflow using static data to show the basic concept.

I created example data nodes.

The end result should be two chats:

“Eric Edwards commented on John Doe’s task: Test14 which is due on null.”

“Eric Edwards assigned Notta Name the task: Test15 which is due on null.”

John Doe/Notta Name should be a mention and Test14/Test15 should be a link to the task. The message nodes of course aren’t pointed at the right data yet because the data they need to pull is the subject of this topic.

EDIT: I apologize for pinging John there! Forgot that the @ symbol might be used as a mention here. Should have done that as a code snippet or something.

EDIT EDIT: Sometimes the comment chat may be a different task than the assigned task, my example data didn’t do that, let me tweak that…

EDIT EDIT EDIT: Okay, fixed that and made the example data reference two different tasks.