Closed kevinwritescode closed 6 years ago
It looks like it may be a configuration issue after all. I was able to get it to work once I also allowed "bot" during the oauth "Slack Button" creation, but I wasn't using a bot for anything in my scripts, just slash commands.
I'm not sure if there is any advise on how to set it up if you don't need a bot? Maybe I'm configuring the code improperly to handle a no bot situation.
Had the same issue. After allowing a bot, I'm getting the error:
TypeError: Cannot read property 'replace' of undefined
at Object.<anonymous> (/home/ethan/node_projects/tripkada-slack/node_modules/botkit/lib/SlackBot.js:648:84)
at Object.Botkit.botkit.trigger (/home/ethan/node_projects/tripkada-slack/node_modules/botkit/lib/CoreBot.js:986:49)
at /home/ethan/node_projects/tripkada-slack/node_modules/botkit/lib/CoreBot.js:1090:32
at Object.bot.findConversation (/home/ethan/node_projects/tripkada-slack/node_modules/botkit/lib/Slackbot_worker.js:751:9)
at /home/ethan/node_projects/tripkada-slack/node_modules/botkit/lib/CoreBot.js:1086:21
at next (/home/ethan/node_projects/tripkada-slack/node_modules/ware/lib/index.js:82:27)
at Ware.run (/home/ethan/node_projects/tripkada-slack/node_modules/ware/lib/index.js:88:3)
at Object.Botkit.botkit.receiveMessage (/home/ethan/node_projects/tripkada-slack/node_modules/botkit/lib/CoreBot.js:1081:35)
at handleSlashCommand (/home/ethan/node_projects/tripkada-slack/node_modules/botkit/lib/SlackBot.js:303:22)
at /home/ethan/node_projects/tripkada-slack/node_modules/botkit/lib/SlackBot.js:226:24
Using botkit 0.4.10
. Traced the code: my bot object is undefined.
Should I be spawning a bot? If so, how would I get the bot token if it's an app's bot?
EDIT: Downgraded to 0.4.2, no longer getting the error.
Hey @peterswimm - over here we ran into the same issue. I think this may be due to some of the changes that Slack has made recently.
Since by default, if you enable slash command on your slack app (without a bot user) - you do not ask for the 'bot' permission. And now with the latest Slack change, you cannot add bot permission without a bot user.
It should still be possible to use slash commands without asking for the bot oauth permission (and subsequently adding a bot user) - as slash commands are independent from bot users.
The call to set the user_id of the bot object (which doesn't exist, because we don't have bot oauth permission, see line 5) is here : https://github.com/howdyai/botkit/blob/master/lib/SlackBot.js#L209 I'm also not sure it's really necessary to spawn a bot for a slash command.
Just wanted you to be aware of this. We are looking at the feasibility of submitting a PR for you guys; I think it may be relatively easy to fix.
@peterswimm The latest version has moved braces and the functionallity is broken again
In the original PR the if was closed here https://github.com/howdyai/botkit/pull/699/files#diff-ffa8ec227ea6e9babdfc11d5a71ee29dR223
While currently it's closed before getting bot id making the problem reappear: https://github.com/howdyai/botkit/blob/master/lib/SlackBot.js#L217
i've the same issue with the latest version (0.6.7)
TypeError: Cannot read property 'user_id' of undefined
at /demo/node_modules/botkit/lib/SlackBot.js:220:34
at /demo/node_modules/botkit/lib/SlackBot.js:148:17
at Store.get (/demo/node_modules/botkit/node_modules/jfs/lib/Store.js:203:28)
at Store.get (/demo/node_modules/botkit/node_modules/jfs/lib/Store.js:345:18)
at Object.get (/demo/node_modules/botkit/lib/storage/simple_storage.js:54:26)
at Object.Slackbot.slack_botkit.findTeamById (/demo/node_modules/botkit/lib/SlackBot.js:505:36)
at Object.Slackbot.slack_botkit.findAppropriateTeam (/demo/node_modules/botkit/lib/SlackBot.js:146:22)
at Object.Slackbot.slack_botkit.handleWebhookPayload (/demo/node_modules/botkit/lib/SlackBot.js:188:22)
at /demo/node_modules/botkit/lib/SlackBot.js:134:26
at Layer.handle [as handle_request] (/demo/node_modules/express/lib/router/layer.js:95:5)
at next (/demo/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/demo/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/demo/node_modules/express/lib/router/layer.js:95:5)
at /demo/node_modules/express/lib/router/index.js:281:22
at Function.process_params (/demo/node_modules/express/lib/router/index.js:335:12)
at next (/demo/node_modules/express/lib/router/index.js:275:10)
any updates of the issue? still not resolved in the latest version(0.6.9)
I'm also facing this issue after following the basic slash commands set-up. Any suggested workaround at this time?
I've been having the same issue when trying to initiate a dialog, I issued a PR https://github.com/howdyai/botkit/pull/1281 with changes according to https://github.com/howdyai/botkit/issues/590#issuecomment-351545096
This is quite important for us, we could not find a npm version that implements dialogs on Slack that does not have this issue.
This still hasn't been merged? I can't seem to get Slash commands working because of this.
Also seeing this issue; verified #1281 is fixing this for me as well. Do we have an ETA on getting that PR reviewed/merged?
Work around - We are using another workaround from here https://github.com/howdyai/botkit/issues/108 which led me to do this (solves both problems):
const controller = Botkit.slackbot({
disable_startup_messages: true,
json_file_store: 'tmp/slack.json'
});
// FIX for: https://github.com/howdyai/botkit/issues/108
var bot = controller.spawn({
token: SLACK_TOKEN
});
bot.api.team.info({}, function(err, response) {
if (err) throw new Error(err.stack || JSON.stringify(err));
// FIX2 this is a workaround for https://github.com/howdyai/botkit/issues/590
response.team.bot = {
id: 'boti',
name: 'boti'
};
// END FIX2
controller.saveTeam(response.team, function() {
// ignore
})
});
// END FIX
I'm getting this issue and after trying @mrbar42's fix, I'm getting this error:
Error: "missing_scope"
at bot.api.team.info (/Users/james/projects/emberex-fantasy-football/server/hooks/addSlackBot.hook.js:52:25)
at Request._callback (/Users/james/projects/emberex-fantasy-football/server/node_modules/botkit/lib/Slack_web_api.js:277:24)
at Request.self.callback (/Users/james/projects/emberex-fantasy-football/server/node_modules/request/request.js:185:22)
at Request.emit (events.js:159:13)
at Request.<anonymous> (/Users/james/projects/emberex-fantasy-football/server/node_modules/request/request.js:1157:10)
at Request.emit (events.js:159:13)
at IncomingMessage.<anonymous> (/Users/james/projects/emberex-fantasy-football/server/node_modules/request/request.js:1079:12)
at Object.onceWrapper (events.js:254:19)
at IncomingMessage.emit (events.js:164:20)
at endReadableNT (_stream_readable.js:1054:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
Why is this issue closed? Is that fix supposed to be the right way to get around this user_id
issue? It seems #1281 fixes this issue. I'll just fork until it gets merged.
Is there any fixed for this? Currently encountering this on version 0.4.3
currently using @mrbar42 quick fix.
@justinemar that's a very old botkit, you should upgrade to the latest version and tell us if you are still seeing the trouble
I am experiencing the same issue again while creating a custom slash command. I noticed that the https://github.com/jnv/botkit/commit/f35fe53cbcb9f7ee25e8307cb9e3e6787847b4c4 this fix has been reverted. When I get back this code, it works fine. I am using the latest version of botkit 0.7.4 How do I work around this?
@joanitad Does your Slack application have a bot associated with it?
Adding one should resolve this.
@benbrown : I have a bot user setup. Is that what you mean? if not, how do I know if the slack application has a bot associated with it? I am fairly new to create custom slash command.
Hi @benbrown , could you clarify this, I have a bot user associated with the application and the bot is added to #general.I still get this error.
When attempting to configure a private Slack App, I'm running into issues with
team.bot.user_id
being undefined? Is this a configuration issue with Slack Apps? Theteam
object I get back in that area of code looks like this:I've pasted the error logs below.
I've also added the basic code used for testing.