Learn R Programming

slackr (version 2.3.0)

slackr_bot: Send result of R expressions to a Slack channel via webhook API

Description

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

Usage

slackr_bot(
  ...,
  channel = "",
  username = "",
  icon_emoji = "",
  incoming_webhook_url = Sys.getenv("SLACK_INCOMING_URL_PREFIX")
)

Arguments

...

expressions to be sent to Slack

channel

Deprecated. will have no effect

username

Deprecated. will have no effect

icon_emoji

Deprecated. will have no effect

incoming_webhook_url

which slack.com API endpoint URL to use (see section Webhook URLs for details)

Webhook URLs

Webhook URLs look like:

  • https://hooks.slack.com/services/XXXXX/XXXXX/XXXXX

OLD STYLE WEBHOOKS ARE NO LONGER SUPPORTED

Details

By default, everything 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 slackr_setup() first.

See Also

slackr_setup(), slackr(), slackr_dev(), slackr_save(), slackr_upload()

Examples

Run this code
# NOT RUN {
slackr_setup()
slackr_bot("iris info", head(iris), str(iris))

# or directly
slackr_bot("Test message",
           incoming_webhook_url = "https://hooks.slack.com/services/XXXXX/XXXXX/XXXXX")
# }

Run the code above in your browser using DataLab