It is not required to use restify
or express
in Bot Framework SDK v4. Any webserver framework that uses a similar WebRequest
and WebResponse
object is compatible with the Bot Framework.
Azure Functions could be used without any modifications. You create a httpTrigger
listening to POST requests. Within the httpTrigger, you call the adapter.processActivity
just like you would do in a 'normal' bot.
const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise<void> {
adapter.processActivity(req as any, context.res as any, async (context) => {
// Route to main dialog.
await myBot.run(context);
});
};
Currently you have to cast the WebRequest object as any
while using Typescript and Azure Functions (or create a shim layer), but this will be solved in 4.9 according to this open pull request.
In order to send proactive notifications, you don't even need this approach. I created an example for a proactive function for Bot Framework SDK v4 in your similar question.