Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate slack blocks #4

Open
3 tasks
jusleg opened this issue May 25, 2019 · 0 comments
Open
3 tasks

Investigate slack blocks #4

jusleg opened this issue May 25, 2019 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@jusleg
Copy link
Owner

jusleg commented May 25, 2019

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 😄

@jusleg jusleg self-assigned this May 25, 2019
@jusleg jusleg added the enhancement New feature or request label May 25, 2019
Repository owner deleted a comment from xie Jul 27, 2019
Repository owner deleted a comment from xie Jul 27, 2019
Repository owner deleted a comment from xie Jul 27, 2019
Repository owner deleted a comment from xie Jul 27, 2019
Repository owner deleted a comment from xie Jul 27, 2019
@jonniesweb jonniesweb mentioned this issue Jul 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant