Skip to main content

Messages

Message

Class

Message(channel: 'str', text: 'str | None' = '', blocks: 'list[Block] | Block | None' = None, attachments: 'list[Attachment] | None' = None, thread_ts: 'str | None' = None, mrkdwn: 'bool' = True, unfurl_links: 'bool | None' = None, unfurl_media: 'bool | None' = None) -> 'None'

A Slack message object that can be converted to a JSON string for use with the Slack message API.

Arguments

ArgumentTypeDescription
channelstrthe Slack channel to send the message to, e.g. "#general".
textstr | Nonemarkdown text to send in the message. If blocks are provided
then this is a fallback to display in notifications.
blockslist[Block] | Block | Nonea list of Blocks to form the contents
of the message instead of the contents of text.
attachmentslist[Attachment] | Nonea list of
Attachments
that form the secondary contents of the message (deprecated).
thread_tsstr | Nonethe timestamp ID of another unthreaded message that will
become the parent message of this message (now a reply in a thread).
mrkdwnboolif True the contents of text will be rendered as markdown
rather than plain text.
unfurl_linksbool | Noneif True, links in the message will be automatically
unfurled.
unfurl_mediabool | Noneif True, media from links (e.g. images) will
automatically unfurl.

Raises: InvalidUsageException: in the event that the items passed to blocks are not valid Blocks.

json

json() -> 'str'

No public documentation is available.

keys

keys() -> 'list[str]'

No public documentation is available.

to_dict

to_dict() -> 'dict[str, Any]'

No public documentation is available.

MessageResponse

Class

MessageResponse(text: 'str | None' = '', blocks: 'list[Block] | Block | None' = None, attachments: 'list[Attachment] | None' = None, thread_ts: 'str | None' = None, mrkdwn: 'bool' = True, replace_original: 'bool' = False, ephemeral: 'bool' = False) -> 'None'

A required, immediate response that confirms your app received the payload.

json

json() -> 'str'

No public documentation is available.

keys

keys() -> 'list[str]'

No public documentation is available.

to_dict

to_dict() -> 'dict[str, Any]'

No public documentation is available.

ResponseType

Class

ResponseType(*values)

Types of messages that can be sent via WebhookMessage.

WebhookMessage

Class

WebhookMessage(text: 'str | None' = None, attachments: 'Attachment | list[Attachment] | None' = None, blocks: 'Block | list[Block] | None' = None, response_type: 'ResponseType | str | None' = None, replace_original: 'bool | None' = None, delete_original: 'bool | None' = None, unfurl_links: 'bool | None' = None, unfurl_media: 'bool | None' = None, metadata: 'dict[str, Any] | None' = None, headers: 'dict[str, str] | None' = None) -> 'None'

Messages sent via the Slack WebhookClient takes different arguments than those sent via the regular WebClient.

See: https://github.com/slackapi/python-slack-sdk/blob/7e71b73/slack_sdk/webhook/client.py#L28

Arguments

ArgumentTypeDescription
textstr | Nonemarkdown text to send in the message. If blocks are provided
then this is a fallback to display in notifications.
attachmentsAttachment | list[Attachment] | Nonea list of
Attachments
that form the secondary contents of the message (deprecated).
blocksBlock | list[Block] | Nonea list of Blocks to form the contents
of the message instead of the contents of text.
response_typeResponseType | str | Noneone of ResponseType.EPHEMERAL or ResponseType.IN_CHANNEL.
Ephemeral messages are shown only to the requesting user whereas
"in-channel" messages are shown to all channel participants.
replace_originalbool | Nonewhen True, the message triggering this response will be
replaced by this message. Mutually exclusive with delete_original.
delete_originalbool | Nonewhen True, the original message triggering this response
will be deleted, and any content of this message will be posted as a
new message. Mutually exclusive with replace_original.
unfurl_linksbool | Noneif True, links in the message will be automatically
unfurled.
unfurl_mediabool | Noneif True, media from links (e.g. images) will
automatically unfurl.
metadatadict[str, Any] | Noneadditional metadata to attach to the message.
headersdict[str, str] | NoneHTTP request headers to include with the message.

Errors

ErrorWhen
InvalidUsageErrorwhen any of the passed fields fail validation.

json

json() -> 'str'

No public documentation is available.

keys

keys() -> 'list[str]'

No public documentation is available.

to_dict

to_dict() -> 'dict[str, Any]'

No public documentation is available.