Skip to content

Releases: slackapi/bolt-python

version 1.9.0

31 Aug 04:49
Compare
Choose a tag to compare

New Features

More Customization for Apps

Since this release, developers can customize listener_executor in apps. Also, to support the use case where Enterprise Grid Org admins install apps from their app management page, we've added a new option to disable state parameter validation in the OAuth flow. Please note that we still don't recommend disabling the state validation for usual OAuth apps.

Changes

References

version 1.8.1

28 Aug 00:53
Compare
Choose a tag to compare

Changes

  • #451 Fix cookie extraction during OAuth for REST based AWS API GW + Lambda app - Thanks @naveensan1
  • #449 Fix typo in App / AsyncApp comments and API documents - Thanks @objectfox
  • #446 Update the entity name - Thanks @seratch

References

version 1.8.0

13 Aug 12:55
Compare
Choose a tag to compare

Changes

  • #436 Fix #409 Custom token rotation expiration time does not work if installation_store is passed at top level - Thanks @seratch
  • #437 Fix a token rotation bug where a bot token is not refreshed if a user token does not exist - Thanks @seratch
  • #431 Fix #430 by adding a new option to customize dev server (http.server) logging - Thanks @seratch @cole-wilson
  • #432 Update Sanic adapter and its tests to be compatible with sanic v21 - Thanks @seratch
  • #416 Fix type hint errors detected by pytype 2021.7.19 - Thanks @seratch

Document Updates

References

version 1.8.0rc1

11 Aug 10:20
Compare
Choose a tag to compare
version 1.8.0rc1 Pre-release
Pre-release

version 1.7.0

15 Jul 23:21
Compare
Choose a tag to compare

New Features

Token Rotation Support

This version includes the support for the apps enabling the newly released token rotation for better security. Refer to the API document for the general information about the feature.

How to handle token rotation with this SDK

If you use any of the built-in InstallationStore, there is nothing else to change on your application code side. If you use the relational database tables along with a built-in InstallationStore, refer to the latest table schema here.

If you use your own custom authorize, not the built-in InstallationStoreAuthorize, the authorize function needs to be updated to run the token rotation. Refer to the InstallationStoreAuthorize's code to learn what to do for it.

Migration guide for Django users

If you operate Django apps based on the example app in this repository and would like to enable token rotation for the apps, check this commit to learn the required changes for it.

Migration guide for SQLAlchemyInstallationStore users

If your app uses the built-in SQLAlchemyInstallationStore for managing Slack app installations, adding the following database columns is required for this version upgrade. Refer to the code to check the complete ones.

Also, since this version, all the table columns for string data have their max length for better compatibility with MySQL. We recommend setting the same ones for your models.

slack_installations
  • Column("bot_refresh_token", String(200)),
  • Column("bot_token_expires_at", DateTime),
  • Column("user_refresh_token", String(200)),
  • Column("user_token_expires_at", DateTime),
slack_bots
  • Column("bot_refresh_token", String(200)),
  • Column("bot_token_expires_at", DateTime),

Changes

  • #404 Fix #400 token rotation feature support - Thanks @seratch
  • #387 #386 Replace re.search() with re.findall() in MessgeListenerMatches middleware to provide better matching results - Thanks @albeec13
  • #379 Make cookies extraction on AWS Lambda compatible with its format v1.0 - Thanks @tattee
  • #375 Update install page to avoid favicon downloads - Thanks @Bhavya6187
  • #401 Fix #378 by adding middleware error handlers - Thanks @seratch @jeremyschulman
  • #403 Fix #377 Better log messages for AsyncApp when a listener is missing - Thanks @seratch
  • #394 Fix #370 by adding an alias of next arg (next_) in middleware arguments - Thanks @seratch
  • #402 Fix #372 by adding listener matcher docs - Thanks @seratch
  • #389 Add reference to WorkflowStepBuilder in docs - Thanks @misscoded

References

version 1.6.1

03 Jun 07:58
Compare
Choose a tag to compare

Changes

References

version 1.6.0

07 May 08:51
Compare
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
Compare
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
Compare
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
Compare
Choose a tag to compare

Changes

References