Attachments
Attachment
Class
Attachment(blocks: 'Block | list[Block] | None' = None, color: 'str | Color | None' = None, fields: 'Field | list[Field] | None' = None, fallback: 'str | None' = None)
Lower priority content can be attached to messages using Attachments. This is content that doesn't necessarily need to be seen to appreciate the intent of the message, but perhaps adds further context or additional information.
See https://api.slack.com/reference/messaging/attachments.
N.B: fields is a deprecated field, included only for legacy purposes. Other legacy
fields, e.g. author_name are deliberately omitted as they were never implemented in
slackblocks.
Arguments
| Argument | Type | Description |
|---|---|---|
blocks | Block | list[Block] | None | an array of Blocks that define the content of the attachment. |
color | str | Color | None | the color (in hex format, e.g. #ffffff) of the vertical bar to the left of the attachment content. Consider using the Color enum from this module. |
fields | Field | list[Field] | None | a list of Field objects to be included in what's rendered in the attachment. |
fallback | str | None | A plain text summary of the attachment used in clients that don't show formatted text (eg. IRC, mobile notifications). |
Errors
| Error | When |
|---|---|
InvalidUsageError | if the color code provided is invalid. |
Color
Class
Color(*values)
Color is a utility class for use with the Slack secondary attachments API.
Pass these to the color argument of
Attachment.
| Value | Preview |
|---|---|
Color.GOOD | |
Color.WARNING | |
Color.DANGER | |
Color.RED | |
Color.BLUE | |
Color.YELLOW | |
Color.GREEN | |
Color.ORANGE | |
Color.PURPLE | |
Color.BLACK |
Field
Class
Field(title: 'str | None' = None, value: 'str | None' = None, short: 'bool | None' = False)
Field text objects for use with Slack's secondary attachment API.
See https://api.slack.com/reference/messaging/attachments#fields.
Arguments
| Argument | Type | Description |
|---|---|---|
title | str | None | text shown as a bold heading on the field. |
value | str | None | text (mrkdwn or plaintext) representing the value of the field. |
short | bool | None | whether the contents of the field is short enough to be presented in multipe columns. |