TypeError: builder.ChatConnector is not a constructor

TypeError: builder.ChatConnector is not a constructor

我在 Node.js

中制作了一个简单的聊天机器人
var restify = require('restify');
var builder = require('botbuilder');

var botConnectorOptions = {
    appId: '',
    appPassword: ''
}

var connector = new builder.ChatConnector(botConnectorOptions); // error here
var bot = new builder.UniversalBot(connector);

// waterfall method
bot.dialog('/',[
     function (session) {
        builder.Prompts.text(session,'What is your name?');
    },
    function(session,args,next){
        session.send('Hello ' +args.response);
    }

 ]); 



// Setup Restify Server
var server = restify.createServer();

// Handles the bot messages
server.post('/api/messages',connector.listen());

// serving a static web page
server.get('/.*/',restify.serveStatic({
    'directory': '.',
    'default': 'index.html'
}));

server.listen(process.env.port || 3978,function () {
    console.log('%s listening to %s', server.name, server.url); 
});

现在,当我尝试在 VS Code 中使用终端 运行 这个机器人时,它给了我以下错误:

TypeError: builder.ChatConnector is not a constructor

有什么我遗漏的吗?

您使用的代码片段适用于先前版本的 Bot Framework (v3)。您可以从 npm 安装以前的版本来解决这个问题,但我的建议是 start with version 4.

npm install botbuilder@3.15.0

Microsoft Bot Framework SDK V4 was released in September 2018, and since then we have shipped a few dot-release improvements. As announced previously, the V3 SDK is being retired with final long-term support ending on December 31st, 2019. Accordingly, there will be no more development in this repo. Existing V3 bot workloads will continue to run without interruption. We have no plans to disrupt any running workloads. source