This release is a pre-release and may not be stable for production use.
Microsoft Agents Hosting - Slack
Build Slack agents with the Microsoft 365 Agents SDK using typed message and event handlers, direct Slack Web API calls, and streaming responses.
Packages Overview
We offer the following PyPI packages to create conversational experiences based on Agents:
Installation
pip install microsoft-agents-hosting-slack
Usage
Given configured application options (including storage) and a connection manager:
from microsoft_agents.hosting.core.app import AgentApplication
from microsoft_agents.hosting.core.app.state import TurnState
from microsoft_agents.hosting.slack import SlackAgentExtension, SlackTurnContext
app = AgentApplication[TurnState](options, connection_manager=connections)
slack = SlackAgentExtension(app)
@slack.message()
async def on_slack_message(context: SlackTurnContext, state: TurnState) -> None:
channel_data = context.activity.slack_channel_data
await slack.call(
context,
"chat.postMessage",
{
"channel": channel_data.channel,
"text": f"You said: {context.activity.text}",
},
token=channel_data.api_token or "",
)
Use @slack.message("hello") for a specific message or @slack.event("reaction_added")
for a specific event. Both accept compiled regular expressions and match only Slack
activities. on_message() and on_event() are deprecated aliases.
Handlers receive a SlackTurnContext with typed activity.slack_channel_data and
access to the per-turn Slack API client through context.client. Envelope, payload,
and response models support nested lookups such as envelope.get("event.channel")
and typed lookups such as response.get("count", type_=int).
Use slack.create_stream(context, thread_ts=...) to start a SlackStream, then
append content and stop the stream. See the API docstrings for routing options,
client configuration, streaming requirements, and lookup behavior.
Quick Links
Metadata
Release files for microsoft-agents-hosting-slack 1.9.0.dev5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| microsoft_agents_hosting_slack-1.9.0.dev5.tar.gz | 18.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| microsoft_agents_hosting_slack-1.9.0.dev5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 42.6 kB
Release files / microsoft_agents_hosting_slack-1.9.0.dev5.tar.gz
| Download URL | microsoft_agents_hosting_slack-1.9.0.dev5.tar.gz |
|---|---|
| Size | 18.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
61848986c531acaa9f6720e2aca0cb7cea31bff1b8436cf85cb0941657b85863
|
|
BLAKE2b-256 checksum How to use checksums |
a6b554a4892a3c7ffbfce8678365b7efb359a3055f890c432a9ac1b9d96ae10f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
RestSharp/106.13.0.0
|
Release files / microsoft_agents_hosting_slack-1.9.0.dev5-py3-none-any.whl
| Download URL | microsoft_agents_hosting_slack-1.9.0.dev5-py3-none-any.whl |
|---|---|
| Size | 24.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9c1849182d8f1540a37dea4556eb78c91d017f76622187c66d512a2340f9b290
|
|
BLAKE2b-256 checksum How to use checksums |
93614ae51666dac38f72700c9a8807ddeb85bb21b26eb60794b4d53cdfd7ee6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
RestSharp/106.13.0.0
|