slackify
slackify copied to clipboard
Investigate slack blocks
Slack recently made public the block kit for richer attachments. This new UI framework doesn't make use of callback_id
and favors unique action_id
per button/interactive field. I believe we could introduce compatibility in the framework by making those action_id
work like a callback_id
. We currently have the following format in the callback_id
: handler_name#method_name
. This won't work with the block components as two buttons could have the same action_id
.
I believe this could be fixed by appending extra stuff to the action id just to make it unique and pass slack's payload verification. For instance, we could have a simple counter after the method name. This would ensure uniqueness and we will just not take into account the counter value when parsing.
Example
button1_action_id = my_handler#my_method#1
button2_action_id = my_handler#my_method#2
Then we run something like:
action_id.split('#').tap |parsed_action_id|
handler = parsed_action_id.first
method = parsed_action_id.second
end
The counter could be introduced in a wrapper for the attachments. We send non slack approved block attachments (blocks having duplicate action id) and we make them valid by adding the counter to it. Hardcoded attachments will not need to use the wrapper, but on the fly attachments could make use of it.
Questions left to be answered before going forward
-
[ ] Does slack send the original attachments in the event API payload?
-
[ ] What's the difference between a regular interactive event vs a block event in a callback?
-
[ ] Did slack introduce a new interaction type in their callback API? (It would make our lives way easier if they did
Is slack-ruby-client ready to handle block payloads? Yes, it is 😄
Can we still edit/delete messages the same way (3-second reply window, response URL for 30 min and channel + ts for any time)? No, the response url is the only way of doing it right now. Perhaps a good way would be to add a method in which you pass a response url and a new payload to make the code look similar to the previous behaviour
TL;DR
Use the action_id
as if it was a callback_id
to trick slack into sending our old payload logic into the fancy new block attachments. It would be cool 😄