Messages
Message
Class
Message(channel: str, text: Optional[str] = '', blocks: Optional[Union[List[Block], Block]] = None, attachments: Optional[List[Attachment]] = None, thread_ts: Optional[str] = None, mrkdwn: bool = True, unfurl_links: Optional[bool] = None, unfurl_media: Optional[bool] = None)
A Slack message object that can be converted to a JSON string for use with the Slack message API.
Arguments
| Argument | Type | Description |
|---|---|---|
channel | str | the Slack channel to send the message to, e.g. "#general". |
text | Optional[str] | markdown text to send in the message. If blocks are providedthen this is a fallback to display in notifications. |
blocks | Optional[Union[List[Block], Block]] | a list of Blocks to form the contentsof the message instead of the contents of text. |
attachments | Optional[List[Attachment]] | a list ofAttachmentsthat form the secondary contents of the message (deprecated). |
thread_ts | Optional[str] | the timestamp ID of another unthreaded message that will become the parent message of this message (now a reply in a thread). |
mrkdwn | bool | if True the contents of text will be rendered as markdownrather than plain text. |
unfurl_links | Optional[bool] | if True, links in the message will be automaticallyunfurled. |
unfurl_media | Optional[bool] | if True, media from links (e.g. images) willautomatically unfurl. |
Raises:
InvalidUsageException: in the event that the items passed to blocks
are not valid Blocks.
ResponseType
Class
Types of messages that can be sent via WebhookMessage.
WebhookMessage
Class
WebhookMessage(text: Optional[str] = None, attachments: Optional[List[Attachment]] = None, blocks: Optional[Union[List[Block], Block]] = None, response_type: Union[ResponseType, str] = None, replace_original: Optional[bool] = None, delete_original: Optional[bool] = None, unfurl_links: Optional[bool] = None, unfurl_media: Optional[bool] = None, metadata: Optional[Dict[str, Any]] = None, headers: Optional[Dict[str, str]] = 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
| Argument | Type | Description |
|---|---|---|
text | Optional[str] | markdown text to send in the message. If blocks are providedthen this is a fallback to display in notifications. |
attachments | Optional[List[Attachment]] | a list ofAttachmentsthat form the secondary contents of the message (deprecated). |
blocks | Optional[Union[List[Block], Block]] | a list of Blocks to form the contentsof the message instead of the contents of text. |
response_type | Union[ResponseType, str] | one 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_orginal | None | when True, the message triggering this response will bereplaced by this messaage. Mutually exclusive with delete_original. |
delete_original | Optional[bool] | when True, the original message triggering this responsewill be deleted, and any content of this message will be posted as a new message. Mutually exclusive with replace_orginal. |
unfurl_links | Optional[bool] | if True, links in the message will be automaticallyunfurled. |
unfurl_media | Optional[bool] | if True, media from links (e.g. images) willautomatically unfurl. |
metadata | Optional[Dict[str, Any]] | additional metadata to attach to the message. |
headres | None | HTTP request headers to include with the message. |
Errors
| Error | When |
|---|---|
InvalidUsageError | when any of the passed fields fail validation. |