It is totally possible.
I ran it 2 ways.
1st - restify service in a docker container - run locally with and ngrok and on AWS
// Create HTTP server.
const server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, () => {
console.log(`\n${server.name} listening to ${server.url}`);
});
async function main(req: WebRequest, context: TurnContext) {
logger.json("Request ->", req.body);
try {
for (const bot of allBots) {
await bot.run(context);
}
} catch (error) {
logger.error("Error processing request[server.ts]");
logger.error(error);
}
}
// Listen for incoming requests.
server.post("/api/messages", (req: WebRequest, res: WebResponse) => {
adapter.processActivity(req, res, async (context: TurnContext) => {
await main(req, context);
});
});
2nd - run on AWS Lambda with Serverless framework. Here is the adapter.
export function lambda(bots: ActivityHandler[]) {
const handler: Handler = async (event: any, _: Context, callback: Callback) => {
logger.json("Event to bot framework: ", event);
const reqWrapper: WebRequest = {
body: event.body,
headers: event.headers,
method: event.method,
query: event.query,
on: (_1: string, ..._2: any[]): any => {
// it needs to be empty
},
};
let statusCode: number;
const resWrapper: WebResponse = {
status: (code: number) => {
statusCode = code;
},
send: (body) => {
callback(null, {statusCode, body});
},
end: () => {
callback(null, { statusCode });
},
};
const adapter = await getAdapter();
adapter.processActivity(reqWrapper, resWrapper, async (context: TurnContext) => {
await main(context, bots);
});
};
return handler;
}