Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add brief migration guide #260

Merged
merged 4 commits into from
May 19, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### 0.15.1 (Next)

* Your contribution here.
* [#260](https://github.com/slack-ruby/slack-ruby-bot/pull/260): Add brief migration guide - [@wasabigeek](https://github.com/wasabigeek).

### 0.15.0 (2020/5/8)

Expand Down
4 changes: 3 additions & 1 deletion DEPLOYMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Once created, go to the app's Basic Info tab and grab the Client ID and Client S

Alternatively, you can still [generate a legacy API token](https://api.slack.com/custom-integrations/legacy-tokens) for your app and use it for some interactions.

If you have a legacy API token, and would like to migrate to the new Slack apps, a brief [migration guide](MIGRATION.md) is provided.

#### SLACK_API_TOKEN

Set the SLACK_API_TOKEN environment variable using the token received above.
Expand Down Expand Up @@ -81,7 +83,7 @@ passenger_pre_start http://example.com:80/;
<Directory /var/www/bot/public>
Allow from all
Options -MultiViews
Require all granted
Require all granted
</Directory>
</VirtualHost>

Expand Down
11 changes: 11 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Migrating from Legacy API Tokens

New Slack Apps require authentication via OAuth, returning an access token that should be a drop-in replacement for `SLACK_API_TOKEN`. As of the time of writing, the tokens never expire, so you could potentially write your own OAuth flow to retrieve the access token separately. Alternatively, you could migrate to [slack-ruby-bot-server](https://github.com/slack-ruby/slack-ruby-bot-server).

## Migrating to slack-ruby-bot-server
Overview:
wasabigeek marked this conversation as resolved.
Show resolved Hide resolved
- Create a new Slack App as [advised by Slack](https://api.slack.com/legacy/custom-integrations/legacy-tokens#migrating-from-legacy).
wasabigeek marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is confusing. I think we should tell users to go through the tutorial/setup of slack-ruby-bot-server as in that doc, then copy command classes, then do the workflow that you suggest. And explain what happens when you do that and the fact that other teams can install the bot too then, which may not be what you want (and needs to be prevented).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am actually a little confused by Slack itself. If I understood correctly, slack-ruby-bot-server requires the latest Slack Apps, but there are also legacy tokens AND class Slack Apps, both with subtly different migration strategies on the Slack end. Did I get that right, and should I gloss over this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I say gloss over this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! Any more comments?

- Figure out how you want to persist your token. The gem supports ActiveRecord and Mongoid out-of-the-box and will create a `Team` model.
- Using a [sample app](https://github.com/slack-ruby/slack-ruby-bot-server/tree/master/sample_apps) as a base, move your `SlackRubyBot::Commands::Base` or `SlackRubyBot::Bot` concrete classes into the [`commands` folder](https://github.com/slack-ruby/slack-ruby-bot-server/tree/master/sample_apps/sample_app_activerecord/commands) and require it in `commands.rb`.
- Create a [Slack Button](https://api.slack.com/docs/slack-button), setting the redirect URL to `.../api/teams`. This is the OAuth grant redirect URL that will be run in the sample `config.ru` file. The endpoint will create a `Team` and store the access token in it.
- Run your app and authenticate with the Slack button.