Skip to content

Migrating from the Slack legacy bot configuration #1718

Open
@grimesp

Description

@grimesp

Slack shut off legacy bot access today, April 2, 2025. They said they were shutting it off March 31, 2025, but it continued to work until today. For anybody else struggling to get their Errbot configuration migrated, this is what I did:


Okay, this is a very common issue when migrating from the legacy Slack RTM API to the modern Events API or Socket Mode, which Errbot's newer Slack backends use. The core problem is that the way your bot receives messages has fundamentally changed.

Here’s a breakdown of what's likely happening and how to fix it:

  1. Legacy RTM vs. Modern Events/Socket Mode:

    • Legacy RTM: Your bot established a persistent WebSocket connection and received all messages from channels it was a member of. It would then filter these messages locally for the ! prefix.
    • Modern Events API/Socket Mode: Slack now sends specific events to your bot (either via HTTP POST to an endpoint or over a WebSocket in Socket Mode). Your bot needs to explicitly subscribe to the events it cares about. Simply being in a channel isn't enough to get all message events by default with some configurations.
  2. The Likely Culprit: Event Subscriptions:
    You have likely configured the authentication tokens correctly, but your Slack App is probably not subscribed to the necessary message events required for Errbot to "see" the !status message. By default, new Slack apps often only listen for direct mentions (@yourbot ...).

  3. Recommended Approach: Socket Mode:
    For most Errbot setups, Socket Mode is the easier migration path as it doesn't require exposing a public HTTP endpoint. It uses WebSockets, similar in concept to RTM but using the modern event structure.

Steps to Fix:

  1. Ensure Correct Errbot Backend:

    • In your Errbot config.py, make sure you are using the correct modern Slack backend. It's likely called SlackV3 or similar (check the latest Errbot documentation or the backend options). The old one might have just been Slack.
    • # config.py
      BACKEND = 'SlackV3' # Or check errbot --list-backends for the exact name
  2. Configure Tokens in config.py:

    • You need both a Bot Token (xoxb-...) and, if using Socket Mode, an App-Level Token (xapp-...).
    • # config.py
      BOT_IDENTITY = {
          'token': 'xoxb-YOUR-BOT-TOKEN-HERE', # Bot User OAuth Token
          'signing_secret': 'your-signing-secret',
          'app_token': 'xapp-YOUR-APP-LEVEL-TOKEN-HERE', # Needed for Socket Mode
      }
      BOT_SOCKET_MODE = True # Explicitly enable Socket Mode in Errbot
    • Make sure BOT_SOCKET_MODE is set to True.
  3. Configure Your Slack App (api.slack.com):

    • Go to your App's settings page on api.slack.com.
    • a. Enable Socket Mode:
      • Navigate to "Settings" -> "Socket Mode".
      • Ensure it's toggled ON. Generate an App-Level Token if you haven't already (this is the xapp-... token for your config.py).
    • b. Add Required OAuth Scopes (Permissions):
      • Navigate to "Features" -> "OAuth & Permissions".
      • Scroll down to "Scopes". Under "Bot Token Scopes", ensure you have at least:
        • chat:write: To send messages.
        • app_mentions:read: To receive @yourbot mentions (good practice).
        • channels:history: To read messages from public channels the bot is in.
        • groups:history: To read messages from private channels the bot is in.
        • im:history: To read direct messages sent to the bot.
        • mpim:history: To read messages in group direct messages the bot is in.
        • channels:read, groups:read, im:read, mpim:read: Often needed to get context about conversations.
        • users:read: Often useful for looking up user info.
    • c. Subscribe to Bot Events:
      • Navigate to "Features" -> "Event Subscriptions".
      • Ensure it's toggled ON (even if using Socket Mode, this is where you select which events Socket Mode will receive).
      • Expand "Subscribe to bot events".
      • Add the following events (at minimum):
        • app_mention: To be notified when someone @mentions your bot.
        • message.channels: To receive messages posted in public channels the bot is in.
        • message.groups: To receive messages posted in private channels the bot is in.
        • message.im: To receive direct messages sent to the bot.
        • message.mpim: To receive messages in group direct messages the bot is in.
      • Crucially, without the message.* events, your bot will not see regular messages like !status unless they also @mention the bot.
    • d. Reinstall App: After changing Scopes or Event Subscriptions, you must reinstall your app into your workspace. Go back to "Settings" -> "Install App" and click "Reinstall to Workspace" (or "Install to Workspace" if it's the first time after changes). Follow the prompts.
  4. Ensure Bot is in the Channel: Double-check that your bot user has actually been invited to and joined the channel where you are typing the !status command.

  5. Restart Errbot: After updating config.py and your Slack App settings (including reinstalling), restart your Errbot process.

  6. Check Logs: Increase Errbot's log level in config.py (BOT_LOG_LEVEL = logging.DEBUG) and restart. Check the logs when you send a !status command. You should see evidence of the message event being received if the subscriptions are correct. If you see the message event but Errbot doesn't react, check your BOT_PREFIX setting in config.py.

In Summary (Checklist):

  • Use the correct Errbot backend (SlackV3 or similar) in config.py.
  • Set BOT_SOCKET_MODE = True in config.py.
  • Provide both xoxb- (Bot Token) and xapp- (App-Level Token) in BOT_IDENTITY.
  • Enable Socket Mode in Slack App settings.
  • Add necessary OAuth Scopes (chat:write, channels:history, groups:history, im:history, mpim:history, etc.).
  • Subscribe to Bot Events (app_mention, message.channels, message.groups, message.im, message.mpim).
  • Reinstall the Slack App to apply scope/event changes.
  • Ensure the bot user is a member of the relevant channel(s).
  • Restart Errbot.
  • Check logs for errors or received message events.

Following these steps, particularly ensuring the correct Event Subscriptions (message.*) are active and the app is reinstalled, should get your Errbot responding to commands again.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions