R/slackr: How can I setup slackr without legacy tokens?

Viewed 163

I'm trying to set up some automatized slack channels. All the content is ready and automation should work but I'm having problems with setting up slackr. There is a nice tutorial on slackr here but it is outdated as slack has changed its token styles.

dcf_file <- "api_token: [Verification Token]
channel: #bot
username: coronapush
incoming_webhook_url: [webhook_url]
write.dcf(dcf_file, file = "slackr.dcf", )
slackr_setup(config_file = "slackr.dcf", echo = T)

However this gives me:

{
  "SLACK_CHANNEL": ["NA"],
  "SLACK_USERNAME": ["NA"],
  "SLACK_ICON_EMOJI": ["NA"],
  "SLACK_INCOMING_URL_PREFIX": ["NA"],
  "SLACK_API_TOKEN": ["NA"]
} 

and

slackr_channels()
NULL

Thx for your help!

1 Answers

Found my way. You have to create a .txt file called ".xxx" with the following lines:

api_token: xxx
channel: xxx
username: xxx
incoming_webhook_url: xxx

Then slackr_setup(config_file ="[path/]xxx", echo =T) should give you something like this:

{
  "SLACK_CHANNEL": ["#general"],
  "SLACK_USERNAME": ["slackr"],
  "SLACK_ICON_EMOJI": [""],
  "SLACK_INCOMING_URL_PREFIX": [""],
  "SLACK_API_TOKEN": [""]
} 

Most important: slackr_msg() does not work. You have to use slackr_bot(). That is a bit annoying if it takes you forever to find it out like it did for me. Probably you (if you read this far =)) and I should just learn to work with the API directly.

Related