Custom fallback intents when using confirmation helper
Asked Answered
T

1

2

I'm trying to create custom fallbacks for intents that contain confirmations. Here is the code:

const functions = require('firebase-functions');
const {
    dialogflow,
    Confirmation
} = require('actions-on-google');


const app = dialogflow({
    debug: true,
});

app.intent('vitals-confirmation', (conv, input, confirmation) => {
    conv.ask(new Confirmation(`Great! Have you fainted recently?`));
});

app.intent('vitals-confirmation-fallback', (conv, input, confirmation) => {
    conv.ask(new Confirmation(`Sorry I didn't understand what you said. Did you faint?`));
})

app.intent('S1-confirmation', (conv, input, confirmation) => {
    if (confirmation) {
        conv.ask(new Confirmation(`I have recorded that you have fainted. Have your feet been hurting?`));
    } else {
        conv.ask(new Confirmation(`I have recorded that you have not fainted. Have your feet been hurting?`));
    }
});

My app asks the user if they have fainted in "vitals-confirmation" and the user is expected to answer with a yes or no type answer that will be identified by the confirmation helper, if they do this correctly they will go to "S1-confirmation" and will be asked the next question.

However the following is outputted when I respond with an answer that is not a yes/no type answer (for example: "red"):

Sorry, Great! Have you fainted recently?

It seems as though there is a default fallback that responds with "Sorry, [repeats previous text output]" and does not go to a custom fallback intent which I have created (which is my desired result).

Trencherman answered 6/1, 2019 at 17:43 Comment(1)
Can you update your question to show how the Intents are configured?Mcfarlane
M
0

Take a look at the documentation for Confirmation helper of Actions SDK for Node.js.

You have to setup an intent with the actions_intent_CONFIRMATION event in DialogFlow in order to retrieve the user response. My advice is to check how you configured your intents and use this method, otherwise be sure to create the follow-up intents with the desired context lifespan.

Example from documentation:

app.intent('Default Welcome Intent', conv => {
  conv.ask(new Confirmation('Are you sure you want to do that?'))
})

// Create a Dialogflow intent with the `actions_intent_CONFIRMATION` event
app.intent('Get Confirmation', (conv, input, confirmation) => {
  if (confirmation) {
    conv.close(`Great! I'm glad you want to do it!`)
  } else {
    conv.close(`That's okay. Let's not do it now.`)
  }
})
Marzipan answered 22/3, 2019 at 13:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.