0

我正在尝试使用 Microsoft Botframework 创建一个 Bot 以在 AWS Lambda 上运行无服务器。但是我从这个 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 一起使用。其他代码主要来自微软提供的 Sample。环境变量设置正确。

4

1 回答 1

0

我使用 nodejs 模板创建了一个新的无服务器项目,现在它正在运行。

于 2018-10-30T15:39:40.463 回答