0

Has anyone been able to figure out how to create a slack bot that listens to direct messages between two users -- using the slack event api? I am working on a bot that needs to be able to get all messages in all channels and direct messages. Currently, it can only get all messages in public channels (after joining them all initially).

I know this was asked about two years ago here: Slack API message.im event is not triggered for other users

and wondering if anyone had some new ideas? Would this be possible if I altered my bot to use RTM rather than the event subscription api?

Http417
  • 71
  • 6
  • Hey and welcome to SO. Thanks for your question. Unfortunately, the answer is still the same as 2 years ago. It's due to how the security architecture of Slack works. And that has not changed. – Erik Kalkoken Mar 10 '20 at 01:43
  • Also, it does not matter if you use Events API or RTM. You have the same result. – Erik Kalkoken Mar 10 '20 at 01:44
  • Btw. The only functionality that reliably works in direct message channels are slash commands. In case that helps. – Erik Kalkoken Mar 10 '20 at 01:45
  • @ErikKalkoken I know you've answered in the past on many posts -- but would you consider giving someone else a chance to inject new thought into this? would you consider opening this up for that reason? – Http417 Mar 11 '20 at 03:00
  • This is not about a missing feature or finding a smarter approach. It's about how a fundamental principle of Slack's security architecture works. And that has not changed and is very unlikely to change in the future. However, there is a workaround. Don't think it would be very useful for you case, but here it is: https://stackoverflow.com/questions/37690761/get-a-list-of-all-private-channels-with-slack-api/53142640#53142640 – Erik Kalkoken Mar 11 '20 at 11:08
  • @ErikKalkoken I found the solution. turns out that I needed to go to the "subscribe to events on behalf of users' section of the 'Event Subscriptions' page. From there I added the message.im scope. et'voila! Originally I added the 'im.history' scope of the 'User Token Scopes' section of 'Oath&Permissions' Page. But that only sent events for messages sent directly to app. Ha! I hope someone in the future will be able to learn from this. – Http417 Mar 25 '20 at 06:27
  • This will still only work for IMs of the user that authed your app. not between any two users. – Erik Kalkoken Mar 25 '20 at 15:12
  • 1
    Yes that it correct. – Http417 Mar 26 '20 at 17:56

0 Answers0