You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-66Lines changed: 23 additions & 66 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,10 +7,6 @@ Slack Ruby Bot Server
7
7
8
8
Build a complete Slack bot service with Slack button integration, in Ruby.
9
9
10
-
If you are not familiar with Slack bots or Slack API concepts, you might want to watch [this video](http://code.dblock.org/2016/03/11/your-first-slack-bot-service-video.html).
11
-
12
-
A good [open-source demo](https://github.com/dblock/slack-strava) of a service built on top of this library is [Strava integration with Slack](https://slava.playplay.io).
13
-
14
10
# Table of Contents
15
11
16
12
-[What is this?](#what-is-this)
@@ -36,25 +32,19 @@ A good [open-source demo](https://github.com/dblock/slack-strava) of a service b
36
32
37
33
### What is this?
38
34
39
-
A library that contains a [Grape](http://github.com/ruby-grape/grape) API serving a [Slack Ruby Bot](https://github.com/slack-ruby/slack-ruby-bot) to multiple teams. This gem combines a web server, a RESTful API and multiple instances of [slack-ruby-bot](https://github.com/slack-ruby/slack-ruby-bot). It integrates with the [Slack Platform API](https://medium.com/slack-developer-blog/launch-platform-114754258b91#.od3y71dyo). Your customers can use a Slack button to install the bot.
35
+
A library that contains a web server and a RESTful [Grape](http://github.com/ruby-grape/grape) API serving a Slack bot to multiple teams. Use in conjunction with [slack-ruby-bot-server-events](https://github.com/slack-ruby/slack-ruby-bot-server-events) to build a complete Slack bot service, or [slack-ruby-bot-server-rtm](https://github.com/slack-ruby/slack-ruby-bot-server-rtm) to build a Class RealTime Slack bot. Your customers can use a Slack button to install the bot.
40
36
41
37
### Stable Release
42
38
43
39
You're reading the documentation for the **next** release of slack-ruby-bot-server. Please see the documentation for the [last stable release, v0.12.3](https://github.com/slack-ruby/slack-ruby-bot-server/blob/v0.12.3/README.md) unless you're integrating with HEAD. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
44
40
45
-
### Try Me
46
-
47
-
A demo version of the [sample app with mongoid](sample_apps/sample_app_mongoid) is running on Heroku at [slack-ruby-bot-server.herokuapp.com](https://slack-ruby-bot-server.herokuapp.com). Use the _Add to Slack_ button. The bot will join your team as _@slackbotserver_.
48
-
49
-

41
+
### Make Your Own
50
42
51
-
Once a bot is registered, you can invite to a channel with `/invite @slackbotserver` interact with it. DM "hi" to it, or say "@slackbotserver hi".
43
+
We recommend you get started from a [slack-ruby-bot-events-sample](https://github.com/slack-ruby/slack-ruby-bot-server-events-sample) app to bootstrap your project.
52
44
53
-

45
+
### Storage
54
46
55
-
### Run Your Own
56
-
57
-
You can use one of the [sample applications](sample_apps) to bootstrap your project and start adding slack command handlers on top of this code. A database is required to store teams.
47
+
A database is required to store teams.
58
48
59
49
### MongoDB
60
50
@@ -67,8 +57,6 @@ gem 'mongoid-scroll'
67
57
gem 'slack-ruby-bot-server'
68
58
```
69
59
70
-
See the [sample app using Mongoid](sample_apps/sample_app_mongoid) for more information.
71
-
72
60
### ActiveRecord
73
61
74
62
Use ActiveRecord with, for example, PostgreSQL via [pg](https://github.com/ged/ruby-pg). Configure the database connection in `postgresql.yml`. Add the `activerecord`, `pg`, `otr-activerecord` and `cursor_pagination` gems to your Gemfile.
@@ -81,11 +69,9 @@ gem 'otr-activerecord'
81
69
gem 'cursor_pagination'
82
70
```
83
71
84
-
See the [sample app using ActiveRecord](sample_apps/sample_app_activerecord) for more information.
85
-
86
72
### Usage
87
73
88
-
Start with one of the samples above, which contain a couple of custom commands, necessary dependencies and tests, then [create a new Slack App](https://api.slack.com/applications/new).
74
+
Start with the [slack-ruby-bot-events-sample](https://github.com/slack-ruby/slack-ruby-bot-server-events-sample) sample, which contain a couple of custom commands, necessary dependencies and tests, then [create a new Slack App](https://api.slack.com/applications/new).
89
75
90
76

91
77
@@ -97,6 +83,13 @@ Run `bundle install` and `foreman start` to boot the app. Navigate to [localhost
97
83
98
84
### OAuth Code Grant
99
85
86
+
Configure your app's [OAuth scopes](https://api.slack.com/legacy/oauth-scopes) as needed by your application.
Once clicked, the user is taken through the authorization process at Slack's site. Upon successful completion, a callback containing a temporary code is sent to the redirect URL you specified. The endpoint at that URL contains code that looks like this:
109
-
110
-
```ruby
111
-
# Instantiate a web client
112
-
client =Slack::Web::Client.new
113
-
114
-
# Request a token using the temporary code
115
-
rc = client.oauth_access(
116
-
client_id:ENV['SLACK_CLIENT_ID'],
117
-
client_secret:ENV['SLACK_CLIENT_SECRET'],
118
-
code: params[:code]
119
-
)
120
-
121
-
# Pluck the token from the response
122
-
token = rc['bot']['bot_access_token']
123
-
```
124
-
125
-
The token is stored in persistent storage and used each time a Slack client is instantiated for the specific team.
101
+
Once clicked, the user is taken through the authorization process at Slack's site. Upon successful completion, a callback containing a temporary code is sent to the redirect URL you specified. The endpoint at that URL contains code that persists the bot token each time a Slack client is instantiated for the specific team.
126
102
127
103
### API
128
104
129
-
This library implements an app, [SlackRubyBotServer::App](lib/slack-ruby-bot-server/app.rb), a service manager, [SlackRubyBotServer::Service](lib/slack-ruby-bot-server/service.rb) that creates multiple instances of a bot server class, [SlackRubyBotServer::Server](lib/slack-ruby-bot-server/server.rb), one per team. It also provides [default HTML templates and JS scripts](public) for Slack integration.
105
+
This library implements an app, [SlackRubyBotServer::App](lib/slack-ruby-bot-server/app.rb) and a service manager, [SlackRubyBotServer::Service](lib/slack-ruby-bot-server/service.rb). It also provides [default HTML templates and JS scripts](public) for Slack integration.
130
106
131
107
#### App
132
108
@@ -248,26 +224,7 @@ A number of extensions use service manager callbacks and service timers to imple
248
224
*[slack-ruby-bot-server-events](https://github.com/slack-ruby/slack-ruby-bot-server-events): Easily handle Slack slash commands, interactive buttons and events.
249
225
*[slack-ruby-bot-server-mailchimp](https://github.com/slack-ruby/slack-ruby-bot-server-mailchimp): Subscribes new bot users to a Mailchimp mailing list.
250
226
*[slack-ruby-bot-server-stripe](https://github.com/slack-ruby/slack-ruby-bot-server-stripe): Enables paid bots with trial periods and commerce through Stripe.
251
-
252
-
#### Server Class
253
-
254
-
You can override the server class to handle additional events, and configure the service to use it.
By default the implementation of [Team](lib/slack-ruby-bot-server/models/team) stores a `bot_access_token` as `token` that grants a certain amount of privileges to the bot user as described in [Slack OAuth Docs](https://api.slack.com/docs/oauth) along with `activated_user_access_token` that represents the token of the installing user. You may not want a bot user at all, or may require different auth scopes, such as `users.profile:read` to access user profile information via `Slack::Web::Client#users_profile_get`. To change required scopes make the following changes.
262
+
By default the implementation of [Team](lib/slack-ruby-bot-server/models/team) stores a `bot_access_token` as `token` (for backwards compatibility), and `activated_user_access_token` as the token with all the requested OAuth scopes.
263
+
264
+
### Sample Bots Using Slack Ruby Bot Server
306
265
307
-
1) Configure your app to require additional scopes in Slack API under _OAuth_, _Permissions_
308
-
2) Change the _Add to Slack_ buttons to require the additional scope, eg. `https://slack.com/oauth/authorize?scope=bot,users.profile:read&client_id=...`
309
-
3) The access token with the requested scopes will be stored as `activated_user_access_token`.
266
+
#### Slack Bots with Granular Permissions
310
267
311
-
You can see a sample implementation in [slack-sup#3a497b](https://github.com/dblock/slack-sup/commit/3a497b436d25d3a7738562655cda64b180ae0096).
268
+
*[slack-ruby-bot-server-events-sample](https://github.com/slack-ruby/slack-ruby-bot-server-events-sample), a generic sample
269
+
*[slack-rails-bot-starter](https://github.com/CrazyOptimist/slack-rails-bot-starter), an all-in-one Rails starter kit
312
270
313
-
###Example Bots Using Slack Ruby Bot Server
271
+
#### Legacy Slack Bots
314
272
315
273
*[slack-ruby-bot-server-sample](https://github.com/slack-ruby/slack-ruby-bot-server-sample), a generic sample
316
274
*[slack-sup](https://github.com/dblock/slack-sup), see [sup.playplay.io](https://sup.playplay.io)
@@ -320,7 +278,6 @@ You can see a sample implementation in [slack-sup#3a497b](https://github.com/dbl
320
278
*[slack-api-explorer](https://github.com/slack-ruby/slack-api-explorer), see [api-explorer.playplay.io](https://shell.playplay.io)
321
279
*[slack-strava](https://github.com/dblock/slack-strava), see [slava.playplay.io](https://slava.playplay.io)
322
280
*[slack-arena](https://github.com/dblock/slack-arena), see [arena.playplay.io](https://arena.playplay.io)
323
-
*[slack-rails-bot-starter](https://github.com/CrazyOptimist/slack-rails-bot-starter), an all-in-one rails starter kit built on top of the slack-ruby-bot-server and the slack-ruby-bot-server-events
Copy file name to clipboardExpand all lines: UPGRADING.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,20 @@
1
1
Upgrading Slack-Ruby-Bot-Server
2
2
===============================
3
3
4
+
### Upgrading to >= 1.0.0
5
+
6
+
#### Extracted RealTime (Legacy) Support
7
+
8
+
New slack apps may no longer access RTM. Classic Slack apps can no longer be submitted to the app directory as of December 4th, 2020. In preparation for these changes slack-ruby-bot-server no longer includes RTM components by default. These have been extracted to a new gem [slack-ruby-bot-server-rtm](https://github.com/slack-ruby/slack-ruby-bot-server-rtm).
9
+
10
+
To upgrade an existing classic Slack app that uses slack-ruby-bot-server do the following.
11
+
12
+
1. Add `slack-ruby-bot-server-rtm` as an additional dependency.
13
+
2. Replace any reference to `SlackRubyBotServer::Server` to `SlackRubyBotServer::RealTime::Server`.
14
+
3. Replace any `require 'slack-ruby-bot-server/rspec'` with `require 'slack-ruby-bot-server-rtm/rspec'`.
15
+
16
+
Existing RTM Slack bots will continue working and be listed in the Slack App Directory. On December 4th, 2020 Slack will no longer accept resubmissions from apps that are not using granular permissions. On November 18, 2021 Slack will start delisting apps that have not migrated to use granular permissions. Use [slack-ruby-bot-server-events](https://github.com/slack-ruby/slack-ruby-bot-server-events) to create a Slack bot with granular permissions. See [migration](https://api.slack.com/authentication/migration) for more details.
0 commit comments