2

I am trying to make a slackbot using botkit and I have written a code however I get the following error when I try to run it-

TypeError: Botkit.slackbot is not a function
    at Object.<anonymous> (E:\Postman Projects\botkitBot\mybot\index.js:27:27)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

This is the part in the code where I get the error:

const controller = Botkit.slackbot({
     debug: false,
     //include "log: false" to disable logging
});

I tried installing yeoman and slack adapter but its still not working. It seems like its not a very common problem as its not acknowledged anywhere. Please do help. It is the very basic step and I can't proceed if this doesn't work.

Aishwarya
  • 31
  • 1
  • 5

1 Answers1

2

check the version of package installed by using this command

npm list botkit

it seems like new version has changed the specification if it shows 4.0 , try to uninstall it

npm uninstall botkit

and install the specific version which has this function in specification

npm install botkit@0.6
Ravi Teja
  • 161
  • 1
  • 8
  • Okay Thanks! I'll try doing this! – Aishwarya May 31 '19 at 11:13
  • So version was not the issue. The code that I had didn't work so I eventually cloned a Git repository provided in one of the YouTube videos and altered that code. Also I used "Dialogflow Middleware" for the integration, incase anyone comes across this same issue, you can try using "Dialogflow Middleware". – Aishwarya Jun 05 '19 at 07:21
  • 1
    It would be better to use Botkit v4 as documented in https://github.com/howdyai/botkit/tree/master/packages/botbuilder-adapter-slack – Naktibalda Jun 06 '19 at 13:24
  • This answer should be the accepted one. I had the same issue and it is indeed relating to the version. – Sean Jan 03 '20 at 07:38
  • here is the version suited : `npm install --save botkit@0.7.4` – pheromix Oct 02 '20 at 08:09