Problems with Spotify Workflow

I have the attached workflow that I am having issues with. Everything works as expected until it gets to the final Spotify step which is to add the songs that match the IF statements to the specified playlist “Dance”. There should be 12 matching songs from this weeks Discover Weekly playlist but it only adds the first one for some reason. I thought it was only adding one in testing but I let the workflow trigger at its normal time this morning and the same thing occurred. Any insight would be greatly appreciated.

{
  "name": "Spotify Archive Discover Weekly",
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        140,
        110
      ],
      "disabled": true
    },
    {
      "parameters": {
        "resource": "playlist",
        "operation": "getUserPlaylists",
        "returnAll": true
      },
      "name": "Get Playlists",
      "type": "n8n-nodes-base.spotify",
      "position": [
        250,
        -160
      ],
      "executeOnce": false,
      "typeVersion": 1,
      "retryOnFail": true,
      "maxTries": 5,
      "credentials": {
        "spotifyOAuth2Api": "Colin"
      }
    },
    {
      "parameters": {
        "resource": "playlist",
        "operation": "getTracks",
        "id": "={{$node[\"Find Weekly Playlist\"].json[\"uri\"]}}",
        "returnAll": true
      },
      "name": "Get Tracks",
      "type": "n8n-nodes-base.spotify",
      "position": [
        870,
        340
      ],
      "executeOnce": true,
      "typeVersion": 1,
      "alwaysOutputData": false,
      "retryOnFail": true,
      "maxTries": 5,
      "credentials": {
        "spotifyOAuth2Api": "Colin"
      }
    },
    {
      "parameters": {
        "resource": "playlist",
        "id": "={{$item(0).$node[\"Find Archive Playlist\"].json[\"uri\"]}}",
        "trackID": "={{$json[\"track\"][\"uri\"]}}"
      },
      "name": "Save to Archive",
      "type": "n8n-nodes-base.spotify",
      "position": [
        1020,
        500
      ],
      "executeOnce": false,
      "typeVersion": 1,
      "retryOnFail": true,
      "maxTries": 5,
      "credentials": {
        "spotifyOAuth2Api": "Colin"
      }
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"name\"]}}",
              "value2": "Discover Weekly Archive"
            }
          ]
        }
      },
      "name": "Find Archive Playlist",
      "type": "n8n-nodes-base.if",
      "position": [
        510,
        30
      ],
      "typeVersion": 1,
      "retryOnFail": true,
      "maxTries": 5
    },
    {
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "mode": "everyWeek",
              "hour": 10
            }
          ]
        }
      },
      "name": "Cron",
      "type": "n8n-nodes-base.cron",
      "position": [
        -220,
        -160
      ],
      "notesInFlow": false,
      "typeVersion": 1
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"name\"]}}",
              "value2": "Discover Weekly"
            }
          ]
        }
      },
      "name": "Find Weekly Playlist",
      "type": "n8n-nodes-base.if",
      "position": [
        500,
        240
      ],
      "typeVersion": 1,
      "retryOnFail": true,
      "maxTries": 5
    },
    {
      "parameters": {
        "mode": "wait"
      },
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        720,
        340
      ],
      "typeVersion": 1,
      "retryOnFail": true,
      "maxTries": 5
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "operation": "append",
        "sheetId": "1_YMgIP_f8XKOc9wl7djtRtEmLicyzik1oqBL4P4uNug",
        "range": "A:M",
        "options": {}
      },
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        2050,
        590
      ],
      "retryOnFail": true,
      "maxTries": 5,
      "credentials": {
        "googleSheetsOAuth2Api": "Colin"
      }
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "Song",
              "value": "={{$node[\"Get Tracks\"].json[\"track\"][\"name\"]}}"
            },
            {
              "name": "Artist",
              "value": "={{$node[\"Get Tracks\"].json[\"track\"][\"artists\"][0][\"name\"]}}"
            },
            {
              "name": "Dancability",
              "value": "={{$json[\"danceability\"]}}"
            },
            {
              "name": "Energy",
              "value": "={{$json[\"energy\"]}}"
            },
            {
              "name": "Tempo",
              "value": "={{$json[\"tempo\"]}}"
            },
            {
              "name": "Acoustic",
              "value": "={{$json[\"acousticness\"]}}"
            },
            {
              "name": "Instrumental",
              "value": "={{$json[\"instrumentalness\"]}}"
            },
            {
              "name": "Liveness",
              "value": "={{$json[\"liveness\"]}}"
            },
            {
              "name": "Loudness",
              "value": "={{$json[\"loudness\"]}}"
            },
            {
              "name": "Valance",
              "value": "={{$json[\"valence\"]}}"
            },
            {
              "name": "Track ID",
              "value": "={{$json[\"id\"]}}"
            }
          ],
          "number": []
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        1220,
        370
      ],
      "retryOnFail": true,
      "maxTries": 5
    },
    {
      "parameters": {
        "resource": "track",
        "operation": "getAudioFeatures",
        "id": "={{$json[\"track\"][\"id\"]}}"
      },
      "name": "Spotify",
      "type": "n8n-nodes-base.spotify",
      "typeVersion": 1,
      "position": [
        1020,
        190
      ],
      "retryOnFail": true,
      "maxTries": 5,
      "credentials": {
        "spotifyOAuth2Api": "Colin"
      }
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "url": "=https://api.spotify.com/v1/search?q={{$node[\"Get Tracks\"].json[\"track\"][\"artists\"][0][\"name\"]}}&limit=1&type=artist",
        "options": {}
      },
      "name": "Get Artist Details",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1340,
        600
      ],
      "retryOnFail": true,
      "maxTries": 5,
      "credentials": {
        "oAuth2Api": "Colin-Spotify"
      }
    },
    {
      "parameters": {
        "mode": "mergeByIndex"
      },
      "name": "Merge1",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 1,
      "position": [
        1650,
        590
      ],
      "alwaysOutputData": true,
      "retryOnFail": true,
      "maxTries": 5
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "Song",
              "value": "={{$node[\"Get Tracks\"].json[\"track\"][\"name\"]}}"
            },
            {
              "name": "Artist",
              "value": "={{$node[\"Get Tracks\"].json[\"track\"][\"artists\"][0][\"name\"]}}"
            },
            {
              "name": "Dancability",
              "value": "={{$json[\"danceability\"]}}"
            },
            {
              "name": "Energy",
              "value": "={{$json[\"energy\"]}}"
            },
            {
              "name": "Tempo",
              "value": "={{$json[\"tempo\"]}}"
            },
            {
              "name": "Acoustic",
              "value": "={{$json[\"acousticness\"]}}"
            },
            {
              "name": "Instrumental",
              "value": "={{$json[\"instrumentalness\"]}}"
            },
            {
              "name": "Liveness",
              "value": "={{$json[\"liveness\"]}}"
            },
            {
              "name": "Loudness",
              "value": "={{$json[\"loudness\"]}}"
            },
            {
              "name": "Valance",
              "value": "={{$json[\"valence\"]}}"
            },
            {
              "name": "Track ID",
              "value": "={{$json[\"id\"]}}"
            },
            {
              "name": "Genre",
              "value": "={{$node[\"Merge1\"].json[\"artists\"][\"items\"][0][\"genres\"]}}"
            }
          ],
          "number": []
        },
        "options": {}
      },
      "name": "Set2",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        1860,
        590
      ],
      "retryOnFail": true,
      "maxTries": 5
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"name\"]}}",
              "operation": "contains",
              "value2": "Dance"
            }
          ]
        }
      },
      "name": "Find Dance Playlist",
      "type": "n8n-nodes-base.if",
      "position": [
        1450,
        -180
      ],
      "typeVersion": 1,
      "retryOnFail": true,
      "maxTries": 5
    },
    {
      "parameters": {
        "resource": "playlist",
        "id": "={{$node[\"Playlist\"].json[\"Playlist\"]}}",
        "trackID": "={{$node[\"Track\"].json[\"Track\"]}}"
      },
      "name": "Spotify1",
      "type": "n8n-nodes-base.spotify",
      "typeVersion": 1,
      "position": [
        2290,
        -70
      ],
      "credentials": {
        "spotifyOAuth2Api": "Colin"
      }
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{$node[\"Spotify\"].json[\"danceability\"]}}",
              "operation": "largerEqual",
              "value2": 0.75
            }
          ],
          "string": []
        }
      },
      "name": "Dancibility",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1220,
        20
      ]
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{$json[\"tempo\"]}}",
              "operation": "largerEqual",
              "value2": 100
            }
          ]
        }
      },
      "name": "Tempo",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1450,
        30
      ]
    },
    {
      "parameters": {
        "mode": "wait"
      },
      "name": "Merge2",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 1,
      "position": [
        1960,
        -80
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "=Track",
              "value": "={{$json[\"uri\"]}}"
            }
          ]
        },
        "options": {}
      },
      "name": "Track",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        1730,
        30
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "=Playlist",
              "value": "={{$json[\"uri\"]}}"
            }
          ]
        },
        "options": {}
      },
      "name": "Playlist",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        1730,
        -180
      ]
    }
  ],
  "connections": {
    "Cron": {
      "main": [
        [
          {
            "node": "Get Playlists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Get Tracks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Tracks": {
      "main": [
        [
          {
            "node": "Save to Archive",
            "type": "main",
            "index": 0
          },
          {
            "node": "Spotify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Playlists": {
      "main": [
        [
          {
            "node": "Find Archive Playlist",
            "type": "main",
            "index": 0
          },
          {
            "node": "Find Weekly Playlist",
            "type": "main",
            "index": 0
          },
          {
            "node": "Find Dance Playlist",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find Weekly Playlist": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Find Archive Playlist": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Spotify": {
      "main": [
        [
          {
            "node": "Dancibility",
            "type": "main",
            "index": 0
          },
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "Get Artist Details",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Artist Details": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Set2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set2": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find Dance Playlist": {
      "main": [
        [
          {
            "node": "Playlist",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Dancibility": {
      "main": [
        [
          {
            "node": "Tempo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tempo": {
      "main": [
        [
          {
            "node": "Track",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Playlist": {
      "main": [
        [
          {
            "node": "Merge2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Track": {
      "main": [
        [
          {
            "node": "Merge2",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge2": {
      "main": [
        [
          {
            "node": "Spotify1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {},
  "id": "5"
}

Do not understand where the problem is. If you say “There should be 12 matching songs from this weeks Discover Weekly playlist” are there then actually 12 songs, so 12 items in n8n?

Or let’s ask differently:
Is the problem that it does not return 12 songs or is the problem that there are 12 songs in n8n but only 1 gets added?

The IF statement correctly finds 12 songs but only one gets added to the playlist.

How many items does the Track-Node contain? Because if it only contains one that would cause an issue like this.

In this case the node would execute 12 times, once for every item. For each of them it would look for the correct item on both in the expression referenced nodes. For Playlist it would find data for all 12. For Track it would then only find data for the first one.

For it to work you have to tell n8n to always use the data of the first item (the item with index 0) which you can do by changing the expression for “Track ID” on the Node “Spotify1” to this value:

{{ $item(0).$node["Track"].json["Track"] }}

Had to change the Merge2 Node to Multiplex it to get it to work. Issue seemed to be that Playlist was only passing 1 result and Track was passing 12.

Yes, exactly that is another possibility. But to be complete also then the expression would still need to get changed. In this case to:

{{ $json["Track"] }}

Yeah, that is the expression being used.