【发布时间】:2018-01-31 08:11:35
【问题描述】:
将机器人从本地 git 存储库部署到 azure - https://docs.microsoft.com/en-us/bot-framework/deploy-bot-local-git
代码:
var restify = require('restify');
var builder = require('botbuilder');
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () { });
// Create the chat connector for communicating with the Bot Framework Service
var connector = new builder.ChatConnector({
appId: "app-id",
appPassword: "app-password"
});
// Listen for messages from users
server.post('/api/messages', connector.listen());
// Create your bot with a function to receive messages from the user
var bot = new builder.UniversalBot(connector, function (session) {
// echo the user's message
session.send("You said: %s", session.message.text);
});
在https://dev.botframework.com 的网络聊天中获取 http 500 错误和消息 -
向您的机器人发送此消息时出错:HTTP 状态代码 InternalServerError
我可以使用 localhost url 和 App Id 和密码从 Bot Framework Emulator 连接到机器人。
也许我需要指定 Web 应用程序是 nodejs?我在应用程序设置中看不到任何有关应用程序入口点或 nodejs 选项的信息。
编辑: 将 "main": "index.js" 更改为 "main": "app.js" 但仍然无法发送测试消息。
EDIT2:我将 web.config 添加到项目中(对建议的代码没有任何更改),之后我在 bot 页面 (http://it-perf-bot.azurewebsites.net/api/messages) 上收到消息 - 由于发生内部服务器错误,该页面无法显示。然后我添加了 IISnode.yml
loggingEnabled: true
devErrorsEnabled: true
并收到此消息 - http://prntscr.com/gc8vww 将机器人推送到天蓝色时记录 - http://prntscr.com/gc8wia,
package.json 文件未指定 node.js 引擎版本约束。
我将"engines":{"node": "8.1.4"} 添加到package.json 并得到
您要查找的资源已被删除、名称已更改或暂时不可用。 我的机器人 - https://github.com/lavandil/skypeBot1。
EDIT3:在进行 edit2 时,我测试了 url http://it-perf-bot.azurewebsites.net/api/messages 并得到不同的警告
您正在查找的页面无法显示,因为正在使用无效的方法(HTTP 动词)。
然后我在 dev.botframework.com 和 Bot Framework Emulator 测试 bot - 将节点版本添加到包 json 后一切正常。感谢回复!
【问题讨论】:
-
如果您仍然遇到问题,请通过以下方式报告此问题:github.com/microsoft/botbuilder/issues/new
标签: node.js azure botframework skype