我已经使用Microsoft Bot Framework完成了Chat-bot。机器人在模拟器上运行良好。不过,我想把它托管到Heroku。Heroku托管Microsoft Bot Framework Chatbot不工作
我app.js代码:
var builder = require('botbuilder');
var restify = require('restify');
var apiairecognizer = require('api-ai-recognizer');
var request = require('request');
//=========================================================
// Bot Setup
//=========================================================
// 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: "xxx", /*changed*/
appPassword: "xxx" /*changed*/
});
server.post('/api/messages', connector.listen());
var bot = new builder.UniversalBot(connector);
var recognizer = new apiairecognizer("xxx");
var intents = new builder.IntentDialog({
recognizers: [recognizer]
});
bot.dialog('/',intents);
intents.matches('Intro',function(session, args){
var fulfillment = builder.EntityRecognizer.findEntity(args.entities, 'fulfillment');
if (fulfillment){
var speech = fulfillment.entity;
session.send(speech);
}else{
session.send('Sorry...not sure how to respond to that');
}
});
intents.matches('Default Fallback Intent',function(session, args){
var fulfillment = builder.EntityRecognizer.findEntity(args.entities, 'fulfillment');
if (fulfillment){
var speech = fulfillment.entity;
session.send(speech);
}else{
session.send('Sorry...not sure how to respond to that');
}
});
我尝试下面的命令来将其推到Heroku上:
- 远程Git RM Heroku的
- 的git的init
- 创建的文件.gitignore和它里面node_modules/
- git add。
- git的承诺-m “基本设置机器人做”
- Procfile和添加的代码 网:节点index.js
- 的Heroku创建
- 的Heroku的git:远程-a应用程序名称
- 混帐推的Heroku掌握
- Heroku的开放
我还通过短信端点消息端点更新:在机器人发展门户http://appname.herokuapp.com/api/messages。
构建成功。如果我打开http://appname.herokuapp.com/api/messages,我看到{"code":"MethodNotAllowedError","message":"GET is not allowed"}
并在开放{"code":"ResourceNotFound","message":"/ does not exist"}
我卡在这里。我想使用Bot注册门户提供的I Frame在页面上使用chat-bot。如何从这里开始并使机器人工作?
由于端点是POST路由,因此会出现get错误。注册门户中的聊天工作? –
您的服务器是否有有效的SSL证书?您的消息端点必须通过HTTPS提供有效的证书。 – nilsw