Microsoft Database End Callback

I am developing Chatbot using the Microsoft Bot framework with nodejs and I want to deploy it to aws lambda using a serverless framework, but for this I need to call the lambda callback.

I can’t find how I can get a callback at the end of message processing (stored data and all necessary messages sent).

I tried to simulate the answer and call the callback, but it did not work, the Microsoft bot infrastructure continues to process the message, here is the current handler that I have

'use strict';
const DynamoDbStorage = require('./dynamo-db-storage').DynamoDbStorage
let storage = new DynamoDbStorage()
const connector = require('./channel')(storage)

module.exports.message = (event, context, callback) => {
   connector.verifyBotFramework(context, getHandler(callback));
};

function getHandler(callback) {
   let status = 200
   return {
      status: (code) => { status = code },
      send: (data) => {
         const response = {
             statusCode: 200,
             body: JSON.stringify(data),
         };
         callback(null, response)
     }
   }
 }

And here is my .js channel

const builder = require('botbuilder');
function getChannel(storage) {

    const connector = new builder.ChatConnector({
        appId: process.env.MICROSOFT_APP_ID,
        appPassword: process.env.MICROSOFT_APP_PASSWORD
    });


    const bot = new builder.UniversalBot(connector, {
        storage: storage
    });

    //Bot logic
    //...

    return connector
}

module.exports = getChannel;
+4
source share
1 answer

, , , res. end(), callback.

function getHandler(callback) {
    let status = 200
    return {
        status: (code) => { status = code },
        send: (data) => {
            const response = {
                statusCode: 200,
                body: JSON.stringify(data),
            };
            callback(null, response)
        },
        end: () => callback(null, "end called");
    }
 }
+1

Source: https://habr.com/ru/post/1659368/


All Articles