Using my gmail account I created an actions project in google console -> then created the intents in the dialogflow agent-> then enabled the webhook for the intents, then I included the server path where my webservice(written in node.js
) is hosted under the fulfillment
button available in Dialog flow agent.
But the webservice hosted on my server is not at all getting called. If I call the same webservice from the browser its getting called.
I am getting this below log in actions console:
"Webhook call failed. Error: Webhook response was empty."
- Code written in node js (created on my server) - - In fulfillment of dialogflow I entered "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);
});