Skip to contents

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(
  ...,
  incoming_webhook_url = Sys.getenv("SLACK_INCOMING_WEBHOOK_URL")
)

Arguments

...

expressions to be sent to Slack.

incoming_webhook_url

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

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.

Note

You need a https://www.slack.com account and will also need to setup an incoming webhook: https://api.slack.com/. Old style webhooks are no longer supported.

Webhook URLs

Webhook URLs look like:

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

OLD STYLE WEBHOOKS ARE NO LONGER SUPPORTED

Examples

if (FALSE) { # \dontrun{
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"
)
} # }