0
//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?

antzshrek
  • 9,276
  • 5
  • 26
  • 43
Greengene Chung
  • 187
  • 1
  • 3
  • 10
  • Have you tried following the steps in these two resources? https://medium.com/@chinnatiptaemkaeo/create-fb-bot-with-heroku-nodejs-microsoft-bot-framework-687bd2893238 https://www.linkedin.com/pulse/deploy-chatbot-microservice-heroku-using-microsoft-bot-harshit-pandey/ Maybe there is an important step that you unintentionally skipped – Fracisco Ponce Gomez Mar 07 '18 at 16:05
  • In fact I did try these resources ,and i got erro message:"There was an error sending this message to your bot: HTTP status code ServiceUnavailablenow".So I go to check the Doc. Now im confusing with the register page of MS.The site in the tutorial dev.botframework.com/bots/new.Is suppose to be the same with dev.botframework.com/bots which is from MS document right ? But now it will automatic redirect to azure platform,and ask me to create new resourse. Is that means i have to apply a payment to use it? – Greengene Chung Mar 08 '18 at 04:45
  • Since i've tried the azure ml service,my free trial is expire now.Any way i've gave it a try.And now i'm stuck in the process of applying.I got Unqualified and the MS support haven't given me a response yet. – Greengene Chung Mar 08 '18 at 04:46
  • 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 Can you share this log file with me? Otherwise, I have no clue. I can create a bot and try to deploy it to Heroku today and see if I get the same errors. – Fracisco Ponce Gomez Mar 12 '18 at 15:41

0 Answers0