-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify README and change env var for authorize message
- Loading branch information
1 parent
0ec5769
commit 732ab35
Showing
2 changed files
with
43 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,71 @@ | ||
# slackbox | ||
Spotify playlist collaboration through Slack. Brought to you by the lovely people at [Benchmark](http://benchmark.co.uk). | ||
# Slack Jukebox | ||
Add music to a Spotify playlist through a Slack command. | ||
|
||
[](https://heroku.com/deploy) | ||
Simply create a Slash Command, such as `/juke`, which accepts a track name (also the artist too for a less fuzzy search) to add to a pre-defined Spotify playlist: | ||
|
||
Simply create a Slash Command, such as `/jukebox`, which accepts a track name (also the artist too for a less fuzzy search) to add to a pre-defined Spotify playlist: | ||
|
||
/jukebox Bell Biv DeVoe – Poison | ||
/juke Ramble On – Led Zeppelin | ||
/juke Ramble On | ||
|
||
## Installation | ||
|
||
### Slack | ||
### Slack Slash command | ||
|
||
There are two ways to use slackbox - via a Slash Commands or an Outgoing Webhook: | ||
First you'll want to create your Slack Slash Command, which you can do by going to your [Slash Commands page](https://my.slack.com/services/new/bots). | ||
|
||
#### Slash Command | ||
{{Image for Slack}} | ||
|
||
Slash commands allow for private functions within Slack which will **not** show up in chat history. | ||
During setup, have your slash command or outgoing webhook submit a POST to your app's `/store` endpoint, e.g. `https://app-name.herokuapp.com/store`. | ||
|
||
First you'll want to create your Slack Slash Command, which you can do by going to your [Slash Commands page](https://my.slack.com/services/new/slash-commands). | ||
Make a note of the `token`, as you'll need it later to help guard against cross-site request forgery. | ||
|
||
#### Outgoing WebHook | ||
### Slack bot to post messages | ||
|
||
Outgoing webhooks allow data to be exported from Slack channels. Using an outgoing webhook means song additions will be public so users will know when songs are requested and who requested them. | ||
You can post to a channel the songs you are adding to the playlist or decide not to, it all depends on the enviroment variables you add. | ||
If you want to post the song that was recently added, go to [Your Slack's app directory](https://my.slack.com/apps/manage/custom-integrations) and just create a simple bot and give it a name. Make note of the `token` of the bot, you will need it later. | ||
|
||
First you'll want to create your Outgoing Webhook, which you can do by going to your [Outgoing WebHooks page](https://my.slack.com/services/new/outgoing-webhook). | ||
### Spotify | ||
|
||
Outgoing WebHooks work best with a trigger word. This way only messages with the trigger word (or words) will be parsed and added. | ||
Head over to [Spotify's Developer Site](http://developer.spotify.com) and create a new Application. Make sure you add whatever slackbox's callback URI as a valid callback URI. If you're running locally, this will be `http://localhost:5000/callback` or on Heroku `https://app-name.herokuapp.com/callback` | ||
|
||
**NOTE:** You may only use slash commands _or_ outgoing webhooks. The Slack Token environment variable can only be set once so it needs to be the token from this or the slash command. | ||
{{Image for Spotify}} | ||
|
||
#### Common | ||
Make a note of the `key`, `secret` and `callback URI` too, as you'll need these later as well. | ||
|
||
During setup, have your slash command or outgoing webhook submit a POST to your app's `/store` endpoint, e.g. `https://app-name.herokuapp.com/store`. | ||
Create a public playlist on Spotify. You can make it public by clicking on the `...` (options) and click on `Make public`. Then, to copy the playlist URI, click again on `...`, `share`, `Copy Spotify URI`. You will only need the last segment of the URI like: spotify:user:dracocraco10:playlist:`6Y0NY8dbLCrRcfIRyn3AdM`. | ||
|
||
Make a note of the `token` (either from the slash command or outgoing webhook), as you'll need it later to help guard against cross-site request forgery. | ||
### Keeping your app alive forever | ||
|
||
### Spotify | ||
If you create an app on Heroku for free, the app will go to sleep after 30 minutes. To get around this, you can use [Firebase](https://console.firebase.google.com/) to host your authorization tokens and a [Cron Job](https://cron-job.org/en/) that runs every 30 minutes to hit your `/refresh` endpoint and refreshes your access tokens. This way you make sure your app will run forever. | ||
|
||
Head over to [Spotify's Developer Site](http://developer.spotify.com) and create a new Application. Make sure you add whatever slackbox's callback URI as a valid callback URI. If you're running locally, this will be `http://localhost:5000/callback` or on Heroku `https://app-name.herokuapp.com/callback` | ||
#### Firebase | ||
|
||
Make a note of the `key`, `secret` and `callback URI` too, as you'll need these later as well. | ||
To create a Firebase database, create an account for free, add project with same name as on Heroku, create a database, and then generate a private key to get your `Firebase service account key` JSON file. You will need this file in the root of your project as it contains the private key to your DB. | ||
|
||
{{Image for Firebase}} | ||
|
||
#### Cron job | ||
|
||
Set up your cron job that will hit your app's `/refresh` endpoint every 30 minutes to keep your project awake. | ||
|
||
Also, don't forget to make a playlist. If you do this through [Spotify's web interface](http://play.spotify.com) then the `playlist identifier` will be the last segment of the URI - make a note of this too! If there's a better way of finding this out, we're all ears. If you do this through the app, right-click the playlist to get it's web URL and again, you need the last segment of the URI. | ||
|
||
### Environment variables | ||
### Heroku | ||
|
||
Once you've cloned slackbox or hit the "Deploy with Heroku" button you'll need to setup the following environment variables. These can either be stored in a `.env` or set up as config variables in Heroku. | ||
You can use any service to host your app, I personally used [Heroku](https://www.heroku.com/). If you decide to use Heroku, create an app for free, deploy your local copy of the Slack jukebox and set up the *environment variables*. You can either do this with an `.env` file or in the `Config Variables` section in Settings: | ||
|
||
* `APP_AUTHORIZE_ENDPOINT` - URL TO `/authorize` endpoint (e.g.: https://project.herokuapp.com/authorize) | ||
* `FIREBASE_DATABASE_NAME` - Your Firebase DB's name (e.g.: project-1j243). | ||
* `FIREBASE_SERVICE_ACCOUNT_KEY` - Path to your Firebase Service Account JSON file. | ||
* `SLACK_CHANNEL` - Name of the Slack channel where the songs added to the playlist will post. | ||
* `SLACK_EMOJI_ICON` - Emoji for the message posting on the channel. | ||
* `SLACK_TOKEN` - The token from Slack's Slash Command. | ||
* `SLACK_OUTGOING` - True if using [Slack Outgoing WebHooks](https://my.slack.com/services/new/outgoing-webhook), false if using [Slack Slash Commands](https://my.slack.com/services/new/slash-commands) | ||
* `SLACK_TOKEN_BOT` - The token from Slack's bot. | ||
* `SLACK_USERNAME` - The username of the bot that posts to the channel. | ||
* `SPOTIFY_KEY` - Your Spotify application key (a.k.a Client ID). | ||
* `SPOTIFY_SECRET` - Your Spotify application secret (a.k.a Client Secret). | ||
* `SPOTIFY_USERNAME` - Your Spotify username. | ||
* `SPOTIFY_PLAYLIST_ID` - Your playlist identifier. | ||
* `SPOTIFY_REDIRECT_URI` - URI to redirect to once your user has allowed the application's permissions. | ||
* `SPOTIFY_SECRET` - Your Spotify application secret (a.k.a Client Secret). | ||
* `SPOTIFY_USERNAME` - Your Spotify username. | ||
|
||
### Authentication | ||
|
||
Visit your slackbox's home page to authenticate yourself with Spotify and you should be all set! | ||
Visit your `APP_AUTHORIZE_ENDPOINT` to authenticate yourself with Spotify and you should be all set! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters