1

I am trying to deploy bot developed using botframework v4. Even if everything seems correct I keep getting "Application has thrown an uncaught exception and is terminated: TypeError: BotFrameworkAdapter is not a constructor"

I also verified that the appId and password is correctly passed to the code below:

const adapter = new BotFrameworkAdapter({
    appId: endpointConfig.appId || process.env.microsoftAppID,
    appPassword: endpointConfig.appPassword || process.env.microsoftAppPassword
});

Could anyone let me know what may be the issue ?

Thanks

1
  • That's an odd one. You have: const { BotFrameworkAdapter } = require('botbuilder'); and you don't have BotFrameworkAdapter defined or instantiated in any other way? You can try updating your package with npm i -s botbuilder. Commented Mar 13, 2019 at 16:27

1 Answer 1

2

After some testing, I believe your issue is likely that you have:

const BotFrameworkAdapter = require('botbuilder');

and not:

const { BotFrameworkAdapter } = require('botbuilder');

The brackets are required around BotFameworkAdapter


If you're not aware as to why (you probably are--this is more for posterity), it's called "destructuring assignment".

Without brackets,

const BotFrameworkAdapter = require('botbuilder')

sets BotFrameworkAdapter to all of botbuilder.

If you do it this way, you could access BotFrameworkAdapter with:

BotFrameworkAdapter.BotFrameworkAdapter


By using

const { BotFrameworkAdapter } = require('botbuilder')

it sets BotFrameworkAdapter to the exported BotFrameworkAdapter class, instead of botbuilder, as a whole.

Note: You could also use:

const BotFrameworkAdapter = require('botbuilder').BotFrameworkAdapter

Sign up to request clarification or add additional context in comments.

5 Comments

The index.js file is the one I copied from one of the template generated from yo generator, so it should be the correct one.
@AshyAshcsi I just ran all 6 templates (3 JS, 3 TS) from yo botbuilder and they all worked. Are you still having issues? With which template? Can you edit your index.js (or equivalent) into your question? You may also want to update your botbuilder generator with npm install -g yo generator-botbuilder
yes, I deleted the bot and copied the files again. It is working fine now. Is there a way to use variables from azure app settings instead of the .bot file ? just like we did for botframework v3.
i am still facing the error in my case as Error: Error occurred while parsing your function triggers. TypeError: BotFrameworkAdapter is not a constructor at Object.<anonymous> (/Users/moblizeit/code-repo/apps/business-card-scanner/functions/lib/index.js:71:19) at Module._compile (internal/modules/cjs/loader.js:688:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10) at Module.load (internal/modules/cjs/loader.js:598:32)
@MoblizeIT Please open a new StackOverflow issue with your problem so you can include your code. Feel free to link me to it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.