0PricingLogin
AI Agents · Lesson

Slack Bolt SDK Basics

App initialization, bot tokens, socket mode vs HTTP, and event subscriptions.

Why Slack Bolt for Agent Development?

Slack Bolt is the official Python SDK for building Slack apps. It handles OAuth, event routing, middleware, and the request/response lifecycle — so your agent focuses on business logic, not HTTP plumbing. Bolt supports both Socket Mode (WebSocket) and HTTP mode.

# Install Slack Bolt
# pip install slack-bolt

# Slack Bolt handles:
# - Event subscriptions (messages, mentions, reactions)
# - Slash commands (/summarize, /ask)
# - Interactive components (buttons, modals, select menus)
# - Shortcuts (global and message shortcuts)
# - OAuth 2.0 for multi-workspace apps
# - Request signature verification (security)

print('Slack Bolt is the official Python SDK for Slack apps')

Bot Token and Signing Secret

A Slack app needs two credentials: a Bot Token (starts with xoxb-) for making API calls and posting messages, and a Signing Secret for verifying that incoming events genuinely come from Slack. Both are found in the Slack app settings dashboard.

import os
from slack_bolt import App

# Load credentials from environment variables
# Never hardcode tokens!
BOT_TOKEN = os.environ['SLACK_BOT_TOKEN']        # xoxb-...
SIGNING_SECRET = os.environ['SLACK_SIGNING_SECRET']  # hex string

# Initialize the Bolt app
app = App(
    token=BOT_TOKEN,
    signing_secret=SIGNING_SECRET
)

print('Slack Bolt app initialized')
print(f'Bot token prefix: {BOT_TOKEN[:10]}...')

All lessons in this course

  1. Slack Bolt SDK Basics
  2. Listening to Events and Slash Commands
  3. Sending Messages and Rich Blocks
  4. Building a Team Notification Bot
← Back to AI Agents