带有Azure函数App和NodeJS的Microsoft Bot框架
我正在尝试使用Microsoft Bot Framework构build一个bot。 我打算使用一个带有Http Trigger的Azure函数作为端点。 NodeJS是我select的语言。 我看到使用restify和nodejs的botframework示例,但是没有使用azure函数。 任何人都可以指出我使用azure函数和nodejs开发botframework的例子,或者给我一个例子。
来自Chris Anderson …
https://github.com/christopheranderson/functions-bot-example
您需要将其连接到HTTP触发器,以下代码将进行集成。
var listen = bot.listen(); var response = function (context) { return { send: function (status, message) { var _msg = message ? message : (typeof status !== 'number' ? status : null) var _status = typeof status === 'number' ? status : 200 var res = { status: _status, body: _msg }; context.res = res; context.done(); } } } module.exports = function (context, req) { listen(req, response(context)) }
这个方法是从Chris Anderson的项目https://github.com/christopheranderson/functions-bot-example中借用的,但是包含了与最新的botbuilder一起工作的更新。
更新:在最新的函数运行时,你不需要包装了。 有关详细信息,请参阅https://github.com/vjrantal/bot-sample/commit/fe56a16f6f0286bfe66095eefc417388c1bc1e1c 。