Sharing music over playlists is a great way to discover new and old music. Spotify has collaborative playlists, but I don't like how they let your friends re-order and delete songs from the list. We can fix this by building our own collaborative playlist that only allows additions using the Spotify Web API. With the Twilio API for WhatsApp we can let our friends send in a song whenever they are struck by inspiration.

In this post we are going to build a WhatsApp bot that can do all of the above using Ruby on Rails.

Getting started

To build this application we will need a few things:

Spotify API Credentials

To work with the Spotify API we will need to generate some API credentials. From the Spotify developer dashboard create a new application and follow the 3 step process.

First, fill in some details about the app. Name it, I called mine WhatsPlaying, provide a short description and check what app type it is, I chose "website" Next we are asked if this is a commercial integration; choose "no" Finally, check the agreements

Once these steps are complete we will see the application dashboard. We will need the Client ID and Client Secret from this page.

There's one more thing we need to do here. Click on "edit settings", enter the redirect URL http://localhost:3000/auth/spotify/callback and click "add".

Now that credentials are sorted, we can start to build our app.

Preparing the project