-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Slash commands for single teams #108
Comments
I've just encountered this as well. It seems like this is for authentication purposes according to the documentation at https://api.slack.com/slash-commands, but I'm not sure why it can't just load up a team either way or use the verification token in some way. |
I solved this by just saving the team when the bot boots: bot = controller.spawn()
bot.api.team.info {}, (err, response) ->
controller.saveTeam(response.team, ->
console.log "Saved the team information..."
) |
Isn't the team id that's in the message itself enough? But indeed, I've solved it in a similair matter. But it's also a bit weird that it's not documented, because it's kind of a weird error. |
I think the idea is you need to capture a "known good" team ID, which you can do by directly asking the Slack API for it, and compare that with the untrusted team ID coming from the slash command web request. |
well, you don't. The id itself is enough. If i have the next code snippet in the beginning of my app, the thing works. (payload is the payload from the RTM api, but that doesn't really matter, the thing is that there is no real info in the team object) //Fix for https://github.com/howdyai/botkit/issues/108
controller.storage.teams.save({id: payload.team.id, foo:"bar"}, function(err){
if(err)
console.error(err)
}); |
I still can't figure out how this works in combination with express and the slash command. I'm saving the team id like you did @caske33 and finally got rid of the error Can you maybe post an example how it should work? My code: let bot = controller.spawn({
token: process.env.SLACK_TOKEN
}).startRTM()
bot.api.team.info({}, (err, res) => {
controller.storage.teams.save({id: res.team.id}, (err) => {
if (err) {
console.error(err)
}
})
})
controller.setupWebserver(process.env.PORT, (err, webserver) => {
controller.createWebhookEndpoints(controller.webserver)
})
controller.on('james', (bot, message) => {
bot.replyPublic(message,'Everyone can see this part of the slash command')
}) Thanks. |
@timche Can you try |
@caske33 Nope, didn't work :( Just to clarify: |
I've solved the problem. I've just changed Before: controller.on('james', (bot, message) => {
bot.replyPublic(message,'Everyone can see this part of the slash command')
}) After: controller.on('slash_command', (bot, message) => {
bot.replyPublic(message,'Everyone can see this part of the slash command')
}) Now everything is working like expected. Thanks anyway for that issue above, was very helpful. Couldn't figure it out by myself. |
@timche you can check which command was used by checking the value of the |
A bit of clarity for anyone else coming to this issue for a solution.. @timche did find the solution but as there is a missing That, on top of the fact that I assumed this was set similar to So to reiterate @timche's find.. full correct code:
|
Oh wow, sorry @benjamincharity! Didn't realize that a |
No worries @timche. Not so late at night and I probably would have noticed much sooner! 😪 |
I'd second that there isn't a need to check the team id, but it should be checking the slack verify token (I don't think it is currently, maybe I missed it though?). One of the greatest strengths of webhooks over a websocket is that it can be stateless, which makes everything much simpler to deal with at scale. |
This has finally been fixed! @selfcontained thanks to another PR, there is now an option to verify all these requests with the token! |
Has this issue been re-introduced with the new slack interactive messages? I am experiencing this issue when trying to receive a response from an interactive message, and resolved it with @wilg's workaround above: #108 (comment) |
@Jon-Biz No, it has not been re-introduced. Slack message buttons, unlike slash commands, are limited ONLY to apps using the slack button oauth system, so the team should always be present in the datastore. |
👍 Was just coming back here to update my comment :) |
botkit/lib/SlackBot.js
Line 79 in 9ca6d2e
I'm not sure why the check for team is necessary? I think it should be done by the client, not by the lib. What's wrong with having a team that is null?
The text was updated successfully, but these errors were encountered: