Attachments
Warning: Deprecated Feature
Attachments, while still accepted by the Slack API, have long (for years now) been considered a deprecated feature.
That said, there is currently no other way to achieve the vertical, colored bars next to content.
Secondary (less important) content can be attached using the deprecated attachments API.
See: https://api.slack.com/slackblocks/latest/reference/messaging/attachments.
Attachment
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
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
blocks |
Optional[Union[Block, List[Block]]]
|
an array of Blocks that define the content of the attachment. |
None
|
color |
Optional[Union[str, Color]]
|
the color (in hex format, e.g. #ffffff) of the vertical bar to the left of the
attachment content. Consider using the |
None
|
fields |
Optional[Union[Field, List[Field]]]
|
a list of |
None
|
Throws
InvalidUsageError: if the color
code provided is invalid.
Source code in slackblocks/attachments.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|
Color
Color is a utility class for use with the Slack secondary attachments API.
Pass these to the color
argument of
Attachment
.
Color.GOOD |
|
Color.WARNING |
|
Color.DANGER |
|
Color.RED |
|
Color.BLUE |
|
Color.YELLOW |
|
Color.GREEN |
|
Color.ORANGE |
|
Color.PURPLE |
|
Color.BLACK |
Source code in slackblocks/attachments.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|
Field
Field text objects for use with Slack's secondary attachment API.
See https://api.slack.com/reference/messaging/attachments#fields.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title |
Optional[str]
|
text shown as a bold heading on the field. |
None
|
value |
Optional[str]
|
text ( |
None
|
short |
Optional[bool]
|
whether the contents of the field is short enough to be presented in multipe columns. |
False
|
Source code in slackblocks/attachments.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|