dialogflow / dialogflow-fulfillment-nodejs

Dialogflow agent fulfillment library supporting v1&v2, 8 platforms, and text, card, image, suggestion, custom responses
Apache License 2.0
598 stars 281 forks source link

Dialogflow agent will not speak inside a function for unknown reason #264

Open marcz2007 opened 5 years ago

marcz2007 commented 5 years ago

I have a Dialogflow agent that is normally able to speak. However, when inside a function (which calls out to the Spotify api), it does not speak anything I write inside an "agent.add()".

What makes it even more strange is that on my Firebase console for the function, the output of the Spotify api call is actually recorded when inside a "console.log". This means that the Spotify api call functions as normal, but the dialogflow agent cannot read out the result of the SPotify api call - and I have no idea why (important code below). [ /**

exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => { const agent = new WebhookClient({request, response});

[ /**

() So in the above code, the user is asked by google if they want a recommendation for an angry song. They say 'yes' which runs this function 'playAngrySong'. A song is selected from a database and the user is told the recommended song e.g "I recommend Suck My Kiss by Red Hot Chili Peppers". From this point in the code onwards (where it says var tempo), the agent does not speak anymore (by text of voice).

The console.log lines are written to the function logs however:

Screenshot 2019-08-06 at 22 35 07

[var analysis = console.log('Analyser Version', data.body.meta.analyzer_version); var temp = console.log('Track tempo', data.body.track.tempo); function logs]

Lastly, Google support sent this in reply to my concern (and have not emailed me back since) - does anyone know what I should do based on their suggestion? Screenshot 2019-08-07 at 11 14 20

I am new to Javascript so have tried adding in the 'async' keyword before the function (as shown in the code here) but I may have been wrong in thinking this was the right way to use it.