slack-bolt 1.27.0


pip install slack-bolt

  Latest version

Released: Nov 13, 2025


Meta
Author: Slack Technologies, LLC
Requires Python: >=3.7

Classifiers

Programming Language
  • Python :: 3.7
  • Python :: 3.8
  • Python :: 3.9
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13
  • Python :: 3.14
  • Python :: Implementation :: CPython

License
  • OSI Approved :: MIT License

Operating System
  • OS Independent

Bolt Bolt logo for Python

PyPI - Version Codecov Pepy Total Downloads
Python Versions Documentation

A Python framework to build Slack apps in a flash with the latest platform features. Read the getting started guide and look at our code examples to learn how to build apps using Bolt. The Python module documents are available here.

Setup

# Python 3.7+ required
python -m venv .venv
source .venv/bin/activate

pip install -U pip
pip install slack_bolt

Creating an app

Create a Bolt for Python app by calling a constructor, which is a top-level export. If you'd prefer, you can create an async app.

import logging
logging.basicConfig(level=logging.DEBUG)

from slack_bolt import App

# export SLACK_SIGNING_SECRET=***
# export SLACK_BOT_TOKEN=xoxb-***
app = App()

# Add functionality here

if __name__ == "__main__":
    app.start(3000)  # POST http://localhost:3000/slack/events

Running an app

export SLACK_SIGNING_SECRET=***
export SLACK_BOT_TOKEN=xoxb-***
python app.py

# in another terminal
ngrok http 3000

Running a Socket Mode app

If you use Socket Mode for running your app, SocketModeHandler is available for it.

import os
from slack_bolt import App
from slack_bolt.adapter.socket_mode import SocketModeHandler

# Install the Slack app and get xoxb- token in advance
app = App(token=os.environ["SLACK_BOT_TOKEN"])

# Add functionality here

if __name__ == "__main__":
    # Create an app-level token with connections:write scope
    handler = SocketModeHandler(app, os.environ["SLACK_APP_TOKEN"])
    handler.start()

Run the app this way:

export SLACK_APP_TOKEN=xapp-***
export SLACK_BOT_TOKEN=xoxb-***
python app.py

# SLACK_SIGNING_SECRET is not required
# Running ngrok is not required

Listening for events

Apps typically react to a collection of incoming events, which can correspond to Events API events, actions, shortcuts, slash commands or options requests. For each type of request, there's a method to build a listener function.

# Listen for an action from a Block Kit element (buttons, select menus, date pickers, etc)
app.action(action_id)(fn)

# Listen for dialog submissions
app.action({"callback_id": callbackId})(fn)

# Listen for slash commands
app.command(command_name)(fn)

# Listen for an event from the Events API
app.event(event_type)(fn)

# Listen for a custom step execution from a workflow
app.function(callback_id)(fn)

# Convenience method to listen to only `message` events using a string or re.Pattern
app.message([pattern ,])(fn)

# Listen for options requests (from select menus with an external data source)
app.options(action_id)(fn)

# Listen for a global or message shortcuts
app.shortcut(callback_id)(fn)

# Listen for view_submission modal events
app.view(callback_id)(fn)

The recommended way to use these methods are decorators:

@app.event(event_type)
def handle_event(event):
    pass

Making things happen

Most of the app's functionality will be inside listener functions (the fn parameters above). These functions are called with a set of arguments, each of which can be used in any order. If you'd like to access arguments off of a single object, you can use args, an slack_bolt.kwargs_injection.Args instance that contains all available arguments for that event.

Argument Description
body Dictionary that contains the entire body of the request (superset of payload). Some accessory data is only available outside of the payload (such as trigger_id and authorizations).
payload Contents of the incoming event. The payload structure depends on the listener. For example, for an Events API event, payload will be the event type structure. For a block action, it will be the action from within the actions list. The payload dictionary is also accessible via the alias corresponding to the listener (message, event, action, shortcut, view, command, or options). For example, if you were building a message() listener, you could use the payload and message arguments interchangably. An easy way to understand what's in a payload is to log it.
context Event context. This dictionary contains data about the event and app, such as the botId. Middleware can add additional context before the event is passed to listeners.
ack Function that must be called to acknowledge that your app received the incoming event. ack exists for all actions, shortcuts, view submissions, slash command and options requests. ack returns a promise that resolves when complete. Read more in Acknowledging events.
respond Utility function that responds to incoming events if it contains a response_url (shortcuts, actions, and slash commands).
say Utility function to send a message to the channel associated with the incoming event. This argument is only available when the listener is triggered for events that contain a channel_id (the most common being message events). say accepts simple strings (for plain-text messages) and dictionaries (for messages containing blocks).
client Web API client that uses the token associated with the event. For single-workspace installations, the token is provided to the constructor. For multi-workspace installations, the token is returned by using the OAuth library, or manually using the authorize function.
logger The built-in logging.Logger instance you can use in middleware/listeners.
complete Utility function used to signal the successful completion of a custom step execution. This tells Slack to proceed with the next steps in the workflow. This argument is only available with the .function and .action listener when handling custom workflow step executions.
fail Utility function used to signal that a custom step failed to complete. This tells Slack to stop the workflow execution. This argument is only available with the .function and .action listener when handling custom workflow step executions.

Creating an async app

If you'd prefer to build your app with asyncio, you can import the AIOHTTP library and call the AsyncApp constructor. Within async apps, you can use the async/await pattern.

# Python 3.7+ required
python -m venv .venv
source .venv/bin/activate

pip install -U pip
# aiohttp is required
pip install slack_bolt aiohttp

In async apps, all middleware/listeners must be async functions. When calling utility methods (like ack and say) within these functions, it's required to use the await keyword.

# Import the async app instead of the regular one
from slack_bolt.async_app import AsyncApp

app = AsyncApp()

@app.event("app_mention")
async def event_test(body, say, logger):
    logger.info(body)
    await say("What's up?")

@app.command("/hello-bolt-python")
async def command(ack, body, respond):
    await ack()
    await respond(f"Hi <@{body['user_id']}>!")

if __name__ == "__main__":
    app.start(3000)

If you want to use another async Web framework (e.g., Sanic, FastAPI, Starlette), take a look at the built-in adapters and their examples.

Getting Help

The documentation has more information on basic and advanced concepts for Bolt for Python. Also, all the Python module documents of this library are available here.

If you otherwise get stuck, we're here to help. The following are the best ways to get assistance working through your issue:

  • Issue Tracker for questions, bug reports, feature requests, and general discussion related to Bolt for Python. Try searching for an existing issue before creating a new one.
  • Email our developer support team: support@slack.com
1.27.0 Nov 13, 2025
1.26.0 Oct 06, 2025
1.26.0.dev4 Oct 03, 2025
1.26.0.dev3 Oct 02, 2025
1.26.0.dev2 Sep 30, 2025
1.26.0.dev1 Sep 30, 2025
1.26.0.dev0 Sep 25, 2025
1.25.0 Sep 09, 2025
1.24.0 Aug 27, 2025
1.23.0 Mar 19, 2025
1.22.0 Dec 18, 2024
1.21.3 Dec 05, 2024
1.21.2 Oct 25, 2024
1.21.1 Oct 22, 2024
1.21.0 Oct 17, 2024
1.20.1 Aug 23, 2024
1.20.0 Aug 14, 2024
1.19.1 Jul 03, 2024
1.19.0 Jun 10, 2024
1.19.0rc1 Jan 25, 2024
1.18.1 Nov 21, 2023
1.18.0 Apr 26, 2023
1.18.0.dev1 Apr 26, 2023
1.17.2 Apr 18, 2023
1.17.1 Apr 13, 2023
1.17.0 Mar 27, 2023
1.17.0rc4 Mar 21, 2023
1.17.0rc3 Mar 15, 2023
1.17.0rc2 Mar 13, 2023
1.17.0rc1 Mar 13, 2023
1.16.4 Mar 10, 2023
1.16.3 Mar 08, 2023
1.16.2 Feb 15, 2023
1.16.2.dev1 Mar 02, 2023
1.16.1 Dec 19, 2022
1.16.1.dev0 Jan 16, 2023
1.16.0 Dec 08, 2022
1.15.5 Nov 17, 2022
1.15.4 Nov 17, 2022
1.15.3 Nov 08, 2022
1.15.2 Oct 18, 2022
1.15.2.dev0 Nov 02, 2022
1.15.1 Oct 06, 2022
1.15.0 Sep 30, 2022
1.15.0.dev0 Sep 26, 2022
1.14.3 Jul 26, 2022
1.14.2 Jul 21, 2022
1.14.1 Jul 12, 2022
1.14.0 May 18, 2022
1.13.2 May 11, 2022
1.13.1 Apr 29, 2022
1.13.0 Mar 18, 2022
1.12.0 Mar 17, 2022
1.11.6 Mar 02, 2022
1.11.5 Feb 25, 2022
1.11.4 Feb 01, 2022
1.11.3 Jan 28, 2022
1.11.2 Jan 17, 2022
1.11.1 Dec 24, 2021
1.11.0 Dec 14, 2021
1.10.0 Nov 04, 2021
1.9.4 Oct 29, 2021
1.9.3 Oct 13, 2021
1.9.2 Sep 28, 2021
1.9.1 Sep 07, 2021
1.9.0 Aug 31, 2021
1.8.1 Aug 28, 2021
1.8.0 Aug 13, 2021
1.8.0rc1 Aug 11, 2021
1.7.0 Jul 15, 2021
1.7.0rc2 Jul 14, 2021
1.7.0rc1 Jul 14, 2021
1.6.1 Jun 03, 2021
1.6.0 May 07, 2021
1.5.0 Apr 20, 2021
1.4.4 Mar 22, 2021
1.4.3 Mar 06, 2021
1.4.2 Mar 03, 2021
1.4.1 Feb 21, 2021
1.4.0 Feb 19, 2021
1.3.2 Feb 11, 2021
1.3.1 Feb 09, 2021
1.3.0 Feb 05, 2021
1.3.0rc1 Feb 04, 2021
1.2.3 Jan 20, 2021
1.2.2 Jan 19, 2021
1.2.1 Jan 12, 2021
1.2.0 Jan 12, 2021
1.2.0rc2 Jan 12, 2021
1.2.0rc1 Jan 10, 2021
1.2.0b4 Dec 14, 2020
1.2.0b3 Dec 08, 2020
1.2.0b2 Dec 03, 2020
1.2.0b1 Dec 01, 2020
1.2.0a3 Nov 30, 2020
1.2.0a2 Nov 25, 2020
1.2.0a1 Nov 25, 2020
1.1.5 Jan 07, 2021
1.1.4 Dec 19, 2020
1.1.3 Dec 16, 2020
1.1.2 Dec 08, 2020
1.1.1 Dec 03, 2020
1.1.0 Dec 02, 2020
1.1.0rc1 Dec 01, 2020
1.0.1 Nov 24, 2020
1.0.0 Nov 09, 2020
1.0.0rc2 Nov 07, 2020
1.0.0rc1 Nov 06, 2020
0.9.6b0 Oct 29, 2020
0.9.5b0 Oct 27, 2020
0.9.4b0 Oct 22, 2020
0.9.3b0 Oct 16, 2020
0.9.2b0 Oct 06, 2020
0.9.1b0 Oct 04, 2020
0.9.0b0 Oct 01, 2020
0.6.4a0 Sep 26, 2020
0.6.3a0 Sep 25, 2020
0.6.2a0 Sep 24, 2020
0.6.1a0 Sep 23, 2020
0.6.0a0 Sep 19, 2020
0.5.3a0 Sep 16, 2020
0.5.2a0 Sep 14, 2020
0.5.1a0 Sep 12, 2020
0.5.0a0 Sep 11, 2020
0.4.0a0 Sep 05, 2020
0.3.2a0 Sep 03, 2020
0.3.1a0 Aug 28, 2020
0.3.0a0 Aug 26, 2020
0.2.3a0 Aug 21, 2020
0.2.2a0 Aug 21, 2020
0.2.1a0 Aug 07, 2020
0.1.0a0 Aug 03, 2020

Wheel compatibility matrix

Platform Python 2 Python 3
any

Files in release

Extras: None
Dependencies:
slack_sdk (<4,>=3.38.0)