How to Make a Node Wait Until Another Node Is Finished When a Node Returns No Value

Hello,

I’ve started experimenting with n8n but I’m stuck at one point. I hope you can give me some tips.

My goal:
I want to mirror my Spotify playlists on YouTube, i.e., synchronize them. Any changes to my Spotify playlists should also be reflected on my YouTube playlists. There are examples at Discover 800+ Automation Workflows from the n8n's Community, but I would like to implement it in my own way.

Currently, my workflow reads my Spotify playlists and uses the “create youtube playlist” node to create any missing playlists. These are initially empty—only the name of the Spotify playlist is created on YouTube. In parallel, I use the “Loop Over Items” node to iterate through each Spotify playlist to read out the individual songs.

My problem:
The marking labeled “A” or “In A only” only returns a value if a new playlist has been created in Spotify. If no new playlist exists, there is no value returned, and “create youtube playlist” is not triggered. Next, I want to prevent the “loop over items” node (labeled “B”) from immediately executing every single time.

I want to achieve the following:

  1. The “loop over items” node should not start if a new YouTube playlist needs to be created. In other words, if “A” returns a value, then “B” should wait until the “create youtube playlist” node finishes.
  2. If “A” does not return a value, meaning no new playlist is needed on YouTube, then “B” can start immediately.

I’m unable to accomplish this with the existing nodes. I can’t use the IF node because IF requires an input value, and “A” doesn’t always produce one—only when new Spotify playlists are created.

I hope I’ve explained the problem clearly.

Thank you,
Aaron

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

n8n version: 1.77.3
Database (default: SQLite): No DB
n8n EXECUTIONS_PROCESS setting (default: own, main): ?
Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
perating system: Win 11

Connect an “If/Switch” node to A. If A returns no value, connect to a “No Operation, do nothing” node. If A returns a value, connect to “Create playlist”.

Or change your switch node and add another value and connect that value to the “No Operation” node.

Thanks for your tip! I have set up an IF condition and can now better control the output of “In A only.”
However, my main problem is still not solved.

Currently, a new playlist (B) “create youtube playlist” is generated if “In A only” is greater than 0.
How can I delay the execution of (C) “Loop Over Items” until (B) has finished its work?

At the same time, I need (C) to run immediately if (A) is executed, meaning (C) should start right away when no new playlist needs to be created.

BR,
Aaron

Hi Aaron,
I think the merge node is what you are looking for. B and C merged, returning only items of C would be the correct behaviour from what I understand. The merge node will wait for both inputs to arrive before executing.

1 Like

Hello Paul,

thanks for your response. The waiting for each other works with Merge, but I am still not able to execute the query:

IF B returns a filled JSON with information, then take B.
IF B returns an empty JSON, then take A.

How can I integrate this query?

Best regards,
Aaron

We’ve created a new category for help with designing workflows, and I’ve moved your question there: Help me Build my Workflow. Find out how this category works by reading this topic.