Project Status: Active - The project has reached a stable, usable state and is being actively developed. downloads CRAN_Status_Badge

slackr - a package to send user messages & webhook API messages to Slack channels/users

The slackr package contains functions that make it possible to interact with the Slack messaging platform. When you need to share information/data from R, rather than resort to copy/paste in e-mails or other services like Skype, you can use this package to send well-formatted output from multiple R objects and expressions to all teammates at the same time with little effort. You can also send images from the current graphics device, R objects (as R data files), and upload files.

BREAKING CHANGES

Versions 1.4+ BREAK THINGS.

Support has been removed for the "old style" incoming web hooks (see "Setup" below for the required incoming web hook URL format).

The incoming webhook "token" is no longer required or used.

News

Many thanks to:

for their contributions to the package!

The following functions are implemented:

SETUP

The slackr_setup() function will try to read setup values from a ~/.slackr (you can change the default) configuration file, which may be easier and more secure than passing them in manually (plus, will allow you to have multiple slackr configs 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:

api_token: YOUR_FULL_API_TOKEN
channel: #general
username: slackr
incoming_webhook_url: https://hooks.slack.com/services/XXXXX/XXXXX/XXXXX

You can also change the default emoji icon (from the one you setup at integration creation time) with icon_emoji.

Installation

# stable/CRAN
install.packages("slackr")

# bleeding edge
devtools::install_github("hrbrmstr/slackr")

Usage

library(slackr)

# current verison
packageVersion("slackr")
#> [1] '1.4.1'
slackrSetup(channel="#code", 
            incoming_webhook_url="https://hooks.slack.com/services/XXXXX/XXXXX/XXXXX")

slackr(str(iris))

# send images
library(ggplot2)
qplot(mpg, wt, data=mtcars)
dev.slackr("#results")

barplot(VADeaths)
dev.slackr("@jayjacobs")

ggslackr(qplot(mpg, wt, data=mtcars))

Test Results

library(slackr)
library(testthat)

date()
#> [1] "Wed Jul 20 14:05:11 2016"

test_dir("tests/")
#> testthat results ========================================================================================================
#> OK: 0 SKIPPED: 0 FAILED: 0
#> 
#> DONE ===================================================================================================================