Learn R Programming

slackr (version 1.2)

slackrBot: Output R expressions to a slack.com channel/user (as slackbot)

Description

Takes an expr, evaluates it and sends the output to a slack.com chat destination. Useful for logging, messaging on long compute tasks or general information sharing.

Usage

slackrBot(..., channel = Sys.getenv("SLACK_CHANNEL"),
  username = Sys.getenv("SLACK_USERNAME"),
  icon_emoji = Sys.getenv("SLACK_ICON_EMOJI"),
  incoming_webhook_url = Sys.getenv("SLACK_INCOMING_URL_PREFIX"),
  token = Sys.getenv("SLACK_TOKEN"))

Arguments

...
expressions to be sent to Slack.com
channel
which channel to post the message to (chr)
username
what user should the bot be named as (chr)
icon_emoji
what emoji to use (chr) "" will mean use the default
incoming_webhook_url
which slack.com API endpoint URL to use
token
your webhook API token

Details

By default, everyting but expr will be looked for in a "SLACK_" environment variable. You can override or just specify these values directly instead, but it's probably better to call slackrSetup first.

This function uses the incoming webhook API and posts user messages as slackbot

See Also

slackrSetup, slackr, dev.slackr, save.slackr, slackrUpload

Examples

Run this code
slackrSetup()
slackr("iris info", head(iris), str(iris))

Run the code above in your browser using DataLab