Slack bots2 minutes to read

Slack bot tokens and scopes for Socket Mode

Tell app-level and bot tokens apart, grant the scopes your Bolt app uses, and replace a token without committing credentials to GitHub.

Assign each Slack credential to one job

  • The app-level token starts with xapp-. Generate it with connections:write and store it as SLACK_APP_TOKEN for the Socket Mode connection.
  • The installed bot token starts with xoxb-. Store it as SLACK_BOT_TOKEN for actions such as posting a reply in that installation.
  • A Slack HTTP receiver needs the signing secret from the same app to verify incoming HTTP requests.

Use the install from the workspace you will test. The same app can have a different bot token for each workspace. Slack token types.

Match permissions to what the handler does

Grant app_mentions:read and subscribe to the app_mention bot event for the mention starter. Grant chat:write so the bot can reply. Add commands if you register a slash command. After a scope change, reinstall the app where Slack requires approval. Check channel membership before asking for broader access.

If a Slack API call reports missing_scope, look up the method and check the workspace install’s granted bot scopes. If it reports not_in_channel, invite the app to the test channel. A connected socket tells you the app-level token has already done its job.

Replace a token and verify it from the workspace

For an app-level token, create a replacement with the same required scope. Save it in Variables and restart. Send a new mention after the hosted worker connects. Revoke the old token once you confirm the replacement works. If a token has been exposed, revoke it promptly and replace it in every consumer.

Slack’s OAuth token rotation feature uses expiring tokens and refresh tokens. A distributed app using that feature needs a durable installation store that can save replacements. Check Slack’s rotation flow before enabling it on a starter that reads a fixed bot token from the environment.