I am developing a Chatbot using Microsoft Bot framework with nodejs, and I want to deploy this on aws lambda using serverless framework, but to do that, I need to call the lambda callback.
I cant find how I can have a callback when processing a message ends(saved data and sent all the necessary messages).
I tried to simulate the response, and call the callback, but it didnt work, microsoft bot framework continues processing the message, here is the current handler 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 channel.js
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;