node.js - Microsoft Bot 框架错误 - InternalServerError { "Message": "An error has occurred." }

标签 node.js azure botframework

当我将机器人代码推送到 azure 时,它​​成功了。我在使用 Node app.js 将其推送到 azure 之前测试了它的工作情况

我使用正确的凭据更新了我的 web.config 文件

var builder = require('botbuilder');

var connector = new builder.ConsoleConnector().listen();
var bot = new builder.UniversalBot(connector);
bot.dialog('/', [
    function (session) {
        builder.Prompts.text(session, 'Hi! What is your name?');
    },
    function (session, results) {
        session.send('Hello %s!', results.response);
    }
]);

当我查看 azure 日志时,我收到以下消息

2016-11-17T13:31:12.880 Executing: 'Functions.messages' - Reason: 'This function was programmatically called via the host APIs.'
2016-11-17T13:31:12.880 Function started (Id=22f4fffb-ad0d-4b54-b86f-dd895c098910)
2016-11-17T13:31:12.880 Function completed (Failure, Id=22f4fffb-ad0d-4b54-b86f-dd895c098910)
2016-11-17T13:31:12.880 A ScriptHost error has occurred
2016-11-17T13:31:12.880 Error: Implement me. Unknown stdin file type!
    at process.getStdin [as stdin] (internal/process/stdio.js:82:15)
    at ConsoleConnector.listen (D:\home\site\wwwroot\messages\node_modules\botbuilder\lib\bots\ConsoleConnector.js:11:60)
    at Object.<anonymous> (D:\home\site\wwwroot\messages\index.js:3:48)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
2016-11-17T13:31:12.880 Function started (Id=22f4fffb-ad0d-4b54-b86f-dd895c098910)
2016-11-17T13:31:12.880 Function completed (Failure, Id=22f4fffb-ad0d-4b54-b86f-dd895c098910)
2016-11-17T13:31:12.895 Exception while executing function: Functions.messages. mscorlib: Error: Implement me. Unknown stdin file type!
    at process.getStdin [as stdin] (internal/process/stdio.js:82:15)
    at ConsoleConnector.listen (D:\home\site\wwwroot\messages\node_modules\botbuilder\lib\bots\ConsoleConnector.js:11:60)
    at Object.<anonymous> (D:\home\site\wwwroot\messages\index.js:3:48)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19).

我不知道这是什么或这是如何发生的。

如有任何帮助,我们将不胜感激,

谢谢

最佳答案

我通过以下步骤成功将 Microsoft Bot Framework 部署到 Azure 应用服务。您可以尝试一下吗?

1.注册机器人后,请在 Azure 门户中设置必要的环境变量。

enter image description here

2.使用 npm 获取 Bot BuilderRestify 模块。

npm install --save botbuilder
npm install --save restify

3.创建一个名为app.js的文件,并用几行代码打个招呼。

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 bot
var connector = new builder.ChatConnector({
    appId: process.env.MICROSOFT_APP_ID,
    appPassword: process.env.MICROSOFT_APP_PASSWORD
});
var bot = new builder.UniversalBot(connector);
server.post('/api/messages', connector.listen());

bot.dialog('/', function (session) {
    session.send("Hello World");
});

4.转到 Microsoft Bot Framework 门户并编辑您的机器人详细信息。使用从 Azure 部署生成的端点,并且不要忘记,在使用机器人应用程序模板时,您需要使用 /api/messages 处端点的路径来扩展粘贴的 URL 。您还应该在 URL 中添加 HTTPS 而不是 HTTP 前缀。 enter image description here 5.完成此处的步骤后,您可以测试并验证 Bot Framework 是否可以与 Bot 的 Web 服务进行通信。

enter image description here

希望这有帮助。

关于node.js - Microsoft Bot 框架错误 - InternalServerError { "Message": "An error has occurred." },我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40656540/

相关文章:

mysql - 无法使用 OneToMany 关系添加新记录

javascript - node.js:包括外部 grunt 配置

azure - 部署在 azure 上的机器人突然变得无响应

javascript - 如何从数组中查找具有特定扩展名的文件列表

javascript - node.js:setInterval() 跳过调用

javascript - 在哪里可以获得我登录 Azure 托管应用程序的用户信息

Azure 功能 - 门户代码部署功能正在跳过构建

azure - 三角洲湖 : Partition by version (Azure Databricks)

azure - 如何在azure中部署机器人框架v3机器人?

java - 无法通过 Skype 机器人创建新对话