Wejay is a music collaboration bot for Slack that can be used to add music to a local Sonos system. It needs to be started on the same network as your Sonos system in order to communicate with the speakers.
Start by creating a .env
file in the root directory of the project. This is for the Spotify search feature and to allow the bot to interact with Slack. It should contain
SPOTIFY_ID=spotify-token-here
SPOTIFY_SECRET=spotify-secret-here
SLACK_TOKEN=slack-token-here
WEJAY_IP=ip-of-the-speaker
Spotify token/secret can be generated by creating an app at https://developer.spotify.com/. Slack token can be found after adding the bot to your Slack below. The value for WEJAY_IP
can be found in "About My Sonos System" of the Sonos Controller app, choose the IP of the speaker you'd like to send music to.
$ git clone https://github.com/Iteam1337/sonos-wejay.git
$ cd sonos-wejay
$ npm install
$ npm build && npm run dev
This will compile the Reason code and start up the Express app.
- The easiest way to start testing is using ngrok. After you've installed
ngrok
, open another terminal and runngrok http 3000
. This will create a tunnel to you local environment. - Go to https://api.slack.com/apps and create a new app
- Inside OAuth & Permissions you'll find "Bot User OAuth Access Token" which is the token that should be added in your
.env
above. - Go to Interactive Components and enable it. In the request url enter one of the urls provided by
ngrok
(http or https) and the route/action
, i.e. https://127.0.0.1/action - Also on Interactive Components add a action. Give it the name "Queue track" and description and callback id "queue"
- Go to Event Subscriptions and enable it. In the request url use the same url as above but use the route
/event
- Also on Event Subscriptions add a "Bot User Event". The best one is
message.im
, which means you can send commands to the bot in private messages - You should be able to send some commands to the bot in Slack now, try sending
help
to see all available commands
Command | Shorthand | Description |
---|---|---|
blame |
Who added the track? (requires MySQL database) | |
clear |
Reset playlist | |
currentqueue |
getqueue , gq , cq |
Display upcoming tracks |
fullqueue |
fq |
Display all tracks currently in the queue |
help |
Display the help text | |
mute |
Mute | |
mostplayed |
List the most played tracks (requires MySQL database) | |
next |
skip |
Skip one track forward |
nowplaying |
np |
Display what's playing right now |
remove <numberOfTracks> <index> |
rm |
Remove tracks |
pause |
Pause | |
play |
Play | |
playtrack <trackNumber> |
Play track number | |
playlatest |
pl |
Play latest track |
previous |
Go back one track | |
queue <Spotify URI> |
q <Spotify URI> |
Queue a track using a Spotify URI |
search <your search string> |
s <your search string> |
Search Spotify for a track |
toplist |
List top Wejayers (requires MySQL database) | |
unmute |
Unmute | |
volume <0-100> |
Set volume, if no number is provided displays current volume |
You can also select a couple of tracks in Spotify, press cmd+c
(Mac) / ctrl+c
(Windows), paste the copied information to the Wejay bot and send the message. Wejay will add all of your tracks at the end of the queue! 🎉
Some of the commands, like blame
and toplist
requires that you have a MySQL database that the service can access. We've included a docker-compose.yml
that you can use to spin up a database.
Thanks goes to these wonderful people (emoji key):
Rickard Laurin 💻 📖 🤔 👀 |
Tom Ekander 💻 🤔 |
Jimmy Jardland 💻 🤔 |
Nils Nilsson 💻 🤔 |
faroutchris 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!