Managing the current music in the office playlist can often turn into quite the coworker conundrum. Why put up with someone nagging you to add the latest Drake song to the playlist, or to skip the thousandth time you’ve heard “Wow” by Beck? That’s where Message.io‘s latest favorite bot, James Brown, comes to play.
James Brown is a chat bot that interfaces Spotify with a Slack conversation. He can add songs to a playlist via a search, display track information about a song that is currently playing or even skip to the next track – all via simple commands in Slack.
Today I’ll walk you through getting James Brown set up in your own office environment, just like at the Message.io HQ. There are a couple of things you’ll need to get set up or think about before diving in, so let’s first take a look at a high level overview of how the James Brown slackbot works.
The actions that James Brown takes can be deduced into two types of actions: Spotify API requests, and Spotify Apple Scripts (which run locally). Spotify’s API gives us access to their music database, which enables James Brown to do searches for artists or song names. The search will give James Brown Spotify’s identifier for that song, and then allow James to add songs to a playlist. Playlists are another component of Spotify’s API that enable James Brown to add songs to a specified playlist via an API request.
The second of the type of actions, which is written in Apple Script, is run locally on your computer. These actions include things like going to the next song, getting information about the song currently playing, and potentially even modifying the volume of the music. These types of actions unfortunately cannot be controlled through an API request via Spotify, so you are dependent on having a local machine running these bots.
So what’s the ideal setup for James Brown?
With the current James Brown implementation, we are tied to using Apple Scripts on a mac OS / OS X computer. For the best possible setup, you’d really want a Mac Mini that runs as your James Brown Server. This would allow the James Brown bot to run locally on the Mac Mini, as well as run Spotify and connect to some sort of speaker system.
Here at the office, I simply run James Brown on my personal computer and connect to a wireless bluetooth speaker. This however creates a dependency on my computer (and presence!) for two things – the James Brown bot running, and the Spotify app running. If you’re really looking for the true “Juke Box” experience, I would really recommend getting a dedicated setup.
Once you’ve got your hardware situation defined, there are only a couple of things that you need to set up from a software perspective. You’ll need a Spotify account, and I would recommend creating a company wide one. Then you’ll need to go through Spotify’s developer account to create a Spotify App, which gives us access to Spotify’s API. Setting up a Slack app is another requirement, which gives James Brown his own user, and token to connect to Slack’s API with.
Lastly, you’re going to be using an application called ngrok which enables your local machine to receive responses from Slack’s API (to do things like skip to the next song, or check what’s currently playing. Ngrok is a great piece of software that opens your machine to those incoming connections with ease, and it will require an account to setup.
If you’re now ready to dive into implementing your own James Brown bot, the next blog will be coming soon to explore the technical nitty-gritty and get your office dancing pronto!2