laravel / slack-notification-channel

Slack Notification Channel for laravel.
https://laravel.com/docs/notifications#slack-notifications
MIT License
864 stars 59 forks source link

Allow `Attachement` type with the new `Block Kit` #73

Closed maximepvrt closed 1 year ago

maximepvrt commented 1 year ago

Can you maintain Attachment type with the new Block Kit ? Currently it only possible use Messagetype.

An example of Attachement Block Kit https://app.slack.com/block-kit-builder/T92LZA0G7#%7B%22blocks%22:%5B%7B%22type%22:%22header%22,%22text%22:%7B%22type%22:%22plain_text%22,%22text%22:%22Invoice%20Paid%22%7D%7D,%7B%22type%22:%22context%22,%22elements%22:%5B%7B%22type%22:%22plain_text%22,%22text%22:%22Customer%20#1234%22%7D%5D%7D,%7B%22type%22:%22section%22,%22text%22:%7B%22type%22:%22plain_text%22,%22text%22:%22An%20invoice%20has%20been%20paid.%22%7D,%22fields%22:%5B%7B%22type%22:%22mrkdwn%22,%22text%22:%22*Invoice%20No:*%5Cn1000%22%7D,%7B%22type%22:%22mrkdwn%22,%22text%22:%22*Invoice%20Recipient:*%5Cntaylor@laravel.com%22%7D%5D%7D,%7B%22type%22:%22divider%22%7D,%7B%22type%22:%22section%22,%22text%22:%7B%22type%22:%22plain_text%22,%22text%22:%22Congratulations!%22%7D%7D%5D%7D

jbrooksuk commented 1 year ago

@maximepvrt do you mean for this kind of "block"?

CleanShot 2023-08-02 at 09 39 29@2x

It's not possible currently, but we'd accept a PR for this.

maximepvrt commented 1 year ago

Yes @jbrooksuk. My PR #74 was closed by @taylorotwell.

Could you please review my initial attempt at integrating this type of block and provide me with your feedback? I'm willing to continue working on this PR and add tests if you think it has a chance of being merged.

jbrooksuk commented 1 year ago

@maximepvrt your PR was closed as it did not include any explanation, reasoning or examples. I would say that setting the color to denote an "attachment" is not a clear DX.

Your PR will also need to include additional tests.

maximepvrt commented 1 year ago

@jbrooksuk, thank you for your feedback. I understand your concerns regarding the lack of explanation, reasoning, and examples in PR. Regarding the use of color to denote an 'attachment' not being clear for DX, I would like to point out that the only differing factor from a regular message in the new 'Block Kit' format for Slack is the addition of a vertical colored bar.

You can test by switching Message to Attachment on this page

Capture d’écran 2023-08-02 à 11 03 58

Could you please elaborate on what improvements you suggest for a better DX ? I'm open to your suggestions and would appreciate your insights on how to enhance the clarity and usability of this feature. Additionally, I will make sure to include the necessary additional tests in the PR.

jbrooksuk commented 1 year ago

@maximepvrt actually, having read a bit more about the "Attachment" option, it looks like Slack considers this deprecated.

In early 2019 we introduced a new way of composing messages, by using blocks to create rich layouts and enable interactivity. Slack apps designed and built before then may have used features such as attachments which are now considered outmoded.

These older features will continue to work, but apps using them will miss out on the new layout and interactivity features blocks provide. — https://api.slack.com/messaging/attachments-to-blocks

As such, if you need to use the older attachments, I'd consider using the SlackMessage class, which still exists in 3.x

maximepvrt commented 1 year ago

@jbrooksuk, thank you for sharing that information. I appreciate your clarification regarding the "Attachment" option in Slack's messaging. It seems that there might have been a misunderstanding regarding the deprecation status.

I would like to highlight that Slack has introduced 'Attachments to Blocks' as a means to aid migration and to provide a smoother transition for older features to the new layout and interactivity features that blocks offer.

Finding equivalents for older visual elements Nearly every older visual element has a direct equivalent in blocks or block elements. If you were using attachments, you can find a list of block alternatives for each visual component in our attachment fields reference guide.

There is one exception, and that's the color parameter, which currently does not have a block alternative. If you are strongly attached (🎺) to the color bar, use the blocks parameter within an attachment.

This will let you place newer blocks inside of an attachment, but bear in mind the advice above and use the opportunity to rethink your message composition. Users will increasingly associate attachments with less-important secondary content because they have a lower visual hierarchy compared to blocks.

There are a few more things to watch out for if you're an old hand at pre-block message composition.

https://api.slack.com/messaging/attachments-to-blocks#direct_equivalents

jbrooksuk commented 1 year ago

@maximepvrt it may be supported, but the way I read it is that Slack still don't recommend it:

This will let you place newer blocks inside of an attachment, but bear in mind the advice above and use the opportunity to rethink your message composition. Users will increasingly associate attachments with less-important secondary content because they have a lower visual hierarchy compared to blocks.

lionslair commented 1 year ago

I think what you are looking for is remote files https://api.slack.com/messaging/files/remote

Would a PR to add this get considered?