我目前正在研究使用Dialogflow构建聊天机器人的解决方案。在创建原型的过程中,我决定将我的GitHub存储库托管在heroku上。
但是,在这种情况下,如果我想使用 dialogflow-fillfillment库并在Nodejs中表达 ,它将无法正常工作。
请参见下面的代码
'use strict';
const { WebhookClient, Card, Suggestion } = require('dialogflow-fulfillment');
const express = require('express');
const app = express();
app.use( express.json() );
app.get('/', (req, res) => processWebhook( req, res ));
app.listen(process.env.PORT || 3000, () => console.log('App listening on port 3000!'));
var processWebhook = function( request, response ){
const agent = new WebhookClient({ request, response });
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
response.send('Hello World');
};
这是package.json文件
{
"name": "FAQbot",
"description": "",
"version": "0.0.1",
"private": true,
"license": "",
"author": "",
"engines": {
"node": ">=6.0"
},
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"express": "^4.16.3",
"dialogflow": "^0.5.0",
"dialogflow-fulfillment": "^0.5.0"
}
}
这就是heroku日志的样子:
2019-03-08T12:20:28.401862+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:649:15)
2019-03-08T12:20:28.401864+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:575:25)
2019-03-08T12:20:28.401865+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:705:19)
2019-03-08T12:20:28.401866+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:14:16)
2019-03-08T12:20:28.401868+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:16:34)
2019-03-08T12:20:28.401869+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:799:30)
2019-03-08T12:20:28.401871+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:810:10)
2019-03-08T12:20:28.401872+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:666:32)
2019-03-08T12:20:28.401873+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:606:12)
2019-03-08T12:20:28.401875+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:598:3)
dialogflow-fillfillment库仅在Firebase环境上工作吗?