使用我的Gmail帐户我在谷歌控制台创建了一个动作项目 - >然后在dialogflow代理中创建了意图 - >然后启用了webhook的意图,然后我包含了我的webservice(写在 node.js
中)托管在其下的服务器路径Dialog流代理中提供了 fulfillment
按钮 .
但是我的服务器上托管的webservice根本没有被调用 . 如果我从浏览器调用相同的Web服务,则会调用它 .
我在登录操作控制台下面得到这个:
“Webhook调用失败 . 错误:Webhook响应为空 . ”
- 用节点js编写的代码(在我的服务器上创建) - - 为了完成对话流,我输入了“https://DomainNameWhereXXXPortIsLocated " with version as " v2” - -
app.js - -
var express = require('express')
, https = require('https')
, fs = require('fs')
, path = require('path');
var app = express();
var bodyParser = require('body-parser');
const {actionssdk,Image,} = require('actions-on-google');
const app2 = actionssdk();
//to display in console
app.get('*' , function (req, res, next) {
console.log('Request URL:', req.originalUrl)
next();
});
//intents created in my dialogflow
app2.intent('favourite_Color',function (conv, {color}) {
var luckyNumber = color.length;
conv.close('This is our lucky number - ' + luckyNumber);
});
app2.intent('call',function (conv, {contacts}) {
console.log(contacts);
console.log("call intent is triggered");
conv.close('You are trying depu to call this person - ' + contacts);
app.use(bodyParser.json(),app2).listen(3000);
var options = {
key:fs.readFileSync(pathIncluded),
cert:fs.readFileSync(pathIncluded)
};
//this is the port I am trying to listen
https.createServer(options, app).listen(xxx, function(){
console.log('Express server listening on port ' + xxx);
});