InstallationStore / AsyncInstallationStoreSince this version, the following methods are available to use for better installation data management.
All the built-in implementations already support these methods. We recommend subscribing to tokens_revoked / app_uninstalled bot events and call these methods in the event handlers.
We recently started hosting the Python module documents at https://slack.dev/python-slack-sdk/api-docs/slack_sdk/
The new admin.users.session.* APIs for Enterprise Grid customers are supported in WebClient and AsyncWebClient.
In addition to the new features mentioned above, we've resolved a few issues in the slack_sdk.models classes. Also, we've improved the consistency of docstrings in this project.
slack_sdk.models usage in Web APIs - Thanks @invokermain @seratchslack_sdk.models.blocks.Option's description value is invalid in blocks - Thanks @seratchtext missing" warning is technically not always accurate - Thanks @eddygIn this version, better proxy configuration supports are added to all API clients support.
http://{username}:{password}@{host}:{port} format support
HTTPS_PROXY / HTTP_PROXY env variables supportWe've improved the internals of RTMClient v2 in this release. If you are using the module, we highly recommend upgrading to this version.
HTTPS_PROXY / HTTP_PROXY env variable supports in all API clients - Thanks @seratchslack_sdk.models.messages and slack_sdk.models.dialoags (misspelled name) - Thanks @seratch @eddygSCIMClient/AsyncSCIMClient - Thanks @seratchSince this version, we support SCIM API and Audit Logs API.
Refer to the documents for details.
aiohttp.ClientSession in Socket Mode AIOHTTP adapter - Thanks @cxlai @seratchThis version includes support for Socket Mode, which enables developers to receive interactivy payalods and events through WebSocket connections.
https://api.slack.com/socket-mode
For WebSocket connection handling, there are four implementations including major 3rd party open-source libraries.
| PyPI Project | SocketModeClient |
|---|---|
| skack_sdk | slack_sdk.socket_mode.SocketModeClient |
| websocket_client | slack_sdk.socket_mode.websocket_client.SocketModeClient |
| aiohttp (asyncio-based) | slack_sdk.socket_mode.aiohttp.SocketModeClient |
| websockets (asyncio-based) | slack_sdk.socket_mode.websockets.SocketModeClient |
Here is a minimal working example with the built-in WebSocket client. You can switch to other implementation by changing the imports and adding the extra dependencies (websocket_client, aiohttp, websockets).
import os
from slack_sdk.web import WebClient
from slack_sdk.socket_mode import SocketModeClient
# Initialize SocketModeClient with an app-level token + WebClient
client = SocketModeClient(
# This app-level token will be used only for establishing a connection
app_token=os.environ.get("SLACK_APP_TOKEN"), # xapp-A111-222-xyz
# You will be using this WebClient for performing Web API calls in listeners
web_client=WebClient(token=os.environ.get("SLACK_BOT_TOKEN")) # xoxb-111-222-xyz
)
from slack_sdk.socket_mode.response import SocketModeResponse
from slack_sdk.socket_mode.request import SocketModeRequest
def process(client: SocketModeClient, req: SocketModeRequest):
if req.type == "events_api":
# Acknowledge the request anyway
response = SocketModeResponse(envelope_id=req.envelope_id)
client.send_socket_mode_response(response)
# Add a reaction to the message if it's a new message
if req.payload["event"]["type"] == "message" \
and req.payload["event"].get("subtype") is None:
client.web_client.reactions_add(
name="eyes",
channel=req.payload["event"]["channel"],
timestamp=req.payload["event"]["ts"],
)
# Add a new listener to receive messages from Slack
# You can add more listeners like this
client.socket_mode_request_listeners.append(process)
# Establish a WebSocket connection to the Socket Mode servers
client.connect()
# Just not to stop this process
from threading import Event
Event().wait()
WebClient#files_upload fails with the default team_id param for Org-wide installations - Thanks @gburek-fastly @seratchWebClient#files_upload's file argument - Thanks @gburek-fastly @seratchThe following changes are related to documents and tutorial contents:
This version includes the changes related to Org-Wide App feature, which is for Enterprise Grid organizations.
https://api.slack.com/enterprise/apps
InstallationStore#find_installation from InstallationStore#find_bot in authorize functionsteam_access_granted / team_access_removedis_enterprise_install: bool in context objectIf you're already using a built-in InstallationStore implementation, the following fields in the data row will be expected since v3.1. If your app uses relational database tables, please add the corresponding columns to the tables.
is_enterprise_install: bool (true if it is an org-level installation)enterprise_url: Optional[str] (URL; this is available only for org-level installation)enterprise_name: Optional[str] (the name of the installed org; this value is just a snapshot data at the timing of installations. So, it can be changed afterwards)team_name: Optional[str] (the name of the installed workspace)incoming_webhook_channel: Optional[str] (channel name)token_type: Optional[str]Also, since this version, the built-in InstallationStore based authorize functions try to fetch Installation. The Installation object contains Bot data too. So, you will be able to utilize more fields like user_token, thanks to this change.
If your application does not maintain the data when handling Slack app installations, upgrading to this version may result in errors due to this incompatibility. If you need to continue using Bot over Installation data rows, please consider implementing and using your own Authorize classes.
PlainTextInputElement class comment fix - Thanks @jelizaga3-gatechCheck v3.1.0 release note.
v3.1.0 includes org-level installation support (for Enterprise Grid users). The detailed release note will be available soon.
This is the first stable version of slack_sdk v3. The remarkable updates in this major version are:
WebClient and WebhookClientslack to slack_sdk) with deprecation warningsRefer to the documents for details. The migration guide for slackclient v2.x users is available at https://slack.dev/python-slack-sdk/v3-migration/
This is the third release candidate version of slack_sdk v3.0.0. The remarkable updates in this major version are:
WebClient and WebhookClientslack to slack_sdk) with deprecation warningsRefer to the documents for details.
The migration guide for slackclient v2.x users is available at https://slack.dev/python-slack-sdk/v3-migration/
see v3.0.0rc3
This is the first release candidate version of slack_sdk v3.0.0. The remarkable updates in this major version are:
WebClient and WebhookClientslack to slack_sdk) with deprecation warningsRefer to the documents for details.
The migration guide for slackclient v2.x users is available at https://slack.dev/python-slack-sdk/v3-migration/
see 3.0.0rc1
Refer to v2.9.3 milestone to know the complete list of the issues resolved by this release.
Updates