The ability for us to skip songs easily, as well as trigger songs at certain times of the day and with keywords was something that we wanted. After a short amount of research I discovered that Spotify has an AppleScript API available. Using the AppleScript API in combination with Slack (we use Slack daily for team communication) we were able to achieve this. 

Using Botkit and Spotify node AppleScript as the framework we were able to create a Slack bot that listened for keywords either via a direct message to “jukebox” or by @mentioning jukebox in a channel that it was listening in; mainly in certain channels.

Some of the commands we have available currently include:

“help”
Returns a list of available commands.

“hi”, “hello”
Responds with “Hello Name.” or “Hello.” and adds a radio icon as a reaction. This is good to check if the Slack Bot is in a particular channel.

“what is this”, “what’s this”, “info”, “playing”, “what is playing” and “what’s playing”
Replies with information about the current playing song.

“detail"
Replies with information about the currently playing song, but also includes the album cover and name along with information about how many times it has been played.

“next”, “skip” and “BLERG”
Skips triggered by TeresaSkips to the next track, and also posts in the channel setup in bot_setup who skipped the track. 

“play”, “resume”, “go”
Resumes a pause song

“stop”, “pause” and “shut up”
Pauses the currently playing song.

“louder”, “volume up”, “pump it”
Turns the volume up.

“quieter” “volume down”, “shhh*”
Turns the volume down.

“design”
Plays our design sign-off celebration song.

“lunch”
Plays the Latin Dinner playlist, more commonly referred to as the Nandos playlist.

“launch”
Launch Triggered by RobNot to be confused with lunch, plays our launch celebration song when something gets ‘pushed live' live and also posts in the channel setup in bot_setup. 

Using Moment.js I’ve also setup the Bot to play a stretch song twice a day, first at 10:30am and second at 3 pm for the team at Bam Creative to take a quick five minutes stand and stretch break.

Summary

The Slack Bot started as a side project and is still very much in its infancy stages. Whilst the AppleScript API is limited we have plans to add more features such as going back to the previous playlist after a time triggered song has finished, skip tokens to limit the amount someone can skip per day, more flexible time and day triggered songs, usage analytics and many more.

You can find our Spotify Slackbot on GitHub to install, follow progress and contribute

We would love to hear from people who have adopted this Slack Bot for their offices!