4

What would be the best way of accessing the previous conversation details when Dialogflow maps the input to a fallback intent?

We'd like to steer the user back into the right direction by re-prompting the last suggestion chips that were given.

The way we do it now is by manually saving the last suggestions and manually resetting them if the conversation is progressing to new intent. Not optimal and error prone.

It would be good if all fallback intents contained the "last intent/response" information.

I also can't find the isFallback properety on the DialogflowConversation object in the AoG SDK. So we're not able to reliably implement logic in the middleware handler. The isFallback property would be very useful to have access to on the conversation object in intent handler functions.

Any best practices for reliably setting and resetting a memory of last conversation for usage in case of fallback?

Sairaj Sawant
  • 1,842
  • 1
  • 12
  • 16
Dennis Alund
  • 2,916
  • 1
  • 13
  • 34

2 Answers2

1

You can save all your current intent response details in a new output context. Fetch that previous intent response from the previous intent output context and the use that data to create a new response for the fallback intent.

Satish Pandey
  • 335
  • 2
  • 8
  • Additionally, you can access the isFallback property in `conv.body.queryResult.intent.isFallback` – Tlaquetzal Aug 05 '19 at 17:52
  • Thanks for the ideas Satish, the output context pattern is similar to how we're solving it now. We still need to clear or over-write it whenever the conversation successfully moves forward. So we're using middleware to check if we should keep remembering the suggestions. – Dennis Alund Aug 09 '19 at 09:47
  • @Tlaquetzal thanks for the thoughts, the `isFallback` property is adressed in the original question. It's not accessible on the `DialogflowConversation` object when using the SDK, as mentioned. – Dennis Alund Aug 09 '19 at 09:49
  • 1
    @DennisAlund I meant with my response that `isFallback` is accesible from the DialogflowConversation object. I have tried it myself with the code I provided. I tried it with the fallback intent as well: `app.intent('Default Fallback Intent', (conv) => {conv.close(conv.body.queryResult.intent.isFallback ? 'detected!' : 'not detected');});`. You can see how this is possible following this route in the documentation DialogflowConversion -> body -> queryResult -> intent -> isFallback – Tlaquetzal Aug 09 '19 at 13:49
  • I totally missed that! Thanks for pointing that out. If you want to formulate it as an answer post then I'll accept it. – Dennis Alund Aug 10 '19 at 10:23
  • @DennisAlund thanks, I think that this answer is a good answer, maybe @SatishPandey can add the additional information regarding the `isFallback` property – Tlaquetzal Aug 15 '19 at 14:22
  • @DennisAlund Which conversational service are you using? According to https://github.com/actions-on-google/actions-on-google-nodejs, Dialogflow and Actions-on-Google are available. – Satish Pandey Aug 16 '19 at 09:43
  • I'm using that aog SDK. I was just mistaken about whether you could find the `isFallback` property in the payload. I found it in the documentation, as pointed out by @Tlaquetzal (https://actions-on-google.github.io/actions-on-google-nodejs/interfaces/dialogflow_api_v2.googleclouddialogflowv2intent.html#isfallback). Thank you – Dennis Alund Aug 17 '19 at 01:52
-1

how about if you use conv.action or conv.intent to check for your fallback intent? You can create a middleware function that stores all the information you need from each conversation in user.data if it is not a fallback intent and use that in your fallback intent handler.

Reza Nasiri
  • 1,360
  • 1
  • 6
  • 19
  • Could you explain more about how you can tell whether an intent is a fallback intent? In my search I couldn't find any information provided to neither the [intent handler function](https://actions-on-google.github.io/actions-on-google-nodejs/interfaces/actionssdk.actionssdkintenthandler.html) or [middleware function](https://actions-on-google.github.io/actions-on-google-nodejs/interfaces/actionssdk.actionssdkmiddleware.html) that contain that information. – Dennis Alund Dec 11 '18 at 02:31
  • the conv.intent will have a value of 'Default Fallback Intent' and conv.action will be 'input.unknown' – Reza Nasiri Dec 11 '18 at 02:40
  • That's an assumption that you are naming your intent to "Default Fallback Intent". We already have a rule that all fallback intents must contain the word "fallback" so that we can string match them. But if you look in the request payload you can see that there is a property called `isFallback` that I am trying to understand where its equivalent is in the SDK – Dennis Alund Dec 11 '18 at 02:46
  • are you using API V2? I can't see isFallback in the V2 payload – Reza Nasiri Dec 11 '18 at 02:57
  • Yes, it's part of the API payload. https://actions-on-google.github.io/actions-on-google-nodejs/interfaces/dialogflow_api_v2.googleclouddialogflowv2intent.html#isfallback – Dennis Alund Dec 11 '18 at 03:07