Search code examples
slack-api

When a (slack) bot is made to leave a channel, how can I get an event in the bot telling it this has happened?


When a (slack) bot is made to leave a channel, how can I get an event in the bot telling it this has happened? I'm already handling member_left_channel but when I remove the bot from the channel, it doesn't get this event (probably because the bot is already out of the channel when the event is triggered to flow).


Solution

  • It sounds like your app is subscribed to member_left_channel on behalf of the bot user event. On your app's configuration site, go to Event Subscriptions and select member_left_channel under Subscribe to events on behalf of users.If you subscribe to member_left_channel under the authenticated user instead, as long as the user is in the channel, you should get an event when the bot leaves the channel. In most cases, unless your app is configured to support OAuth, the only authenticated user will be you so make sure you're in the channel.