//import modules
var builder = require("botbuilder");
var restify = require("restify");
var menu = require("./menuConfig.json");
var express = require("express");
var request = require("request");
var bodyParser = require("body-parser");
I got this part for ms-Azure connector, and builder.UniversalBot()
method for the XXX.dialog()
waterflow pattern.
var server = restify.createServer();
server.listen(process.env.port||process.env.PORT||3978, function () {
console.log('%s listening to %s', server.name, server.url);
})
var connector = new builder.ChatConnector({
appId: process.env.MicrosoftAppId,
appPassword: process.env.MicrosoftAppPassword,
})
server.post('/api/messages', connector.listen());
var bot = new builder.UniversalBot(connector)
Then I added second part for Heroku connect and facebook webhook
var app = express();
app.use(bodyParser.urlencoded({extended:false}));
app.use(bodyParser.json());
app.listen((process.env.PORT||5000));
app.get("/",function(req,
res){
res.send("deployed!");
})
app.get("/webhook",function(req,res){
if(req.query["hub.verify_token"]==="process.env.VERIFICATION_TOKEN"){
console.log("Verified webhook");
res.status(200).send(req.query["hub.challenge"]);
}else{
console.error("Verification failed. The tokens do not match");
res.sendStatus(403)
}
})
var mainMenu = menu.main;
var drinkMenu = menu.drink;
var foodMenu = menu.food;
then rest dialog water flow
bot.dialog("/",[
//default dialog
function(session) {
session.send("welcom!!");
session.replaceDialog('mainMenu');
}
]).triggerAction({matches: /^fistUse$/});
.....etc
this is my package.json
{
"name": "baobao_generator_bot",
"version": "1.0.0",
"description": "create baobao generator bot",
"main": "app.js",
"author": {
"name": "orangelion"
},
"license": "ISC",
"scripts": {
"start": "node app.js"
},
"dependencies": {
"body-parser": "^1.18.2",
"botbuilder": "3.14.0",
"express": "^4.16.2",
"mongoose": "^5.0.9",
"request": "^2.83.0",
"restify": "6.3.4"
}
}
I successfully git pushed my program to heroku. but when I enter heroku open, I got Application error.
Here's the log.
Application Logs
2018-03-07T11:18:55.690635+00:00 app[web.1]: - npm ERR! A complete log of this run can be found in:
2018-03-07T11:18:55.690851+00:00 app[web.1]: - npm ERR! /app/.npm/_logs/2018-03-07T11_18_55_626Z-debug.log
2018-03-07T11:18:55.895218+00:00 heroku[web.1]: - State changed from starting to crashed
2018-03-07T11:18:55.882087+00:00 heroku[web.1]: - Process exited with status 1
2018-03-07T11:46:32.782848+00:00 heroku[router]: - at=error code=H10 desc="App crashed" method=GET path="/" host=immense-falls-15019.herokuapp.com request_id=05e87397-b586-4319-abf6-a51deab37e7b fwd="125.227.255.81" dyno= connect= service= status=503 bytes= protocol=https
2018-03-07T11:46:33.061549+00:00 heroku[router]: - at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=immense-falls-15019.herokuapp.com request_id=5fd3502b-0884-430d-a3a8-9088ab62e2e5 fwd="125.227.255.81" dyno= connect= service= status=503 bytes= protocol=https
2018-03-07T11:47:41.678941+00:00 heroku[router]: - at=error code=H10 desc="App crashed" method=GET path="/" host=immense-falls-15019.herokuapp.com request_id=a203c6a9-b934-4306-823f-00baf6eb6f9d fwd="125.227.255.81" dyno= connect= service= status=503 bytes= protocol=https
2018-03-07T11:47:41.975202+00:00 heroku[router]: - at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=immense-falls-15019.herokuapp.com request_id=22b6bb3e-c5c0-47e6-a4c7-c5b3d1f17b0f fwd="125.227.255.81" dyno= connect= service= status=503 bytes= protocol=https
2018-03-07T11:51:02.393492+00:00 heroku[router]: - at=error code=H10 desc="App crashed" method=GET path="/" host=immense-falls-15019.herokuapp.com request_id=66493288-1511-46dc-9c58-9978ad6ed3d5 fwd="125.227.255.81" dyno= connect= service= status=503 bytes= protocol=https
2018-03-07T11:51:02.708936+00:00 heroku[router]: - at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=immense-falls-15019.herokuapp.com request_id=0f4af933-6501-4966-856a-91e77e504868 fwd="125.227.255.81" dyno= connect= service= status=503 bytes= prot
ocol=https
I've found similar quetion here but didn't get the solution of my problem.
Is there a way not too complicated to run a msbot-frame-work chatbot on heroku? Or I have to choose : give up to use ms-bot-framework or use Azure? And any other cloud service is recommended?