Slack API

Set up a Slack bot with API access for posting messages, reading channels, and responding to events.

⏱ 10 minutes messaging productivity api.slack.com
getapi slack

Prerequisites

  • A Slack workspace where you have permission to install apps
  • Admin or app-installation permissions in that workspace

Credentials

Variable Description Sensitive
SLACK_BOT_TOKEN Bot User OAuth Token (starts with xoxb-) Secret
SLACK_SIGNING_SECRET Signing secret for verifying requests from Slack Secret

Setup Steps

  1. 1 Info

    We'll create a Slack app and get a bot token and signing secret. You'll need admin access (or permission to install apps) in your Slack workspace.

  2. 2 Open URL

    Opening the Slack app management page. Sign in with your Slack account if prompted.

    https://api.slack.com/apps
  3. 3 Choice

    Do you already have a Slack app you want to use, or do you need to create a new one?

  4. 4 Info

    Click 'Create New App', then choose 'From scratch'. Give it a name and select the workspace you want to install it in.

  5. 5 Confirm

    App created? You should now be on the app's settings page.

    Checkpoint — confirm before continuing
  6. 6 Info

    Click on your existing app to open its settings page.

  7. 7 Info

    In the left sidebar, go to 'OAuth & Permissions'. Scroll down to 'Scopes' and under 'Bot Token Scopes', add the permissions your bot needs. Common scopes: 'chat:write' (post messages), 'channels:read' (list channels), 'channels:history' (read messages).

  8. 8 Confirm

    Bot scopes configured?

    Checkpoint — confirm before continuing
  9. 9 Info

    Scroll to the top of the 'OAuth & Permissions' page and click 'Install to Workspace' (or 'Reinstall to Workspace' if updating). Authorize the app when prompted.

  10. 10 Confirm

    App installed to your workspace?

    Checkpoint — confirm before continuing
  11. 11 Input

    Copy the 'Bot User OAuth Token' (starts with xoxb-) and paste it here:

    → SLACK_BOT_TOKEN
    Starts with xoxb-
  12. 12 Info

    Now go to 'Basic Information' in the left sidebar. Under 'App Credentials', find the 'Signing Secret' and click 'Show'.

  13. 13 Input

    Paste your Signing Secret here:

    → SLACK_SIGNING_SECRET
    At least 20 characters
  14. 14 Validate

    Checking your bot token works...

    Bot token verified. Your Slack app is ready.
    Couldn't verify the bot token. Make sure the app is installed and the token is correct.

Things to Know

  • Bot tokens start with 'xoxb-'. User tokens start with 'xoxp-'. Make sure you're using the bot token.
  • The signing secret is used to verify that incoming requests actually come from Slack. You'll need it if you're handling events, slash commands, or interactive messages.
  • If you change scopes after installing, you must reinstall the app to the workspace for changes to take effect.
  • Bots can only access channels they've been invited to. Use '/invite @yourbot' in a channel to add it.
  • Slack's free tier limits message history to 90 days.