Dispatch by Mio
Published in

Dispatch by Mio

Tutorial: Getting Groovy With James Brown [Part 1]

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.

[caption id=”attachment_271" align=”alignnone” width=”1000"]

This is an example of a Spotify API Request. Within a Direct Message, James brown is able to search Spotify’s library for songs or artists. James Brown uses Slack’s ephemeral messaging to make a seamless and clean UI.[/caption]

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.

[caption id=”attachment_272" align=”alignnone” width=”1002"]

Here we are using Spotify Apple Scripts, which run on the host machine. The apple script triggers Spotify to hit next song.[/caption]

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!



Microsoft Teams + Slack + Webex Teams News

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store

Chat better, together. Mio powers cross-platform messaging across Microsoft Teams, Slack, Webex, and Zoom. Learn more at https://m.io