DialogFlow应用程序不会在Heroku中部署 [英] DialogFlow app does not get deployed in Heroku

查看:269
本文介绍了DialogFlow应用程序不会在Heroku中部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有使用对话框流程的经验,因此我试图按照这篇youtube教程
来制作一个机器人。现在,当我在 DialogFlow控制台上测试它时,该机器人运行良好,但它不会部署在Heroku上。每当我尝试打开应用程序应该部署到的位置时,我都会继续获取内部服务器错误(曾用于 {speech:,displayText:,source:webhook } 在我应用此之前)。它表示无法加载资源:服务器在控制台中响应状态为500(内部服务器错误)



我尝试了文档,但我使用了Heroku而不是谷歌平台,我不知道我是否正确做事。



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

  -----> Node.js应用检测到
----->创建运行时环境

NPM_CONFIG_LOGLEVEL =错误
NPM_CONFIG_PRODUCTION = true
NODE_VERBOSE = false
NODE_ENV =生产
NODE_MODULES_CACHE = true
---- - >安装二进制文件
engines.node(package.json):4.1.1
engines.npm(package.json):unspecified(使用默认值)

解析节点版本4.1.1 ...
下载并安装节点4.1.1 ...
使用默认的npm版本:2.14.4
----->恢复缓存
跳过缓存恢复(未找到)
----->构建依赖关系
检测到预构建(已存在node_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
accept@1.3.4 / tmp / build_07222934258aa157e39d784f7e60dd1c / digracesion-make-sandwich-9119d54 / node_modules /接受
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-parse r@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_07222 934258aa157e39d784f7e60dd1c / 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 - 完成
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 / b uild_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-化妆夹心9119d54 / node_modu les / 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_modul es / 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
安装任何新模块(package.json)
----->缓存构建
清除以前的节点缓存
保存2个cacheDirectories(默认值):
- node_modules
- bower_components(无需缓存)
----->建立成功!
----->发现过程类型
Procfile声明类型 - > web
----->压缩...
完成:11.5M
----->启动...
发布v3
https://make-sandwich.herokuapp.com/部署到Heroku

请帮我解决这个错误。我已在此发布了代码






另外,我试过在localhost上部署应用程序,并且一直收到这个错误信息:

 错误:在Function.Module的Function.Module._resolveFilename(module.js:536:15)
处找不到模块'js'
。在module.require(module.js:579:17)处使用_load(module.js:466:25)
(require / internal / module.js:11:18)
$ new
查看(C:\ Users \EtoNalangGamitinMo\Downloads\make-sandwich-master\make-sandwich-master\\\
ode_modules\express\lib\view.js:81:14)
在Function.render(C:\ Users \EtoNalangGamitinMo\Downloads\make-sandwich-master\make-sandwich-master\\\
ode_modules\express\lib\application.js:570:12)
在ServerResponse.render(C:\ Users \EtoNalangGamitinMo\Dow nloads\make-sandwich-master\make-sandwich-master\\\
ode_modules\express\lib\response.js:1008:7)
在C:\ Users \EtoNalangGamitinMo\Downloads \make-sandwich-master\make-sandwich-master\index.js:22:11
在Layer.handle [作为handle_request](C:\ Users \EtoNalangGamitinMo\Downloads\make (C:\Users\EtoNalangGamitinMo\):
在下一个(C:\ Users \EtoNalangGamitinMo\下载\make-sandwich-master\make-sandwich-master\\\
ode_modules\express\lib\router\route.js:137:13)


解决方案

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

然而,Heroku需要明确设置这些端点。 GCF希望Heroku支持的 express 类环境。根据Heroku示例,在 https:// github .com / heroku / node-js-getting-started / blob / master / index.js ,你可能需要添加这样的行(我没有测试过)来调用你的makeSandwich函数: p>

  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 包。


I have no experience whatsoever with using dialog flow so I'm trying to follow this youtube tutorial to make a bot. Now, the bot works well when I tested it on the DialogFlow console, but it doesn't get deployed on Heroku. Whenever I try to open the url where the app's supposed to be deployed in, I keep on getting "Internal server error" (this used to be {"speech":"","displayText":"","source":"webhook"} before I applied this). It says "Failed to load resource: the server responded with a status of 500 (Internal Server Error)" in the console.

I tried following the docs here but I used Heroku instead of Google Platform and I'm not sure if I'm doing things right.

This is the current build log I got from the latest build:

-----> 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

Please help me fix this error. I've posted the code here.


additionally, i've tried deploying the app on localhost and i keep getting this error:

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)

解决方案

The problem is that the directions at https://dialogflow.com/docs/getting-started/basic-fulfillment-conversation assume you're using Google's Cloud Functions (GCF). GCF makes it simple to deploy node.js functions without some boilerplate code required to attach those functions to an HTTP endpoint.

Heroku, however, needs to have those endpoints explicitly setup. GCF expects an express-like environment, which is one that Heroku also supports. Based on the barebones Heroku example at https://github.com/heroku/node-js-getting-started/blob/master/index.js, you might need to add lines such as this (which I haven't tested) to invoke your makeSandwich function:

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 }`));

You'll also need to adjust your package.json to make sure it includes the express package.

这篇关于DialogFlow应用程序不会在Heroku中部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆