knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(details)

Overview

slackteams uses incoming webhook tokens to interact with the Slack API. There are two main methods to create a token.

  1. Use slackteams::add_team_interactive to interactively create a token for the R session.
  2. BYOT (Bring your own token) You are a super user or work at a company that supplied you a token.

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

Interactive

This is similar to oauth2 implementation you would see in googlesheets4. The steps are:

  1. Call the function from the R console
  2. Authorize the creation of the token in a browser.
  3. Get redirected back to the R console.

This 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

permissions

The 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")
)

BYOT

This is useful if you:



yonicd/slackteams documentation built on March 13, 2023, 6:26 a.m.