-
Notifications
You must be signed in to change notification settings - Fork 636
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 for Message Buttons, Menus, and Dialogs #316
Comments
@mhemmings I guess this can already be done via the |
Agreed that this would be a cool feature to add! I don't have the bandwidth to implement it myself, but would love a PR ;) |
+1 for this, I would love to be able to have my hubot send a response with action buttons |
+1 for this. |
The catch, FWIW, is that only apps can use action buttons, but Hubot is implemented as a custom integration—which is not allowed to use action buttons. I'm working to see what we can manage, but I'm going to have to ask you to hold your collective breaths for the moment :( |
Is there any plan to enable custom integrations to also use these action builds? |
Unfortunately, that's not something I can knowledgably comment on. |
By reading https://api.slack.com/bot-users, it seems a bot can be bundled as an app? But I guess it means hosting it. There are also bot users, and it seems they can benefit from Action Buttons if I correctly understood the content of the page. |
Sorry if I'm completely misunderstanding this thread. Ideally I'd like my hubot to make use of action buttons if it's possible though I'm getting the impression it's impossible to do via hubot. Or is this more it's difficult to make direct support whilst there's still a workaround? I have my bot configured through the hubot app on slack instead of a custom configuration. If it's impossible to do via Hubot, I'm guessing l would still be able to do it through the generic bot custom integration? I seem to have found a few examples of people using action buttons using botkit. |
So, I did manage to get action buttons working through creating my own App: https://api.slack.com/apps I've added this to my team as an App and not a custom integration. You get a Verification Token by creating a bot this way which was successfully able to connect a Botkit bot to. I imagine you should be able to connect to it with a hubot bot as well. I will quickly check this now. Edit: Sadly I can't seem to connect hubot as it gives me this error:
Think this is because of this: https://github.com/slackhq/hubot-slack/pull/174/files since the Verification Token doesn't begin with xoxb or xoxp. So there's probably no way to get hubot to be able to create action buttons? :[ |
@angelalukic what does an App Verification Token look like? Because if it does not work solely because of this verification, it should be fairly easy to patch. PS: by the way, how have you been able to add an app if it is not available in the App Directory? Have not found a link or button to perform this action. |
@oncletom The App Verification Token is a 24 character long string using uppercase and lowercase letters and numbers. There is no punctuation or xoxb/xoxp on the front. I was able to create my app here: https://api.slack.com/apps I think upon creating an app you have to actively add it to the App Directory, otherwise you can just add it to your own Slack channels for private use/testing purposes. |
This would be a great feature to have. |
We are thinking about ways to make this happen so you don't have to jump through these hoops, FWIW. I can't say when a solution will be ready, or what it will look like, however :( |
+1 for this |
I would love to have this cool feature! |
1 similar comment
I would love to have this cool feature! |
I would love to have this feature |
+1 for this! |
At the moment, this is totally impossible to add to Hubot because of the way message buttons work. But I just wanted to update this ticket to let you know that finding a way to make this happen is increasingly a priority. Thanks for hanging in there, y'all! |
If anyone is interested, I have this sort of working using workarounds; the Bot User OAuth Access Token provided on the OAuth & Permissions page for app management can be used fine for // VERY IMPORTANT! If you don't verify the token against the one on the app's
// Basic Info page, anyone can trigger these actions!
let slackToken = process.env.HUBOT_SLACK_VERIFY_TOKEN;
module.exports = (robot) => {
robot.router.post('/hubot/slack-msg-callback', (req, res) => {
let data = null;
if(req.body.payload) {
try {
data = JSON.parse(req.body.payload);
} catch(e) {
robot.logger.error("Invalid JSON submitted to Slack message callback");
res
.response(422)
.send('You supplied invalid JSON to this endpoint.');
return;
}
} else {
robot.logger.error("Non-JSON submitted to Slack message callback");
res
.response(422)
.send('You supplied invalid JSON to this endpoint.');
return;
}
if(data.token === slackToken) {
robot.logger.info("Request is good");
} else {
robot.logger.error("Token mismatch on Slack message callback");
res
.response(403)
.send('You are not authorized to use this endpoint.');
return;
}
let handled = robot.emit(`slack:msg_action:${data.callback_id}`, data, res);
if (!handled) {
res
.response(500)
.send('No scripts handled the action.');
}
});
}; |
@ceph3us can you be more specific on how to use this script? |
Sorry for the wall of text. It's rather convoluted this way, since you have to deal directly with the Slack API yourself, but it does work. |
@ceph3us thanks a lot i will try it! |
So to get this working I went through all the trouble of making a whole new Slack App for my work's Enterprise Grid. It works just fine. The only problem is there's no "Add Configuration" button like there is for Hubot so I can't even make multiple instances of the bot. Why is this a problem? Well we have a production, a qa-testing, and multiple dev instances of the bot for each of our developers on the project. So basically I'm stuck. I do not want to make this a published app because it's not meant for public consumption. I also don't want to make a new app for every instance of our bot. That's just ridiculous. |
hello, i have added hubot to slack then i connect him with the given token so in my code i use this : robot.hear(/test/i, res => {
res.send({
"text": "Would you like to play a game?",
"attachments": [
{
"text": "Choose a game to play",
"fallback": "You are unable to choose a game",
"callback_id": "wopr_game",
"color": "#3AA3E3",
"attachment_type": "default",
"actions": [
{
"name": "game",
"text": "Chess",
"type": "button",
"value": "chess"
},
{
"name": "game",
"text": "Falken's Maze",
"type": "button",
"value": "maze"
},
{
"name": "game",
"text": "Thermonuclear War",
"style": "danger",
"type": "button",
"value": "war",
"confirm": {
"title": "Are you sure?",
"text": "Wouldn't you prefer a good game of chess?",
"ok_text": "Yes",
"dismiss_text": "No"
}
}
]
}
]
})
}); i try to make it work, but on click on button, slackbot say that : Darn – that didn’t work. Only Slack Apps can add interactive elements to messages. Manage your apps here: https://api.slack.com/apps/ i have added an slack app and connected @slack/interactive-messages. // Attach action handlers by callback_id
slackMessages.action('wopr_game', (payload) => {
console.log(payload);
}); now nothing change. Darn – that didn’t work. Only Slack Apps can add interactive elements to messages. Manage your apps here: https://api.slack.com/apps/ same error ... thx for the help |
@madbean You need to create a new Slack Application with "Interactive Messages" and "Bots" enabled as features. |
thx for the quick response, one more question, i have activated the feature but now i doesn't have any token, should i create a custom bot to get a token ? https://my.slack.com/services/new/bot ? edit : i answer to me : the token is on the install section |
@madbean Counter intuitively the bot tokens will be under OAuth & Permissions Hubot will work just fine with these. |
sorry if this is a dumb question, but is there a particular reason why @ceph3us solution can't be integrated into hubot (providing the user defines the correct |
@gingerlime |
@gingerlime |
@andreash92 |
@hparadiz oh i didnt know that. could you please give me an example of this "the WebAPI client in the hubot environment won't have access to everything that a normal Hubot configuration would have." ? |
@andreash92 Basically try running A Hubot configuration will work. A stand alone Slack application using the Bot OAuth key will NOT work. You actually need to make a second WebClient instance to get around this. |
@hparadiz oh now i see what you mean. thanks for letting us know |
sorry, but I'm confused. What exactly is a "Hubot Configuration"? If I have hubot running and using the slack adapter, can I then use @ceph3us solution? If so, what's blocking this being merged into the project? |
@gingerlime A Hubot configuration is a special type of Slack application. It comes with an OAuth bot token but not much else. It does NOT support interactive messages (buttons, drop downs). The benefit of a Hubot configuration is that the OAuth bot token provided gives you access to all of the abilities that are provided by the Slack Web API without having to use a different OAuth access token. TLDR |
Hi guys, I made small dumb wrapper of node-slack-interactive-messages for Hubot in here, so people can write external Hubot scripts using Slack interactive messages without conflicting with each other. I hope the module to be more than what it is right now. |
Thanks a lot @hparadiz and @alFReD-NSH ! Hope I'll get a chance to play around with this soon :) |
@alFReD-NSH your project is very interesting! since your goal / motivation is to standardize interactive message in the hubot status update: i've heard the feedback that setting up Apps is quite a bit more work than using the custom bot method or using the Hubot configuration method of registering with Slack. i'm trying to work out how we can simplify the creation of Apps. if that proves to be too much work to get done quickly, then we'll go ahead with updating the docs for App creation. either way we'll be integrating the |
is there any way to get this working when having hubot behind the firewall? We connect it through a http-proxy and that works well, but buttons require a URL accessible on the internet. |
@davidkarlsen you will have to allow an incoming connection from slack's servers in order to use interactive message features. in a strict security environment, i recommend verifying requests are originating from slack by checking the verification token on an unprivileged proxy that can forward only verified requests into your trusted infrastructure. this is essentially shared secret (password) security. one step further you might want to take is to make your Request URL extremely obfuscated and difficult to guess. |
@aoberoi Any updates? |
@zdrummond we don't have any development for this feature planned. the maintainers are definitely open to contributions to address this need, and we'd be happy to review and give feedback to PRs. |
Would it be more appropriate to add support for block kit stuff, since that exposes some interactivity components? |
Or can you use the existing |
See this is still open. You might want to check out slack-block-builder. It makes the process of creating interactive elements and modals more maintainable and declarative. |
See https://slackhq.com/get-more-done-with-message-buttons-5fa5b283a59#.kn5h19a9h
The power of this if integrated with Hubot is immense!
The text was updated successfully, but these errors were encountered: