Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mrkaye97/slackr
An R package for sending messages from R to Slack
https://github.com/mrkaye97/slackr
r rstats slack
Last synced: 3 months ago
JSON representation
An R package for sending messages from R to Slack
- Host: GitHub
- URL: https://github.com/mrkaye97/slackr
- Owner: mrkaye97
- License: other
- Created: 2014-09-04T13:16:47.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-11-10T13:34:56.000Z (12 months ago)
- Last Synced: 2024-06-23T04:56:42.068Z (5 months ago)
- Topics: r, rstats, slack
- Language: R
- Homepage: https://matthewrkaye.com/slackr/
- Size: 5.53 MB
- Stars: 307
- Watchers: 16
- Forks: 84
- Open Issues: 2
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- awesome - slackr
- awesome-shiny-extensions - slackr - Send messages, images, R objects, and files to Slack channels/users. (Backend / Notification Integration)
- jimsghstars - mrkaye97/slackr - An R package for sending messages from R to Slack (R)
README
---
output: rmarkdown::github_document
---```{r base, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```[![CRAN status](https://www.r-pkg.org/badges/version/slackr)](https://CRAN.R-project.org/package=slackr)
[![R-CMD-check](https://github.com/mrkaye97/slackr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/mrkaye97/slackr/actions/workflows/R-CMD-check.yaml)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
![downloads](http://cranlogs.r-pkg.org/badges/grand-total/slackr)
[![codecov](https://codecov.io/gh/mrkaye97/slackr/branch/master/graph/badge.svg?token=5HjUtFfIJR)](https://codecov.io/gh/mrkaye97/slackr)`slackr` provides a set of tools for making it easier to send messages, data, alerts, etc. directly from R to Slack.
You can use this package to send well-formatted output from R to all teammates (or to specific individuals) at the same time
with little effort. You can send text, R function output, images
from the current graphics device and `ggplots`, R objects (as R data files),
rendered LaTeX expressions, and uploaded files.## Installation
```{r setup, eval=FALSE}
# CRAN version
install.packages("slackr")# Development version
devtools::install_github("mrkaye97/slackr")
```## Breaking Changes
Version `3.0.0+` removes all references to `bot_user_oauth_token` (deprecated in `v2.4.0`) in favor of `token`. There have also been significant changes to how `slackr` and `slackr_bot` handle errors. See [the changelog](https://matthewrkaye.com/slackr/news/index.html) for more details.
Version `2.4.0+` now allows users to choose between using a bot token and a user token. See below for details and check the changelog (`NEWS.md`) for more changes.
## Setup
There are three ways of interfacing with `slackr` that provide
significantly different functionality:1. Creating a single-channel bot
Using only a webhook to send messages to a channel
2. Creating a fully-functional multi-channel bot
Creating a bot user to send messages to multiple channels, including plots,
tables, files, etc. as well as deleting messages, reading the channels in a
workspace, etc.3. Using a user token to send messages from a specific user's account
Similar to the fully-scoped bot token, but connected to the account of a single user. This approach is not recommended in production settings -- or any settings where a token needs to be shared -- but it can be useful for one-off Slack messages as it lets users send data as themselves as opposed to through a bot.
In most cases, we recommend `Option 1` above. This requires the fewest
permissions and is the simplest to set up, and will allow basic messaging to a
specific channel.See the vignettes for setup instructions.
## Vignettes
The vignettes contain setup instructions and example usage:
* Option 1 setup: `vignette('scoped-bot-setup', package = 'slackr')`
* Option 2 setup: `vignette('webhook-setup', package = 'slackr')`
* Usage: `vignette('using-slackr', package = 'slackr')`**Important Note:** The setup process for `Option 2` and `Option 3` are roughly the same, with only slightly differing scopes.
### Config File Setup
The `slackr_setup()` function will try to read setup values from a `~/.slackr`
(you can change the default filepath by recording in the SLACKR_CONFIG_FILE_PATH
environment variable or supplying as an argument to the `config_file`
parameter) configuration file, which may be easier and more secure than passing
them in manually (plus, will allow you to have multiple `slackr` configurations
for multiple Slack.com teams).The file is in Debian Control File (DCF) format since it really doesn't need to
be JSON and R has a handy `read.dcf()` function since that's what `DESCRIPTION`
files are coded in.Here's the basic format for the configuration file:
```
token: xox*-
channel: #general
username: slackr
incoming_webhook_url: https://hooks.slack.com/services/XXXXX/XXXXX/XXXXX
icon_emoji: 'boom'
```**As of `slackr 2.3.0`, you can create a config file with `create_config_file()` instead of setting it up manually.** See the docs for details.
You can also change the default emoji icon (from the one you setup at
integration creation time) with `icon_emoji`.## Contributors
Many thanks to:
- [Bob Rudis](https://github.com/hrbrmstr)
- [Jay Jacobs](https://github.com/jayjacobs)
- [David Severski](https://github.com/davidski)
- [Quinn Weber](https://github.com/qsweber)
- [Konrad Karczewski](https://github.com/konradjk)
- [Ed Niles](https://github.com/eniles)
- [Rick Saporta](https://github.com/rsaporta)
- [Jonathan Sidi](https://github.com/yonicd)
- [Matt Kaye](https://github.com/mrkaye97)
- [Xinye Li](https://github.com/xinye1)
- [Andrie de Vries](https://github.com/andrie)for their contributions to the package!
## Known Issues
* Depending on your scopes, `slackr` could quietly fail (i.e. not throw an error, but also not post anything to your channel). If this happens, try explicitly adding the app you're trying to have `slackr` post as to the channel you want in your Slack workspace with `/invite @your_app_name` or make sure you have `chat:write.public` enabled.