【问题标题】:Microsoft Bot Framework with Azure Functions App and NodeJS带有 Azure Functions 应用程序和 NodeJS 的 Microsoft Bot Framework
【发布时间】:2016-11-07 20:29:58
【问题描述】:

我正在尝试使用 Microsoft Bot Framework 构建机器人。我打算使用带有 Http Trigger 的 Azure 函数作为端点。 NodeJS 是我选择的语言。我看到了带有 restify 和 nodejs 的 botframework 示例,但没有使用 azure 函数。谁能指出一个使用 azure 函数和 nodejs 开发 botframework 的例子,或者给我一个如何做的例子。

【问题讨论】:

    标签: node.js botframework azure-functions


    【解决方案1】:

    来自克里斯·安德森...

    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))
    }
    

    【讨论】:

    • 当我尝试使用上述方法时,出现以下错误
    • 2016-10-15T21:57:30.527 执行函数时出现异常:Functions.spellcheck。 mscorlib: TypeError: res.status is not a function at ChatConnector.dispatch (D:\home\site\wwwroot\spellcheck\node_modules\botbuilder\lib\bots\ChatConnector.js:354:13) 在 ChatConnector.verifyBotFramework (D: \home\site\wwwroot\spellcheck\node_modules\botbuilder\lib\bots\ChatConnector.js:106:18) 在 D:\home\site\wwwroot\spellcheck\node_modules\botbuilder\lib\bots\ChatConnector.js:36 :23
    【解决方案2】:

    您可以在此处看到 https://github.com/vjrantal/bot-sample/commit/e80faefded1c9da9a8b0d69e36497bb221b54709 一个变更集,该变更集为使用 restify 构建的机器人带来了 Azure Functions 兼容性。

    该方法借鉴自 Chris Anderson 在https://github.com/christopheranderson/functions-bot-example 的项目,但包括更新以与最新的机器人构建器一起使用。

    更新:在最新的 Functions 运行时,您不再需要包装。详情请见https://github.com/vjrantal/bot-sample/commit/fe56a16f6f0286bfe66095eefc417388c1bc1e1c

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-11
      • 1970-01-01
      • 2018-08-10
      • 1970-01-01
      • 2016-11-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多