Skip to content

Releases: slackapi/bolt-python

version 1.6.1

03 Jun 07:58

Choose a tag to compare

Changes

References

version 1.6.0

07 May 08:51

Choose a tag to compare

New Features

Code Suggestion for Missing Listeners

Since this version, the warning message for unhandled requests is even more helpful!

Let's say you've configured the "message" event subscription in the Slack App configuration page, and the Slack server-side started sending message events to your app. However, your app does not have the corresponding event listener yet. In this case, Bolt suggests the missing listener with a working code snippet.

WARNING:slack_bolt.App:Unhandled request ({'type': 'event_callback', 'event': {'type': 'message'}})
---
[Suggestion] You can handle this type of event with the following listener function:

@app.event("message")
def handle_message_events(body, logger):
    logger.info(body)

The new suggestion logging should be helpful for the developers who are new to Bolt and the Slack platform.

Options For Turning the Built-in Middleware Off

Developers can turn any of the built-in middleware off if they would like to do so for some reason.

app = App(
    token=os.environ["SLACK_BOT_TOKEN"],
    signing_secret=os.environ["SLACK_SIGNING_SECRET"],
    # Verify request signature
    request_verification_enabled = False,  # default: True
    # Skip processing the events generated by this app's bot user itself
    ignoring_self_events_enabled = False,  # default: True
    # Respond to ssl_check requests
    ssl_check_enabled = False,  # default: True
    # Respond to url_verification requests in the Events API configuration steps
    url_verification_enabled = False,  # default: True
)

Please make sure if it's safe enough when you turn a built-in middleware off. We strongly recommend using RequestVerification for better security. If you have a proxy that verifies request signature in front of the Bolt app, it's totally fine to disable RequestVerification to avoid duplication of work. Don't turn it off just for easiness of development.

Changes

References

version 1.5.0

20 Apr 06:23

Choose a tag to compare

New Features

Underlying SDK Upgrade

This release upgrades the underlying slack-sdk package from 3.4 to 3.5 (or higher). Refer to the package's release note for more details: https://github.com/slackapi/python-slack-sdk/releases/tag/v3.5.0

Built-in Token Revocation Handlers

Since this version, the out-of-the-box support for the following events is available:

To use this feature, all you need to do are:

  • Enable installation_store of the OAuth settings (see the document)
  • Call enable_token_revocation_listeners() method of the App / AsyncApp instance
app = App(
  # Enabling installation_store required
)
app.enable_token_revocation_listeners()

This is equivalent to the following code:

app = App()  # installation_store required
app.event("tokens_revoked")(app.default_tokens_revoked_event_listener)
app.event("app_uninstalled")(app.default_app_uninstalled_event_listener)

These event listeners properly utilize the data deletion methods in the InstallationStore you use. If you have your own InstallationStore implementation, please implement deletion methods in the classes. Refer to slackapi/python-slack-sdk#995 for more details.

Customize Unhandled Error Handling

Handling unmatched request patterns had not been customizable in the past versions. The pull request #290 introduced a new option to enable using @app.error handlers for unmatched requests. The default is set to False, which is fully backward compatible. If the option is True, Bolt raises a BoltUnhandledRequestError with sufficient information. @app.error handler can customize the behavior for the patterns (e.g., having custom logging, changing HTTP status from 404 to something else).

app = App(
    token=os.environ["SLACK_BOT_TOKEN"],
    signing_secret=os.environ["SLACK_SIGNING_SECRET"],
    # enable @app.error handler to catch the patterns
    raise_error_for_unhandled_request=True,
)

@app.error
def handle_errors(error):
    if isinstance(error, BoltUnhandledRequestError):
        # You may want to have debug/info logging here
        return BoltResponse(status=200, body="")
    else:
        # other error patterns
        return BoltResponse(status=500, body="Something wrong")

Add respond to app.view Listeners

When an input block in your modal has response_url_enabled: true, view_submission payloads can have response_urls. Since this version, you can use respond utility to use the primary element in the array.

@app.view("view-id")
def check(ack, respond):
    # if there is an input block with response_url_enabled: true
    respond("This message will be posted in the selected channel")
    ack()

see also:

Better Compatibility with Thread-local feature based Libraries

ListenerCompletionHandler is a new addition, which enables developers to customize callbacks for listener runner completion. The callbacks can be useful, especially when you use a library/framework that utilizes thread-local variables (e.g., Django ORM, thread-local sessions in SQLAlchemy) along with Bolt for Python.

If you're interested in how it works, check the updated Django adapter implementation for details: https://github.com/slackapi/bolt-python/blob/v1.5.0/slack_bolt/adapter/django/handler.py

from django.db import connections

class DjangoListenerCompletionHandler(ListenerCompletionHandler):
    def handle(self, request: BoltRequest, response: Optional[BoltResponse]) -> None:
        # closes all the thread-local connections in the current thread
        connections.close_all()

Changes

  • #270 Add support for lazy listeners when running with chalice local - Thanks @jlujan-invitae
  • #281 Fix #280 Django thread-local connection cleanup in multi threads - Thanks @seratch
  • #287 Enable installation_store authorize to fallback to bots (prep for #254) - Thanks @seratch
  • #289 Fix #254 Add built-in tokens_revoked/app_uninstalled event handlers - Thanks @seratch
  • #288 Fix #260 Enable to use respond utility in app.view listeners (only when response_urls exists) - Thanks @seratch
  • #290 Fix #273 Enable developers to customize the way to handle unmatched requests - Thanks @seratch

References

version 1.4.4

22 Mar 06:26

Choose a tag to compare

Changes

  • #261 #262 SocketModeHandler#start() does not terminate on Windows - Thanks @vv-grinko @seratch
  • #256 #257 Improve the warning message in App/AsyncApp constructor - Thanks @seratch

References

version 1.4.3

06 Mar 05:35

Choose a tag to compare

Changes

References

version 1.4.2

03 Mar 02:28

Choose a tag to compare

Changes

  • #246 Pass the Bolt logger in default WebClient instantiation - Thanks @seratch
  • Upgrade the minimum version of underlying slack_sdk to v3.4.1 - Thanks @seratch

References

version 1.4.1

21 Feb 03:43

Choose a tag to compare

Changes

  • #244 Fix an issue where different user's token may exist in context - Thanks @seratch

References

version 1.4.0

19 Feb 05:47

Choose a tag to compare

This release upgrades the underlying slack-sdk package from 3.3 to 3.4 (or higher). Refer to the package's release note for more details: https://github.com/slackapi/python-slack-sdk/releases/tag/v3.4.0

Changes

References

version 1.3.2

11 Feb 23:59

Choose a tag to compare

Changes

This patch version upgrades the minimum slack-sdk version from 3.3.1 to 3.3.2 for proxy issue in the built-in SocketModeClient. Also, Socket Mode adapter supports newly added proxy_headers argument in its constructor. Refer to https://github.com/slackapi/python-slack-sdk/releases/tag/v3.3.2 for the underlying changes.

References

version 1.3.1

09 Feb 08:03

Choose a tag to compare

Changes

References