You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use new slack "blocks" instead of "attachments" #166
It looks like attachments is still used, but there are simply some deprecated keys for each attachment, and a new blocks key within the attachments array to replace the deprecated functionality.
When you say it's "broken", what do you mean? Are there any hints in the st2chatops logs?
This feature is a legacy part of messaging functionality for Slack apps. We recommend you stick with layout blocks as above, but if you still want to use attachments, read our caveats below.
And the most thorough advice that basically says it's deprecated even though it's not deprecated...
Secondary attachments are a legacy part of the messaging functionality. While we aren't deprecating them, you should understand that they might change in the future, in ways that reduce their visibility or utility.
We've already mentioned that we recommend the attachments array only contain secondary content that is less important to the intent of the published message.
Any content displayed within attachments may be wrapped, truncated, or hidden behind a "show more" style option by Slack clients. This isn't the case with the top-level blocks field.
In short, we recommend you use layout blocks for as much of your message composition as you can, and avoid using attachments if possible. Blocks have many more visual and interactive capabilities available.
And the big caveat just after that section explaining why attachments are NOT completely deprecated (yet).
At launch, messages built with blocks will not be supported in “All unreads”, “Threads”, “Pinned”, “Starred”, and “Shared Messages” views in Slack. Instead, users will see: This message can't be shown in full here. View message
We’re working actively to support these views as soon as possible.
This feature is a legacy part of messaging functionality for Slack apps. We recommend you stick with layout blocks, but if you still want to use attachments, read our caveats.
I think we're talking past each other. The new blocks thing is just an object that goes in the attachments array, so semantically blocks are simply a special type of attachments. The attachments array is not going away.
Is there anything useful in the logs when it fails? Does anything show up in Slack when you try to use blocks? It's a little difficult to debug something when the only information I have to go on is "it doesn't work" or "it doesn't display".
Also, the Slack adapter doesn't do a whole lot of munging when it sees an extra.slack.attachments key, so I'm surprised this isn't working. Have you verified that your usage of blocks is correct with Slack?
Putting blocks under attachments was the only way I could get any blocks to work. blocks should actually replace attachments, so it would be something like:
extra:
slack:
text: some msg
blocks:
- type: section
text:
type: plain_text
text: section header
- type: divider
- type: actions
elements:
type: button
text: windows link to file on NAS
url: "file://///nas_server/share/path/filename.csv"
When I used the workaround of putting blocks under attachments, iirc, there were no error messages in the log, but the actions never showed up in Slack.
Does something like this work? Can you test this out? It's straight out of the Slack docs:
result:
format: ...extra:
slack:
icon_emoji: ":jira:"username: Jira Botattachments:
- blocks:
- type: sectiontext:
type: mrkdwntext: "Danny Torrence left the following review for your property:"
- type: divider
- type: sectionblock_id: section567text:
type: mrkdwntext: > <https://example.com|Overlook Hotel> :star: Doors had too many axe holes, guest in room 237 was far too rowdy, whole place felt stuck in the 1920s.accessory:
type: imageimage_url: https://is5-ssl.mzstatic.com/image/thumb/Purple3/v4/d3/72/5c/d3725c8f-c642-5d69-1904-aa36e4297885/source/256x256bb.jpgalt_text: Haunted hotel image
- type: divider
- type: sectionblock_id: section789fields:
- type: mrkdwntext: "*Average Rating*\n1.0"
Activity
blag commentedon May 14, 2019
It looks like
attachmentsis still used, but there are simply some deprecated keys for each attachment, and a newblockskey within theattachmentsarray to replace the deprecated functionality.When you say it's "broken", what do you mean? Are there any hints in the st2chatops logs?
Edit:
attachmentsis an array.cognifloyd commentedon May 16, 2019
By broken, I mean that if I include an actions type element in the list of blocks, it does not render in slack.
cognifloyd commentedon May 16, 2019
It's not deprecated, but it is legacy until they can get blocks ready enough to deprecate it.
A quote from Creating rich message layouts
And the most thorough advice that basically says it's deprecated even though it's not deprecated...
And the big caveat just after that section explaining why attachments are NOT completely deprecated (yet).
And another quote from the top of Reference: Secondary attachments
blag commentedon May 16, 2019
I think we're talking past each other. The new
blocksthing is just an object that goes in theattachmentsarray, so semantically blocks are simply a special type of attachments. Theattachmentsarray is not going away.Is there anything useful in the logs when it fails? Does anything show up in Slack when you try to use
blocks? It's a little difficult to debug something when the only information I have to go on is "it doesn't work" or "it doesn't display".Also, the Slack adapter doesn't do a whole lot of munging when it sees an
extra.slack.attachmentskey, so I'm surprised this isn't working. Have you verified that your usage of blocks is correct with Slack?cognifloyd commentedon Apr 18, 2020
Putting blocks under attachments was the only way I could get any blocks to work.
blocksshould actually replaceattachments, so it would be something like:When I used the workaround of putting blocks under attachments, iirc, there were no error messages in the log, but the actions never showed up in Slack.
blag commentedon Jun 18, 2020
Does something like this work? Can you test this out? It's straight out of the Slack docs: