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:
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.
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.
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.
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.
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.
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.