How to prevent google action from closing the conversation if there is no intent match?

Viewed 262

whenever default fallback intent is triggered 3 times in a row conversation is getting closed with the response, my test app left the conversation. How can i prevent this from happenning and also only exit from the action only when user wants to exit from the action.

2 Answers

The Actions on Google docs mention a conv.data.fallbackCount object, which you can read about in the No-match reprompting subsection:

 app.intent('Default Fallback Intent', (conv) => {

 conv.data.fallbackCount++;

 // Provide two prompts before ending game

 if (conv.data.fallbackCount === 1) {
   conv.contexts.set(DONE_YES_NO_CONTEXT, 5);
   conv.ask('Are you done playing Number Genie?');
 } else {
   conv.close(`Since I'm still having trouble, so I'll stop here. ` +
     `Let’s play again soon.`);
 }

});

Although it's arguably better conversation design to leave this variable alone -- thereby letting the conversation close when the counter increments to three -- you could try resetting conv.data.fallbackCount manually, like:

conv.data.fallbackCount = 0;

At least right now with the new Google Action you can just redirect the user to the current scene again on a NO_MATCH intent.

Basically in your webhook just set:

webhookResponseJson.scene.next.name = webhookRequestJson.scene.name
Related