Answered by:
Debug the Bot in Visual Studio Code - builder.ChatConnector is not a constructor

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
-
Hello,
you should ask here: https://docs.microsoft.com/answers/topics/azure-webapps.html
- Proposed as answer by Richard MuellerMVP, Banned Friday, April 3, 2020 9:10 AM
- Marked as answer by Richard MuellerMVP, Banned Saturday, April 11, 2020 12:47 PM
Friday, April 3, 2020 8:34 AM
All replies
-
Sorry,
Your thread should posts on Visual Studio forum. Here is Small Basic forum. Please post your thread on correct forum.
Thank you!
Thursday, April 2, 2020 6:19 AM -
Hi jordantanjunwen, or you should better to ask your question in Microsoft Q&A. Thanks.
Nonki Takahashi
Thursday, April 2, 2020 2:13 PM -
Thursday, April 2, 2020 11:55 PM
-
Hello,
you should ask here: https://docs.microsoft.com/answers/topics/azure-webapps.html
- Proposed as answer by Richard MuellerMVP, Banned Friday, April 3, 2020 9:10 AM
- Marked as answer by Richard MuellerMVP, Banned Saturday, April 11, 2020 12:47 PM
Friday, April 3, 2020 8:34 AM