mrkaye97 / slackr

An R package for sending messages from R to Slack
https://matthewrkaye.com/slackr/
Other
307 stars 83 forks source link

slackr_history() is working for channels but not ims. #196

Closed revgizmo closed 9 months ago

revgizmo commented 1 year ago

slackr_history() is working for channels but not ims.

I also tried replacing the @ name with the ID and channel from slackr_ims() to no avail. I appear to have all 4 of the :history scopes.

Works:

slackr::slackr_history(  channel = "#test_dm_channel")
#> .
#> .
#> 
#> .
#> .
#> .
#> .
#> .
#> .
#> 
#> New names:
#> # A tibble: 21 × 12
#>    type    subtype text   user  bot_id bot_link ts    client_msg_id blocks team 
#>    <chr>   <chr>   <chr>  <chr> <chr>  <chr>    <chr> <chr>         <list> <chr>
#>  1 ... 10
#> # ℹ 11 more rows
#> # ℹ 2 more variables: app_id <chr>, bot_profile <df[,7]>

Created on 2023-09-08 with reprex v2.0.2

Doesn't work:

slackr::slackr_history(  channel = "@conor")
#> .
#> .
#> 
#> .
#> .
#> .
#> .
#> .
#> .
#> 
#> New names:
#> Warning: The slack API returned an error: channel_not_found 
#> # A tibble: 0 × 0

Created on 2023-09-08 with reprex v2.0.2

mrkaye97 commented 12 months ago

Thanks for the report! Looking into this

mrkaye97 commented 12 months ago

Alright, so I highly suspect that this is because you're using a bot token, and bot tokens can't read arbitrary IMs between people in Slack (not 100% sure of this). Can you confirm you're using a bot token? And if yes, can you also confirm that your bot isn't added explicitly as an app inside your IM you want to read (unsure if this is even possible).

I suspect that reading IM history will work if you use a user token, but not 100% sure

revgizmo commented 12 months ago

Confirmed:

  1. I'm using a user token. ("xoxp-" rather than "xoxb-", right?)
  2. my bot isn't added in the IM I want to read
mrkaye97 commented 12 months ago

Yeah, that's right. And thanks! Do you mind trying to add your bot to the IM you want to read? The other thing you could try is making the API calls directly using https://api.slack.com/methods/conversations.history to see if they work. If they do, it's almost certainly a slackr issue, but if they don't (which I suspect they won't), then it's probably because the bot needs to be added to your chat

I know that's not particularly helpful, but unfortunately I'm having trouble reproducing this issue in my sandbox account

stale[bot] commented 9 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.