Skip to content

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

SetDNDResponse(*, snooze_enabled: Optional[bool] = None)

Response for Set do not disturb

Attributes

snooze_enabled class-attribute instance-attribute
snooze_enabled: Optional[bool] = dataclass_field(default=None, kw_only=True)

Whether snooze is enabled.

CreateChannelResponse dataclass

CreateChannelResponse(*, channel: Optional[Channel | Mapping[str, Any]] = None)

Response for Create a channel

JoinChannelResponse dataclass

JoinChannelResponse(*, channel: Optional[Channel | Mapping[str, Any]] = None, warning: Optional[str] = None)

Response for Join a public channel

Attributes

warning class-attribute instance-attribute
warning: Optional[str] = dataclass_field(default=None, kw_only=True)

Whether the user is already in the channel or not.

ListChannelsResponse dataclass

ListChannelsResponse(*, value: Optional[List[Channel | Mapping[str, Any]]] = None, next_link: Optional[str] = None)

Response for List public channels (Pagination support)

Attributes

next_link: Optional[str] = dataclass_field(default=None, kw_only=True, metadata={'wire_name': '@odata.nextLink'})

Link to get next page of results

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
ok: Optional[bool] = dataclass_field(default=None, kw_only=True)

Indicates if the operation was successful.

channel class-attribute instance-attribute
channel: Optional[str] = dataclass_field(default=None, kw_only=True)

The channel which the message was posted to.

ts class-attribute instance-attribute
ts: Optional[str] = dataclass_field(default=None, kw_only=True)

Unix timestamp for when the message was created.

message class-attribute instance-attribute
message: Optional[Dict[str, Any]] = dataclass_field(default=None, kw_only=True)

A channel message.

error class-attribute instance-attribute
error: Optional[str] = dataclass_field(default=None, kw_only=True)

Details of the error messages, if any.

Channel dataclass

Channel(*, id: Optional[str] = None, name: Optional[str] = None)

Definition: Channel

Attributes

id class-attribute instance-attribute
id: Optional[str] = dataclass_field(default=None, kw_only=True)

The id of the channel.

name class-attribute instance-attribute
name: Optional[str] = dataclass_field(default=None, kw_only=True)

The name of channel.

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: str

Channel, private group, or IM channel to send message to. Can be a name(ex:

general) or an encoded ID.
text instance-attribute
text: str

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
username: Optional[str] = dataclass_field(default=None, kw_only=True)

Name of the bot.

as_user class-attribute instance-attribute
as_user: Optional[bool] = dataclass_field(default=None, kw_only=True)

Pass true to post the message as the authenticated user, instead of as a bot.

parse class-attribute instance-attribute
parse: Optional[str] = dataclass_field(default=None, kw_only=True)

Change how messages are treated. For details, see https://api.slack.com/docs/formatting

mrkdwn class-attribute instance-attribute
mrkdwn: Optional[bool] = dataclass_field(default=None, kw_only=True)

Slack markup parsing setting. Enabled by default.

link_names: Optional[int] = dataclass_field(default=None, kw_only=True)

Find and link channel names and usernames.

unfurl_links: Optional[bool] = dataclass_field(default=None, kw_only=True)

Pass true to enable unfurling of primarily text-based content.

unfurl_media class-attribute instance-attribute
unfurl_media: Optional[bool] = dataclass_field(default=None, kw_only=True)

Pass false to disable unfurling of media content.

icon_url class-attribute instance-attribute
icon_url: Optional[str] = dataclass_field(default=None, kw_only=True)

URL to an image to use as an icon for this message.

icon_emoji class-attribute instance-attribute
icon_emoji: Optional[str] = dataclass_field(default=None, kw_only=True)

Emoji 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 async for.

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.