knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(details)
slackteams
uses incoming webhook tokens to interact with the Slack API. There are two main methods to create a token.
slackteams::add_team_interactive
to interactively create a token for the R session.Each has their own pros and cons depending on what type of usage you may have
Token Type|User Level|Session Persistent|Manage Multiple Teams in Session|Store Credentials Locally|Depend on External Server :--:|:--:|:--:|:--:|:--:|:--: Interactive | All | No|Yes | No | No BYOT | Intermediate | Yes|No | Yes | No
This is similar to oauth2 implementation you would see in googlesheets4. The steps are:
R
consoleThis is by far the easiest method.
The main piece that the user controls are the permission scopes the token has attached to it. To help with this we use a yaml file to allow users to define locally what scopes they want to define. {slackteams} comes with its own yaml file with the scopes that are needed to use all of slackverse
.
scopes
channels
: public channels in the workspacegroups
: private channels that your slack app has been added tousers
: people in the workspaceim
: direct messages that your slack app has been added tompim
: group direct messages that your slack app has been added toemoji
: custom emoji in the workspacefiles
: files shared in channels and conversations that your slack app has been added tousergroups
: user groups in the workspacechat
: messages in approved channels & conversationsteam
: team metainformationpermissions
write
access mean that you can post content in a scoperead
access mean that you can view basic information about a scopehistory
access mean that you can view messages and other content in a scopeThe following yaml contains a base
role which contains only read access permissions and slackverse
role containing permissions needed for the packages in slackverse
.
Click the triangle to view the scopes and the permission of each of these roles:
```{details,details.lang = 'yml',details.summary = 'Scopes',echo= FALSE} system.file("scopes.yml", package = "slackteams")
The default scope is called by
slackteams::add_team_interactive( scopes = load_scopes( system.file("scopes.yml", package = "slackteams"), "base" ) )
and corresponds to
slackteams::add_team_interactive(scopes = load_scopes())
To use the `slackverse` role, use
slackteams::add_team_interactive(which = "slackverse"))
It is also possible to define custom roles. To do this, define a scopes file, for example "custom_scopes.yml", which should have scopes defined following the Slack [permission scopes](https://api.slack.com/scopes). For example ```{details,details.lang = 'yml',details.summary = 'Custom Scopes',echo= FALSE}` base: - channels: - read - users: - read - groups: - read - mpim: - read - im: - read - team: - read analyze: - channels: - read - history - users: - read - groups: - read - history - mpim: - read - im: - read - history - team: - read - links: - read postanalysis: - channels: - read - users: - read - groups: - read - mpim: - read - im: - write - team: - read
The resulting file can then be used, for example as
slackteams::add_team_interactive( scopes = load_scopes("/path/to/custom_scopes.yml", which = "analyze") )
This is useful if you:
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.