ERROR: can't determine which item to use

Hey guys I have a question. I ran into an issue today. The problem is not that .first and .last doesn’t work for me it’s more that my node code got multiple outputs and if I use first or last it always takes only 1 output as the value instead of all. Any way to fix this?

Hey @Mesh hope all is good.

Would you like to share your workflow, or show something we can actually take a look at? Tell us what you do, what you expect to happen and what actually happens.

Can I share my workflow without showing my tokens? Not sure if they will be uploaded if I copy paste my workflow

If the tokens are used in credentials, they won’t be shown. If they are used in clear text (like in http header fields or JSON body) - then you probably want to remove them before sharing.

this is my current workflow. It is a twitter scraper and I need create a ai agent after the create a row node. My current issue is running on the “create a record1” node. As I mentioned earlier it says can’t determine which item to use. I tried .first .last but my node code got multiple outputs and if I use first or last it always takes only 1 output as the value instead of all.

My goal is just to get this fixed

if possible also please take a look at the whole workflow. Especially the supabase and code nodes. Im a beginner and I used a lot of AI for this so im not sure if everything is correct

Ok, let’s try to unwind this.

Create a record1 node uses to expressions
{{ $('Code12').item.json.text }}
{{ $('Code12').item.json.id }}
to create a record in Airtable.

The Code12 node iterates over tweets, processes them and if all is good returns this

[
  {
    "text": "Full tweet text...",
    "length": 234,
    "id": "tweet_1",
    "author": "elonmusk",
    "createdAt": "2025-07-30T02:25:00.000Z"
  },

  {
    ...
  }
]

and if not, this:

[{
  "message": "No tweets found matching criteria",
  "debug": {
    "totalProcessed": 10,
    "tooShort": 5,
    "duplicates": 3,
    "inputStructure": ["tweets"]
  }
}]

or even this

[{
  error: error.message,
  inputData: ...
}]

In case there are findings - the output will be multiple items, so accessing $('Code12').item.json.text won’t be possible, because it’s not clear which of the items you want to access. It also wont be possible if no messages are found or the code errors out. I’d argue if you need these records to be created based on the the result of code12, split the workflow, where one branch goes to the supabase, and another to the airtable, instead of trying to do it sequentially by trying to reference a previous node.
So, it looks like this logic is quite broken.

Now this part is pure magic

What is the idea behind it?

As for the whole workflow, I don’t have a full picture or see the data flow, to suggest any optimizations. I think it:

  • gets 50 latest posts from a tweet account, then
  • sorts/filters them,
  • gets all rows from supabase,
  • filters out duplicates,
  • then there is that magic loop thing,
  • then searches rows by id,
  • if not found - creates the row in the same table in airtable
  • searches for all records with placeId
  • creates a row in supabase

I think this is somewhat correct, but like I said - without more context, clear explanation and visibility into data flow, it’s difficult to suggest much.

thank you. How would you separate the airtable node and the supabase? Im a beginner, if you have time a step by step guide would help ALOT. Im stuck on this. What do you mean with the loop node?

re: split
I mean “parallel” branches:

re: loop
I just don’t think the loop is doing anything except existing on the canvas :slight_smile:

After what node would you place the do nothing node? My overall goal is to prevent n8n to make duplicates in my Airtable or supabase table. There are not any duplicates in the output but overtime there will be the same tweet again and I don’t want it to be in my table if it already exists. If you know a simple and effective solution for this let me know.

As I mentioned earlier I worked with Ai and it told me to do a lot of stuff that I didn’t even know if it really does something

I will explain the whole workflow give me a min

You shouldn’t place do nothing node, this was just to illustrate the split and how it would look like.

First http: posts the command for the scraper

Wait node: waits a bit so the scraper can load everything

Second http: gets the output of the scraper

Data available: checks if there’s a valid output. If not it will go over to the wait node and wait until output is done.

Code12: honestly don’t know what this really does I just told ChatGPT that I only want tweets as an output that have more than 200 letters.

Get many rows: this just gets all the existing data from my supabase. Don’t know how this helps but I think I created this just to get a json value that I can use for later.

Code123: ChatGPT told me that this prevents duplicate tweets

Loop over: :up_arrow:

Search records: every teeet has a id. It looks for it.

If node: every existing id goes to the false path and every new id creates a record.

After that my goal was to upload the Airtable data automatically to supabase because I want to add a ai agent after that with the knowledge of the supabase.

This workflow scrapes tweets, saves them, uses the tweet posts as knowledge, ai creates a tweet based of the knowledge that I gave. I don’t want duplicates in my Airtable or supabase

is output a single item with all tweets or multiple items, each with a single tween? (you can see this in the execution logs, what is the number on the output side of the node?)

this can be done with the Filter node

this can be done with Remove Duplicates node

So far I don’t understand why you need two data sources - supabase and airtable

Hey my account was new so I got a cooldown. Created a new one. I updated my workflow but Im still getting the same error @jabbson


hey check my previous message

1 Like

You get the same error, because you have the same problem - there are many output items coming out of the Code node and then you try to reference it as if it was a single item.

Try to put a Loop Over Items node after the Code1 node, bring in all further nodes inside the loop and then in the last node, reference Loop node instead of the Code node