none
Debug the Bot in Visual Studio Code - builder.ChatConnector is not a constructor RRS feed

  • Question

  • I am following this tutorial to make a chatbot in Microsoft Azure and I am stuck with this error
    d:\Bitbucket\factbot\index.js:10
    var connector = useEmulator ? new builder.ChatConnector() : new botbuilder_azure.BotServiceConnector({
                                  ^
    
    TypeError: builder.ChatConnector is not a constructor
        at Object.<anonymous> (d:\Bitbucket\factbot\index.js:10:31)
        at Module._compile (internal/modules/cjs/loader.js:698:14)
        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)
    Waiting for the debugger to disconnect...
    TypeError: builder.ChatConnector is not a constructor
        at Object.<anonymous> (d:\Bitbucket\factbot\index.js:10:31)
        at Module._compile (internal/modules/cjs/loader.js:698:14)
        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)

    the code for index.js is here

    'use strict';
    var builder = require('botbuilder');
    var botbuilder_azure = require('botbuilder-azure');
     
    var useEmulator = true;
    var userName = '';
    var yearsCoding = '';
    var selectedLanguage = '';
     
    var connector = useEmulator ? new builder.ChatConnector() : new botbuilder_azure.BotServiceConnector({
        appId: process.env.MicrosoftAppId,
        appPassword: process.env.MicrosoftAppPassword
    });
     
    var bot = new builder.UniversalBot(connector);
     
    bot.dialog('/', [
     
        function(session) {
            builder.Prompts.text(session, "Hello, and welcome to QnA Factbot! What's your name?");
        },
     
        function(session, results) {
            userName = results.response;
            builder.Prompts.number(session, 'Hi ' + userName + ', how many years have you been writing code?');
        },
     
        function(session, results) {
            yearsCoding = results.response;
            builder.Prompts.choice(session, 'What language do you love the most?', ['C#', 'Python', 'Node.js', 'Visual FoxPro']);
        },
     
        function(session, results) {
            selectedLanguage = results.response.entity;
     
            session.send('Okay, ' + userName + ", I think I've got it:" +
            " You've been writing code for " + yearsCoding + ' years,' +
            ' and prefer to use ' + selectedLanguage + '.');
        }]);
     
    var restify = require('restify');
    var server = restify.createServer();
     
    server.listen(3978, function() {
        console.log('test bot endpoint at http://localhost:3978/api/messages');
    });
     
    server.post('/api/messages', connector.listen());


    I was debugging using node.js in Visual Studio Code.

    Did anyone faced issue in this tutorial also?


    • Moved by Nonki Takahashi Friday, April 3, 2020 7:10 AM not about Small Basic
    Thursday, April 2, 2020 5:47 AM

Answers

All replies