getting data out of the slackr package history_slackr function

slackr seems to have a case of naming spaghetti. This one is history_slackr and I can't get it to work. Maybe I'm doing something wrong?

The return value is httr response object (invislbly)

Does this work for you?

Any way you can do a reprex? (perhaps with a public slack forum like the R4DS slack community? https://www.rfordatasci.com/)

1 Like

I've replicated the problem on my own Slack workspace where I'm the owner and have full permissions. Anyone using the reprex below will have to insert their own token and webhook.

Here's what happens - I can post a message to either a private or a public channel, but then I can only retrieve the history, or delete posts, from the public channel, and not from the private channel.

As I have global permissions in this workspace, this seems like an inconsistency to me. Perhaps I misunderstand something.

Note that no errors are reported in the reprex, but the calls for history_slackr, or delete_slackr do not work for the private channel.

library(slackr)
packageVersion("slackr")
#> [1] '1.5.0'

username <- "slackr"
api_token <- "xoxp-xxxxxxxxxxxxx-xxxxxxxxxxxxxx-xxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
incoming_webhook_url <- "https://hooks.slack.com/services/xxxxxxxxxxx/xxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"


# public channel "#random"
channel <- "#random"
slackr_setup(channel = channel,
             username = username,
             api_token = api_token,
             incoming_webhook_url = incoming_webhook_url)
slackr("Test message: 1")
slackr_msg("Test message: 2")
slackr_bot("Test message: 3")
history_slackr(count = 3)
#>      type     subtype                    text                ts username
#> 1 message bot_message ```Test message: 3\n``` 1548526424.001900   slackr
#> 2 message        <NA> ```Test message: 2\n``` 1548526424.001800     <NA>
#> 3 message        <NA> ```Test message: 1\n``` 1548526423.001700     <NA>
#>      bot_id      user
#> 1 BFP889P88      <NA>
#> 2 BFPCJLHEV UFRCNF2JJ
#> 3 BFPCJLHEV UFRCNF2JJ
delete_slackr(count = 3)

# private channel "slackr"
channel <- "slackr"
slackr_setup(channel = channel,
             username = username,
             api_token = api_token,
             incoming_webhook_url = incoming_webhook_url)

slackr("Test message: 1")
slackr("Test message: 2")
slackr_bot("Test message: 3")
history_slackr(count = 3)
#> NULL
delete_slackr(count = 3)

Created on 2019-01-26 by the reprex package (v0.2.1)

There is an open issue about that

Ans it seems that there is something not possible with user token.

Yes, it seems that to be sustainable the slackr package needs to be updated to use webhooks throughout and abandon the older user tokens.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.