I am trying to create a Bot using the Microsoft Botframework to run Serverless on AWS Lambda. But I get this error message: "BotFrameworkAdapter is not a constructor" from this Lambda code:
export async function main(event, context, callback){
var _status = null;
var _body = null;
var _respond = function (status, body) {
callback(null, {
statusCode: status || 200,
body: body || ''
});
};
var req = {
body: JSON.parse(event.body),
headers: event.headers
};
console.log(req);
var res = {
send: function (status, body) {
_respond(status, body);
},
status: function (status) {
_status = status;
},
write: function (body) {
_body = body;
},
end: function() {
_respond(_status, _body);
}
};
//res.send(200,'{"Test": "Hallo"}');
const path = require('path');
// Import required bot services.
// See https://aka.ms/bot-services to learn more about the different parts of a bot.
const { BotFrameworkAdapter, MemoryStorage, ConversationState } = require('botbuilder');
// Import required bot configuration.
const { BotConfiguration } = require('botframework-config');
// This bot's main dialog.
const { MyBot } = require('./bot');
// Read botFilePath and botFileSecret from .env file
// Note: Ensure you have a .env file and include botFilePath and botFileSecret.
//const ENV_FILE = path.join(__dirname, '.env');
//const env = require('dotenv').config({path: ENV_FILE});
// bot endpoint name as defined in .bot file
// See https://aka.ms/about-bot-file to learn more about .bot file its use and bot configuration .
const DEV_ENVIRONMENT = 'development';
// Create adapter.
// See https://aka.ms/about-bot-adapter to learn more about .bot file its use and bot configuration .
const adapter = new BotFrameworkAdapter({
appId: process.env.microsoftAppID,
appPassword: process.env.microsoftAppPassword
});
}
The first part of the code changes the Lambda reqeuest and response format to work with the BotFramework. The other code is mostly from the Sample provided by Microsoft. The environment variables are set correctly.