In the commented area of code if a function call is done.
newGame.call(conv);
It throws the error:"TypeError: Cannot read property 'ask' of undefined at newGame"
And if i replace the comment with the below line of code.
It throws the error:"Error: No response has been set."
app.intent('newGameIntent',newGame);
Here is the code.
const functions = require('firebase-functions');
process.env.DEBUG = 'actions-on-google:*';
const {dialogflow,SimpleResponse} = require('actions-on-google');
const app = dialogflow();
var welcome =(conv)=>{
if(newUser)
{
// how to trigger 'newGameIntent' here
}
else
{
// how to trigger 'LoadGameIntent' here
}
}
var newGame =(conv)=>{
conv.ask(new SimpleResponse({
speech: "Welcome to new game",
text: "Welcome to new game"
}));
}
var loadGame =(conv)=>{
conv.ask(new SimpleResponse({
speech: "Resuming the game for you",
text: "Resuming the game for you"
}));
}
app.intent('Default Welcome Intent',welcome);
app.intent('newGameIntent',newGame);
app.intent('LoadGameIntent',loadGame);
exports.MySample = functions.https.onRequest(app);