SlackClient
Attributes
TRIGGER_OPERATIONS
module-attribute
TRIGGER_OPERATIONS: Dict[str, Dict[str, Any]] = {'OnNewFile': {'operation_id': 'OnNewFile', 'path': '/{connectionId}/trigger/files.list', 'method': 'get', 'required_parameters': ['channel'], 'callback_payload_type': None}}
Classes
SetDNDResponse
dataclass
CreateChannelResponse
dataclass
Response for Create a channel
JoinChannelResponse
dataclass
ListChannelsResponse
dataclass
PostMessageResponse
dataclass
PostMessageResponse(*, ok: Optional[bool] = None, channel: Optional[str] = None, ts: Optional[str] = None, message: Optional[Dict[str, Any]] = None, error: Optional[str] = None)
Response for Post message
Attributes
ok
class-attribute
instance-attribute
Indicates if the operation was successful.
channel
class-attribute
instance-attribute
The channel which the message was posted to.
ts
class-attribute
instance-attribute
Unix timestamp for when the message was created.
message
class-attribute
instance-attribute
A channel message.
Channel
dataclass
PostMessageRequest
dataclass
PostMessageRequest(channel: str, text: str, *, username: Optional[str] = None, as_user: Optional[bool] = None, parse: Optional[str] = None, mrkdwn: Optional[bool] = None, link_names: Optional[int] = None, unfurl_links: Optional[bool] = None, unfurl_media: Optional[bool] = None, icon_url: Optional[str] = None, icon_emoji: Optional[str] = None)
Definition: PostMessageRequest
Attributes
channel
instance-attribute
Channel, private group, or IM channel to send message to. Can be a name(ex:
general) or an encoded ID.
text
instance-attribute
Body of the message to send. Slack API will truncate messages containing more than 40,000 characters. For formatting options, see https://api.slack.com/docs/formatting
username
class-attribute
instance-attribute
Name of the bot.
as_user
class-attribute
instance-attribute
Pass true to post the message as the authenticated user, instead of as a bot.
parse
class-attribute
instance-attribute
Change how messages are treated. For details, see https://api.slack.com/docs/formatting
mrkdwn
class-attribute
instance-attribute
Slack markup parsing setting. Enabled by default.
link_names
class-attribute
instance-attribute
Find and link channel names and usernames.
unfurl_links
class-attribute
instance-attribute
Pass true to enable unfurling of primarily text-based content.
unfurl_media
class-attribute
instance-attribute
Pass false to disable unfurling of media content.
icon_url
class-attribute
instance-attribute
URL to an image to use as an icon for this message.
SlackClient
SlackClient(connection_runtime_url: str, credential: AsyncTokenCredential | AzureKeyCredential, *, max_retry_attempts: int = 3, timeout: float = 30.0, use_exponential_backoff: bool = True, initial_retry_delay_seconds: float = 0.5, maximum_retry_delay_seconds: float = 120.0, retry_jitter_factor: float = 0.1, retry_unsafe_http_methods: bool = False, transport: Optional[AsyncHttpTransport] = None, **kwargs: Any)
Bases: ConnectorClientBase
Typed client for slack connector.
Initialize a SlackClient.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
connection_runtime_url
|
str
|
The connection runtime URL from Azure Portal. |
required |
credential
|
AsyncTokenCredential | AzureKeyCredential
|
Caller-owned Azure Core credential. |
required |
max_retry_attempts
|
int
|
The maximum number of request attempts. |
3
|
timeout
|
float
|
The network timeout in seconds for each request. The value configures Azure Core retry and transport deadlines. Nonpositive values disable SDK and transport deadlines. |
30.0
|
use_exponential_backoff
|
bool
|
Whether retries use exponential backoff. |
True
|
initial_retry_delay_seconds
|
float
|
The initial retry delay in seconds. |
0.5
|
maximum_retry_delay_seconds
|
float
|
The maximum retry delay in seconds. |
120.0
|
retry_jitter_factor
|
float
|
The jitter fraction applied to retry delays. |
0.1
|
retry_unsafe_http_methods
|
bool
|
Whether unsafe HTTP methods may be retried. |
False
|
transport
|
Optional[AsyncHttpTransport]
|
Optional Azure Core async HTTP transport closed by the client through its asynchronous lifecycle. |
None
|
**kwargs
|
Any
|
Optional Azure Core pipeline policy settings. |
{}
|
Methods:
set_dnd
async
set_dnd(*, num_minutes: Optional[str] = None, timeout: Optional[float] = None, headers: Optional[Mapping[str, str]] = None, client_request_id: Optional[str] = None, response_hook: Optional[ConnectorResponseHook] = None) -> dict[str, Any] | None
Set do not disturb
Set the do not disturb status for the user.
Swagger operation ID: SetDND.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_minutes
|
Optional[str]
|
The number of minutes to set do not disturb. |
None
|
timeout
|
Optional[float]
|
The request timeout in seconds. |
None
|
headers
|
Optional[Mapping[str, str]]
|
Additional HTTP request headers. |
None
|
client_request_id
|
Optional[str]
|
A caller-provided request identifier. |
None
|
response_hook
|
Optional[ConnectorResponseHook]
|
A callback invoked with the connector response. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
dict[str, Any] | None: The connector operation result. |
Raises:
| Type | Description |
|---|---|
ConnectorException
|
If the connector request fails. |
create_channel
async
create_channel(*, name: Optional[str] = None, is_private: Optional[bool] = None, timeout: Optional[float] = None, headers: Optional[Mapping[str, str]] = None, client_request_id: Optional[str] = None, response_hook: Optional[ConnectorResponseHook] = None) -> dict[str, Any] | None
Create a channel
Create a channel in slack.
Swagger operation ID: CreateChannel_V2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
Optional[str]
|
The name of the new channel. |
None
|
is_private
|
Optional[bool]
|
Channel is private or not. |
None
|
timeout
|
Optional[float]
|
The request timeout in seconds. |
None
|
headers
|
Optional[Mapping[str, str]]
|
Additional HTTP request headers. |
None
|
client_request_id
|
Optional[str]
|
A caller-provided request identifier. |
None
|
response_hook
|
Optional[ConnectorResponseHook]
|
A callback invoked with the connector response. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
dict[str, Any] | None: The connector operation result. |
Raises:
| Type | Description |
|---|---|
ConnectorException
|
If the connector request fails. |
join_channel
async
join_channel(*, channel: Optional[str] = None, timeout: Optional[float] = None, headers: Optional[Mapping[str, str]] = None, client_request_id: Optional[str] = None, response_hook: Optional[ConnectorResponseHook] = None) -> dict[str, Any] | None
Join a public channel
Join a public channel in slack.
Swagger operation ID: JoinChannel_V2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
Optional[str]
|
The name of the channel. |
None
|
timeout
|
Optional[float]
|
The request timeout in seconds. |
None
|
headers
|
Optional[Mapping[str, str]]
|
Additional HTTP request headers. |
None
|
client_request_id
|
Optional[str]
|
A caller-provided request identifier. |
None
|
response_hook
|
Optional[ConnectorResponseHook]
|
A callback invoked with the connector response. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
dict[str, Any] | None: The connector operation result. |
Raises:
| Type | Description |
|---|---|
ConnectorException
|
If the connector request fails. |
list_channels
list_channels(*, timeout: Optional[float] = None, headers: Optional[Mapping[str, str]] = None, client_request_id: Optional[str] = None, response_hook: Optional[ConnectorResponseHook] = None) -> AsyncItemPaged[dict[str, Any]]
List public channels (Pagination support)
List the public channels in slack.
Returns an Azure Core async pager that follows the connector continuation URL.
Swagger operation ID: ListChannels_V3.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
Optional[float]
|
The request timeout in seconds. |
None
|
headers
|
Optional[Mapping[str, str]]
|
Additional HTTP request headers. |
None
|
client_request_id
|
Optional[str]
|
A caller-provided request identifier. |
None
|
response_hook
|
Optional[ConnectorResponseHook]
|
A callback invoked with the connector response. |
None
|
Returns:
| Type | Description |
|---|---|
AsyncItemPaged[dict[str, Any]]
|
AsyncItemPaged[dict[str, Any]]: An Azure Core pager over connector
results. Consume it with |
Raises:
| Type | Description |
|---|---|
ConnectorException
|
If the connector request fails. |
post_message
async
post_message(input: PostMessageRequest | Mapping[str, Any], *, timeout: Optional[float] = None, headers: Optional[Mapping[str, str]] = None, client_request_id: Optional[str] = None, response_hook: Optional[ConnectorResponseHook] = None) -> dict[str, Any] | None
Post message
This operation is used to post a message to the specified channel.
Swagger operation ID: PostMessage_V2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
PostMessageRequest | Mapping[str, Any]
|
The request body. Mapping keys use serialized Swagger wire names. |
required |
timeout
|
Optional[float]
|
The request timeout in seconds. |
None
|
headers
|
Optional[Mapping[str, str]]
|
Additional HTTP request headers. |
None
|
client_request_id
|
Optional[str]
|
A caller-provided request identifier. |
None
|
response_hook
|
Optional[ConnectorResponseHook]
|
A callback invoked with the connector response. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
dict[str, Any] | None: The connector operation result. |
Raises:
| Type | Description |
|---|---|
ConnectorException
|
If the connector request fails. |