• Home

  • Automation with Zapier

  • Automation inspiration

Automation inspiration

7 min read

Make your perfect Spotify playlist with this automated workflow

Let Zapier make you a mixtape

By Tyler Robertson · August 3, 2020
A hero image for Spotify app tips with the Spotify logo on a green background

While the impact music can have on productivity is still up for debate, there's no question that having the right playlist can make your workday infinitely more tolerable.

But what is the right playlist? And why can't I seem to find it?

These days, my music habits include a heavy rotation of "lo-fi beats to study/work to" YouTube playlists, "Mood" recommendations from Spotify, and long periods of silence while clicking between six or seven different playlists to find just the right vibe for these emails I've been avoiding. Every now and then, I manually curate a work or productivity" playlist from the songs I've liked on Spotify, but nothing really sticks.

Let's fix that today, with science.

A man tilting his head to the side and with the text every song I download has to pass a series of rigorous tests to answer one simple question: is it a banger?
Very precise science

Fans of High Fidelity know that crafting the perfect playlist is an art form, but with a bit of well-placed automation and a sprinkle of math, I'll wager we can get pretty close. The team at Spotify seems to agree, and has opened up their API to include measurable audio features for each track in their database. In addition to the metrics we expect like key and beats per minute, these features include once-nebulous qualities of music, like "acousticness," "liveness," or "speechiness." We're going to use all of that to create a Zap that will build the perfect work playlists.

If you don't like math or science, that's ok too! Feel free to skip ahead, to where I link to a pre-made Zap that will let you jump straight into building the perfect playlist.

Something to note: This is a multi-step Zap, meaning you'll either need to be in your trial period or have a paid account to set it up. Depending on how often it runs, it could be pretty task heavy.

How Spotify measures music

In order to get this playlist sounding just how you want it, you'll need to tweak the values Spotify assigns to eight qualities of every track. Most of these are on values from 0.0 (does not have this quality) to 1.0 (absolutely has this quality). If you want to dive deeper into the science behind these scores, Spotify has a lot of interesting information on their developer page.

Here are the qualities:

  • Acousticness: This represents how certain Spotify is that the track was performed acoustically (without electronic instruments). Folk-rock group The Lumineers' song "Ho Hey" scores 0.765, while DEVO's "Whip It" scores significantly lower at 0.00213.

  • Danceability: Spotify's documentation described "danceability" as "how suitable a track is for dancing based on a combination of musical elements including tempo, rhythm stability, beat strength, and overall regularity." Daft Punk's "Hard, Better, Faster, Stronger" scores a respectable 0.817, while David Bowie's "Space Oddity" comes in at 0.299.

  • Energy: Using a few different qualities like tempo, loudness, and overall activity within the song, Spotify puts together an "energy" score that tells you how likely the track is to wake you up in the morning. Brahms' "Lullaby" clocks an energy score of 0.36, while Technotronic's '90s dance classic "Pump Up the Jam" hits 0.887.

  • Instrumentalness: Spotify also predicts how likely the song is to have no vocals, not counting mouth sounds like "ooh" and "aah." Eminem's "Lose Yourself" barely ekes out a score at 0.00072, while Flatt & Scruggs' "Foggy Mountain Breakdown" tops the charts at 0.901.

  • Liveness: By listening for crowd noise, Spotify tells us whether the song was recorded in front of a live studio audience, Full House style. Sting and Phil Collins playing "Every Breath You Take" at Live Aid 1985 scores 0.992, while Todrick Hall's quarantine-themed "Mask, Gloves, Soap, Scrubs" appropriately rings in at 0.0694.

  • Loudness: While you can manually adjust your volume at any time, Loudness tells us about relative loudness over the whole length of the song (basically, will you need to turn up the volume to hear this song?). Loudness is measured from -60 to 0 decibels, with most songs averaging around -5dB. Disturbed's "Down with the Sickness" is surprisingly well-mixed at -4.262dB, while Sigur Rós's "Sleep 9" averages a chill -32.0dB.

  • Speechiness: The opposite of Instrumentalness, this measures the presence of spoken words on the track. Podcasts are likely to score highly, with most songs averaging below 0.3. Hit musical Hamilton's "Alexander Hamilton" scores one of the higher Speechiness scores I've seen at 0.285, while Paul Simon's "You Can Call Me Al" receives a somewhat surprising 0.0535, probably thanks to the penny whistle solo.

  • Valence: Sure the music is good, but is it happy? Valence uses measures like key and tempo to determine whether the song has a positive or negative emotion. Pharrell Williams's "Happy" from Despicable Me 2 lives up to its name with a valence score of 0.962, while Sarah MacLachlan's contribution to Toy Story 2 "When She Loved Me" scores an appropriate 0.235 (I'm not crying, you're crying).

Using these eight elements of music, we can build a new playlist filled with 100 percent quantifiable bangers.

Creating the Zap

This Zap is fairly advanced, but we'll walk you through the steps. If you want to get started right away, click the button below.

Create the perfect Spotify playlist

Create the perfect Spotify playlist
  • Spotify logo
  • Filter by Zapier logo
  • Spotify logo
Spotify + Filter by Zapier

Need help with more complex automation? Zapier Experts are certified consultants, freelancers, and agencies that can help you do more with automation. Visit our Experts directory to help you find the right Expert to work with.

Prework: Set up Spotify to work with Zapier

You'll need to be sure the playlist you want to use as your trigger and the one that will receive the songs show up in the Playlists section on the left side of your Spotify. Use the Save to Your Library option to make a playlist appear there.

How to save a track to your library

Doing this in advance will make sure you can select these playlists as you create your Zap.

Tell Zapier where to look for new potential songs

To start, choose New Track Added to Playlist as your trigger event.

Select the New Track Added to Playlist event to start your Zap.

This Zap will start every time a new song is added to a specific playlist that you follow. This can be a playlist you curate, a collaborative playlist you make with friends, or one Spotify generates for you, like "Discover Weekly."

Next, we need to select the playlist. To do that, click on Customize Track and then use the Playlist dropdown to select the playlist you want to keep an eye on. In this screenshot, we've selected the "Discover Weekly" playlist.

Selecting the Discover Weekly playlist to customize your track info.

Each time a song is added to this playlist, the Zap will run and give us some basic information like title, artist, whether it's explicit, and so on.

To get the really detailed song info, we need to add an action called Get Audio Features for a Track. Go through the same steps as above to choose your account. Then, to get the features for the song that triggered the Zap, when you get to the Customize Audio Feature step, click in the box under "Track" and then click Custom. In the search box, put "Track ID" and select that option from the dropdown list.

Select Track ID in the Custom section of this action.

Using the Track ID value gives us access to all of the data for this song.

Then we'll need to test the action, so that we can see the data Spotify has for that track:

Sample data when you test the step to get audio features for a track

Tell Zapier which songs it should add to your perfect list

To make sure only the perfect songs get into your playlist, let's add a Filter to the Zap and start setting up conditions.

After much honing and testing, here's what my final Filter looks like:

A list of audio features with ranges

Based on my personal preferences, I set the Filter to favor high-energy, danceable, happy songs and removed features that don't matter, like "liveness."

These numbers can be tweaked to match your specific preferences for at-work listening. For numerical fields, you'll want to choose (Number) Greater than if you'd like to see your playlist feature more of that quality or (Number) Less than if you'd like to avoid songs with that quality. The Track Explicit field is a bit different, and explained below.

A refresher on what these elements mean:

  • Acousticness: The closer to 1.0, the more acoustic. Closer to 0.0, it's more electronic.

  • Danceability: Uses tempo, rhythmic stability, beat strength, and regularity to determine whether your feet will be moving at your standing desk. 1.0 is toe-tapping, 0.0 is cat-napping.

  • Energy: Keep the party jumping by setting this closer to 1.0, and go closer to 0.0 to get chill, low-key vibes. Instrumentalness: If you prefer instrumental music while you write, set this value to around 0.7.

  • Liveness: Thrive on crowd noise? Setting this value to 0.6 or greater will bring the festival to you.

  • Speechiness: Prefer the spoken word? Most music is below 0.3, with things like podcasts and speeches ranking much higher.

  • Tempo: This directly relates to the song's beats per minute (BPM) in the song, with higher numbers typically meaning a more energetic tune.

  • Valence: At the end of the day we all want to be happy, right? Setting this number closer to 1.0 will get the happiest songs from Spotify into your playlist.

  • Track Explicit: Whether it includes swear words. Set to (Boolean) is false to keep it safe for work and kid-friendly.

Adding songs to your designated playlist

Finally, let's round this Zap out with an "Add Track to Playlist" action, to bring our fully vetted song into the perfect playlist.

Choose your Spotify account, and in the Customize Track section, select the playlist where you want the songs to appear, and in the Track field, once again select Custom, search for "Track ID" and select that. When you're finished, it will look like this.

The Customize Track section of the final action step in your Zap.

The Results

Using the "Discover Weekly" as our trigger playlist means that the end result will be targeted specifically to you, helping achieve the magic that makes for a really great playlist. "Discover Weekly" is refreshed by Spotify each week, so this process can (and arguably should) take some time. You may see only a few songs added each week, but it will eventually grow into a playlist that can last the whole workday.

To add tracks quickly, you can use Spotify's "New Saved Track" trigger instead, so each time you like a really, really good song, it gets saved into your playlist as well. You could even have the trigger monitor a collaborative playlist, and let this Zap filter out your friends' bad tastes in music (Really, Tom? Coldplay again?).

To give you an idea of what this Zap can do, I'm going to let you all into my circle of trust. I've been running a version of this Zap since May, allowing my "Discover Weekly" playlist to add a few new songs to it each week, and occasionally adding in a few songs that I've liked elsewhere. The "Discover Weekly" algorithm gets pretty specific to each user, so there's no accounting for taste, but, as of this moment, here's my perfect work playlist.

Try it out!

Want to give this a shot with your own Spotify library? Get started with this Zap:

Create the perfect Spotify playlist

Create the perfect Spotify playlist
  • Spotify logo
  • Filter by Zapier logo
  • Spotify logo
Spotify + Filter by Zapier

Get productivity tips delivered straight to your inbox

We’ll email you 1-3 times per week—and never share your information.

tags

Related articles

Improve your productivity automatically. Use Zapier to get your apps working together.

Sign up
See how Zapier works
A Zap with the trigger 'When I get a new lead from Facebook,' and the action 'Notify my team in Slack'