node.js - Bot Framework WebChat 失败 [405] 不允许使用方法

标签 node.js azure botframework direct-line-botframework

我们使用 Microsoft Bot Framework NodeJS 模板开发了一个聊天机器人。我们部署到 Azure 上。打开输出控制台时,我们看到以下错误:

机器人源代码:

var restify = require('restify');
var builder = require('botbuilder');

// Setup Restify Server
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
   console.log('%s listening to %s', server.name, server.url); 
});

// Create chat connector for communicating with the Bot Framework Service
var connector = new builder.ChatConnector({
    appId:My APP ID',
    appPassword:My APP Password
});

// Listen for messages from users 
server.post('/api/messages', connector.listen());

// Receive messages from the user and respond by echoing each message back (prefixed with 'You said:')
var bot = new builder.UniversalBot(connector, function (session) {
    session.send("You said: %s", session.message.text);
});

包.JSON

{
  "name": "",
  "version": "",
  "dependencies": {
    "botbuilder": "^3.15.0",
    "restify": "^7.2.1"
  }
}

控制台输出

        Error: GET to 'https://state.botframework.com/v3/botstate/webchat/conversations/0560d6047ba0487bd762e7e86a1b6ca/users/A8r4akHZE1Z' failed: [405] Method Not Allowed
    at Request._callback (D:\home\site\wwwroot\node_modules\botbuilder\lib\bots\ChatConnector.js:647:46)
    at Request.self.callback (D:\home\site\wwwroot\node_modules\request\request.js:185:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request. (D:\home\site\wwwroot\node_modules\request\request.js:1157:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage. (D:\home\site\wwwroot\node_modules\request\request.js:1079:12)
    at IncomingMessage.g (events.js:291:16)
    at emitNone (events.js:91:20)

我们尝试了多种解决方法,但没有任何效果。

最佳答案

您似乎正在尝试使用旧的 StateClient,它已被弃用一段时间了。

按照有关如何在 Bot Framework 中保存状态的文档 here for Node.js 进行操作

如果没有有关您的代码的模式详细信息,我无法提供更多帮助

关于node.js - Bot Framework WebChat 失败 [405] 不允许使用方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51823661/

相关文章:

azure - 获取 KeyVault 通过 Powershell AZ CLI 获取访问策略

asp.net-mvc-2 - Windows Azure "Sandbox"

botframework - 在动态对话框中使用 Microsoft bot 框架

node.js - res.redirect() cors在MEAN应用程序中不起作用

node.js - 'when-js' 或基本 amqplibrabbitmqnodejs 教程不起作用

javascript - Node.js exec 调用永远不会调用回调

node.js - 需要在模拟器上使用 node.js 创建自适应卡的示例代码

Node.js、WebSocket 位置问题?

来自 Azure Function 的 C# HttpClient POST 请求(带有用于第三方 API 的授权标记)将被删除 header 和正文

node.js - 机器人框架 : Multi step waterfall