-
Notifications
You must be signed in to change notification settings - Fork 28
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
Support Slack Message Buttons #40
Comments
We are considering this. |
Any idea when could this feature be implemented for Slack ? |
Nothing concrete is currently being worked on (to the best of my knowledge) so don't get your hopes up too much. |
Any news or progress on this? |
@i-nikolov I am using Slack's API to make use of this feature instead of relying on any functions from errbot. |
@ab9-er Will you be willing to share some code examples with us? |
@eran-totango check this out https://gist.github.com/ab9-er/e47695429262f8274d1b0a9b19114db0 (I have initiated a variable with a mutable value which is not the best of the practices but it was a dirty quick example) 😈 The function should also return something, which it doesn't in the basic example, best would be to return the result of the API call which should be a 200 OK along with the ts value of the message and other details as per Slack's API documentation. |
@ab9-er cool, I'd really love to integrate that to flows: they basically match this with button answers being fed to the context and unlocking steps. I don't have much time for myself at the moment but I can guide anyone willing to do that. |
@gbin-argo I could help chip in but sporadically. |
I'm a bit keen on this too, but I also see authentication being "fun" (not). @ab9-er how did you handle that? |
@ab9-er @gbin-argo Is there any update regarding this feature? if not then I would like to take up the task of implementing this feature 😄 |
You guys may want to take a quick glance at https://api.slack.com/changelog/2018-12-a-bric-a-brac-of-broadcasts-built-with-blocks before starting any work. I don't know if it impacts buttons, but it might.
|
I guess this is more meant to be provided by Slack Events errbotio/errbot#1451 . def _interactive_message_event_handler(self, event):
"""
Event handler for the 'interactive' event, used in attachments / buttons.
"""
msg = Message(
frm=SlackPerson(event['user']['id'], event['channel']['id'], bot=self),
to=self.bot_identifier,
extras={
'actions': [{x['name']: x} for x in event['actions']],
'url': event['response_url'],
'trigger_id': event.get('trigger_id', None),
'callback_id': event.get('callback_id', None),
'slack_event': event
}
)
flow, _ = self.flow_executor.check_inflight_flow_triggered(msg.extras['callback_id'], msg.frm)
if flow:
log.debug("Reattach context from flow %s to the message", flow._root.name)
msg.ctx = flow.ctx
self.callback_message(msg) Then on callback_message of the plugin: def callback_message(self, msg):
callback = msg.extras.get('callback_id', None)
if (
callback and callback in dir(self) and
callable(getattr(self, callback))
):
self.log.info(f'Calling function {callback}')
return getattr(self, callback)(msg) Finally on the command: @botcmd
def approval_request(self, msg, args=None):
""" Check response of a request. """
if msg.extras.get('callback_id', None) == 'approval_request':
answer = msg.extras.get('actions')[0]['question']['value']
answer = True if answer == 'Approve' else False |
Slack recently introduced the concept of message buttons.
Blog post: https://slackhq.com/get-more-done-with-message-buttons-5fa5b283a59
Developer documentation: https://api.slack.com/docs/message-buttons
Here's their summary of the interaction model:
I opened this issue so there would be a place for conversation about if and how errbot could support message buttons.
The text was updated successfully, but these errors were encountered: