I have done a Chat-bot using Microsoft Bot Framework. The bot is perfectly running fine on the emulator. However I want to Host it on it to Heroku.
My app.js code:
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');
}
});
I tried the following commands to push it on to Heroku:
- git remote rm heroku
- git init
- Created a file .gitignore and inside it node_modules/
- git add .
- git commit -m "basic bot setup done"
- Procfile and added the code web: node index.js
- heroku create
- heroku git:remote -a app name
- git push heroku master
- heroku open
I have also updated by messaging endpoint to Messaging Endpoint : http://appname.herokuapp.com/api/messages in Bot development Portal.
The build succeed. If I open http://appname.herokuapp.com/api/messages, I am seeing {"code":"MethodNotAllowedError","message":"GET is not allowed"} and on opening {"code":"ResourceNotFound","message":"/ does not exist"}
I am stuck here. I want to have the chat-bot on the page using the I Frame provided by Bot registration portal. How to proceed from here and make the bot working?