Search code examples
javascriptnode.jsbotframework

Botframework compile error TypeError: bot.dialog is not a function at Object


Hi I've been stuck on this error for the last couple of days this piece of code is taken from the Microsoft docs and when I run npm start this is the error I get

TypeError: bot.dialog is not a function
    at Object.<anonymous> (C:\Users\Conor\Documents\_repos\Chatbot - All\Backend-Conor\index.js:54:5)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:

Code:

bot.dialog('greetings', [
    // Step 1
    function(session) {
        builder.Prompts.text(session, 'Hi! What is your name?');
    },
    // Step 2
    function(session, results) {
        session.endDialog(`Hello ${ results.response }!`);
    }
]);

If anyone has any idea why I get this error or what Im doing wrong it would be very much appreciated.


Solution

  • This code above is outdated since Microsoft bot framework is pulling support for this SDK. I switched over to SDK 4, Documentation can be found here: https://learn.microsoft.com/en-us/azure/bot-service/?view=azure-bot-service-4.0 and if you haven't migrated your bot over here is how: https://learn.microsoft.com/en-us/azure/bot-service/migration/migration-about?view=azure-bot-service-4.0