BotBuilder TypeError: builder.ConsoleConnector is not a constructor

我与影子孤独终老i 提交于 2019-12-21 15:47:18

问题


I'm following the official quick start of Microsoft Bot Builder(SDK v3) for NodeJs: Create a bot with the Bot Builder SDK for Node.js

1- I made a new project with

npm init

2- then

npm install --save botbuilder

3- then I created a new file "app.js"

var builder = require('botbuilder');

var connector = new builder.ConsoleConnector().listen();
var bot = new builder.UniversalBot(connector, function (session) {
session.send("You said: %s", session.message.text);
});

But when I run "node app.js" the following error is thrown:

var connector = new builder.ConsoleConnector().listen();
            ^

TypeError: builder.ConsoleConnector is not a constructor

Could anyone help me, please?

My project structure:


回答1:


There is a mismatch between the documentation and the latest release of the botbuilder package (version 4.0.6) features / methods. Microsoft has changed some of the legacy features of the botbuilder npm package, but they haven't updated their doc yet!

The JavaScript code which is present in Microsoft's Documentation won't work for the same reason!

Try with the botbuilder package version 3.13.1 , it will work perfectly.

To Install:

npm i -S botbuilder@3.13.1

And your piece of code will work!

Find the snapshots:

Cheers!!



来源:https://stackoverflow.com/questions/52604280/botbuilder-typeerror-builder-consoleconnector-is-not-a-constructor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!