我正在尝试使用Microsoft Botframework创建一个Bot,以在AWS Lambda上运行Serverless。 但是我从此Lambda代码中收到以下错误消息:“ BotFrameworkAdapter不是构造函数”:
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
});
}
代码的第一部分更改了Lambda请求和响应格式,以与BotFramework一起使用。 其他代码主要来自Microsoft提供的示例。 环境变量设置正确。
答案 0 :(得分:0)
我使用nodejs模板创建了一个新的无服务器项目,现在它正在运行。