DialogFlow应用程序未部署在Heroku中

时间:2018-01-09 03:31:49

标签: heroku deployment dialogflow

我对使用对话框流没有任何经验,所以我试图关注this youtube tutorial 做一个机器人。现在,当我在DialogFlow console上测试时,机器人运行良好,但它没有部署在Heroku上。每当我尝试打开url where the app's supposed to be deployed in时,我都会继续"Internal server error"(过去{"speech":"","displayText":"","source":"webhook"}之前"Failed to load resource: the server responded with a status of 500 (Internal Server Error)"。它在控制台中显示-----> Node.js app detected -----> Creating runtime environment NPM_CONFIG_LOGLEVEL=error NPM_CONFIG_PRODUCTION=true NODE_VERBOSE=false NODE_ENV=production NODE_MODULES_CACHE=true -----> Installing binaries engines.node (package.json): 4.1.1 engines.npm (package.json): unspecified (use default) Resolving node version 4.1.1... Downloading and installing node 4.1.1... Using default npm version: 2.14.4 -----> Restoring cache Skipping cache restore (not-found) -----> Building dependencies Prebuild detected (node_modules already exists) Rebuilding any native modules ejs@2.5.7 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/ejs express@4.16.2 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/express accepts@1.3.4 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/accepts mime-types@2.1.17 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/mime-types mime-db@1.30.0 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/mime-db negotiator@0.6.1 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/negotiator array-flatten@1.1.1 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/array-flatten body-parser@1.18.2 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/body-parser bytes@3.0.0 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/bytes content-type@1.0.4 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/content-type debug@2.6.9 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/debug ms@2.0.0 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/ms depd@1.1.1 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/depd http-errors@1.6.2 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/http-errors inherits@2.0.3 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/inherits setprototypeof@1.0.3 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/http-errors/node_modules/setprototypeof statuses@1.3.1 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/statuses iconv-lite@0.4.19 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/iconv-lite on-finished@2.3.0 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/on-finished ee-first@1.1.1 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/ee-first qs@6.5.1 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/qs raw-body@2.3.2 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/raw-body unpipe@1.0.0 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/unpipe type-is@1.6.15 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/type-is media-typer@0.3.0 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/media-typer content-disposition@0.5.2 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/content-disposition cookie@0.3.1 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/cookie cookie-signature@1.0.6 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/cookie-signature encodeurl@1.0.1 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/encodeurl escape-html@1.0.3 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/escape-html etag@1.8.1 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/etag finalhandler@1.1.0 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/finalhandler parseurl@1.3.2 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/parseurl fresh@0.5.2 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/fresh merge-descriptors@1.0.1 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/merge-descriptors methods@1.1.2 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/methods path-to-regexp@0.1.7 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/path-to-regexp proxy-addr@2.0.2 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/proxy-addr forwarded@0.1.2 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/forwarded ipaddr.js@1.5.2 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/ipaddr.js range-parser@1.2.0 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/range-parser safe-buffer@5.1.1 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/safe-buffer send@0.16.1 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/send destroy@1.0.4 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/destroy mime@1.4.1 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/mime serve-static@1.13.1 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/serve-static setprototypeof@1.1.0 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/setprototypeof utils-merge@1.0.1 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/utils-merge vary@1.1.2 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/vary node-env-file@0.1.8 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/node-env-file js@0.1.0 /tmp/build_07222934258aa157e39d784f7e60dd1c/digracesion-make-sandwich-9119d54/node_modules/js Installing any new modules (package.json) -----> Caching build Clearing previous node cache Saving 2 cacheDirectories (default): - node_modules - bower_components (nothing to cache) -----> Build succeeded! -----> Discovering process types Procfile declares types -> web -----> Compressing... Done: 11.5M -----> Launching... Released v3 https://make-sandwich.herokuapp.com/ deployed to Heroku

我尝试关注applied this,但我使用的是Heroku而非Google平台,我不确定我是否做得对。

这是我从最新版本获得的当前构建日志:

Error: Cannot find module 'js'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.Module._load (module.js:466:25)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at new View (C:\Users\EtoNalangGamitinMo\Downloads\make-sandwich-master\make-sandwich-master\node_modules\express\lib\view.js:81:14)
    at Function.render (C:\Users\EtoNalangGamitinMo\Downloads\make-sandwich-master\make-sandwich-master\node_modules\express\lib\application.js:570:12)
    at ServerResponse.render (C:\Users\EtoNalangGamitinMo\Downloads\make-sandwich-master\make-sandwich-master\node_modules\express\lib\response.js:1008:7)
    at C:\Users\EtoNalangGamitinMo\Downloads\make-sandwich-master\make-sandwich-master\index.js:22:11
    at Layer.handle [as handle_request] (C:\Users\EtoNalangGamitinMo\Downloads\make-sandwich-master\make-sandwich-master\node_modules\express\lib\router\layer.js:95:5)
    at next (C:\Users\EtoNalangGamitinMo\Downloads\make-sandwich-master\make-sandwich-master\node_modules\express\lib\router\route.js:137:13)

请帮我修复此错误。我发布了docs here

另外,我尝试在localhost上部署应用程序并且我一直收到此错误:

1.Inside package.json, remove ^ from "firebase": "^4.8.1"

1.1 Downgrade Firebase from 4.8.1 to 4.8.0 by changing 4.8.1 to 4.8.0

1.2 End result should look like this: "firebase": "4.8.0"

2. Run npm update in the Project Root. NPM will downgrade Firebase for ya

3. Run ng serve --open to check for compilation errors. There shouldn't be any.

1 个答案:

答案 0 :(得分:1)

问题在于https://dialogflow.com/docs/getting-started/basic-fulfillment-conversation处的路线假设您正在使用Google的云功能(GCF)。 GCF使得部署node.js函数变得简单,而无需将这些函数附加到HTTP端点所需的一些样板代码。

然而,Heroku需要明确设置这些端点。 GCF期望一个类似express的环境,这是Heroku也支持的环境。基于https://github.com/heroku/node-js-getting-started/blob/master/index.js的准系统Heroku示例,您可能需要添加这样的行(我还没有测试过)来调用makeSandwich函数:

const express = require('express')
const PORT = process.env.PORT || 5000

express()
  .use(express.static(path.join(__dirname, 'public')))
  .get('/', (req, res) => exports.makeSandwich( req, res ))
  .listen(PORT, () => console.log(`Listening on ${ PORT }`));

您还需要调整package.json以确保它包含express包。