2017-07-21 5 views
0

GoogleのNLP API.AIインターフェイス用の簡単なWebフックの実装に慣れています。 node.jsを使用してHerokuをサーバーとして使用したい問題は、私がHerokuでコードをビルドして展開することができますが、実行がすぐに失敗することです。私は、コードの多くの異なるバージョンを試してみましたが、でも、このコードしているビルドログ(「本名」アプリがテストしないで、私はこの記事のためにそれを変更することに注意してください)シンプルなAPI.AI node.js WebhookがHerokuでクラッシュする

[...] 
2017-07-21T13:28:57.000000+00:00 app[api]: Build succeeded 
2017-07-21T13:29:07.012028+00:00 heroku[web.1]: Starting process with command `npm start` 
2017-07-21T13:29:10.516218+00:00 app[web.1]: 
2017-07-21T13:29:10.516234+00:00 app[web.1]: > [email protected] start /app 
2017-07-21T13:29:10.516235+00:00 app[web.1]: > node app.js 
2017-07-21T13:29:10.516236+00:00 app[web.1]: 
2017-07-21T13:29:11.076809+00:00 heroku[web.1]: State changed from starting to crashed 

から

エキスほとんど何も実行に失敗するために削減されます。ここで

は私app.jsです:

'use strict'; 

process.env.DEBUG = 'actions-on-google:*'; 
const ApiAiApp = require('actions-on-google').ApiAiApp; 

const test = function(request, response) { 
// todo 
}; 

module.exports = { 
    test 
}; 

そして、これはpackage.jsonファイルである:私は正しいセットアップを見つけた検索のログ後

{ 
    "name": "test", 
    "description": "virtual scrum master", 
    "version": "0.0.3", 
    "private": true, 
    "license": "Apache Version 2.0", 
    "author": "Google Inc.", 
    "scripts": { 
    "lint": "semistandard --fix \"**/*.js\"", 
    "start": "node app.js", 
    "monitor": "nodemon app.js", 
    "deploy": "gcloud app deploy" 
    }, 
    "engines": { 
    "node": "6.11.1" 
    }, 
    "dependencies": { 
    "actions-on-google": "^1.0.0"  
    }, 
    "devDependencies": { 
    "semistandard": "^9.1.0" 
    } 
} 

答えて

0

。ここで

正しいapp.jsコードです:

'use strict'; 

process.env.DEBUG = 'actions-on-google:*'; 
let Assistant = require('actions-on-google').ApiAiAssistant; 
let bodyParser = require('body-parser'); 

let app = express(); 
app.use(bodyParser.json({type: 'application/json'})); 

app.post('/', function (req, res) { 

// Todo 

}); 

if (module === require.main) { 
    // Start the server 
    let server = app.listen(process.env.PORT || 8080, function() { 
    let port = server.address().port; 
    console.log('App listening on port %s', port); 
    }); 
} 

module.exports = app; 
関連する問題