How to return to original intent after user says Repeat during an elicit dialog on Alexa using Node js?

Viewed 861

Intents:

IntentA

This is the scenario:

  • U: "Alexa, open myapp"
  • A: "Welcome to myapp" (LaunchHandler)
  • U: "Search routes" (IntentAHandler)
  • A: "From where do you depart?" (IntentAHandler, with addElicitSlotDirective)
  • U: "Repeat" (RepeatHandler)
  • A: "From where do you depart?" (IntentAHandler, with addElicitSlotDirective) <- I can't get to this

I've tried different ways to return to the original intent, but I get this error: INVALID_RESPONSE A valid slot of the intent being processed should be specified for slotToElicit in "Dialog.ElicitSlot" directive

The code from RepeatIntent:

handlerInput.requestEnvelope.request.intent = attributes.temp_IntentA;
return custom.IntentAHandler.handle(handlerInput);

I have no problem repeating the last speech, like when I have the output speech with results. But during a dialog, eliciting, how? Is there a way to do this?

2 Answers

During a multi turn conversation with Dialog Model, the intent remains the same while the slots are getting filled or during the confirmation of intents/slots. Now when the user says "Repeat", Alexa map it to RepeatIntent (unless you have "repeat" as utterance in the same intent). Now what you want is to elicit a slot of a different intent(original intent) from the handler of repeat intent. Unfortunately as of now you can't do this. Only updated intent of same type can be sent with a Dialog.ElicitSlot directive.

Note that you cannot change intents when returning a Dialog directive, so the intent name and set of slots must match the intent sent to your skill.

You will receive an error message if you try to do so.


The solution is to

  1. Save the state and progress made so far with IntentA.
  2. (RepeatIntent or any other intent is called and response is sent)
  3. Re-trigger the original IntentA with an appropriate utterance.
  4. Restore the state and progress made.

You can save the state in sessionAttributes and to re trigger the IntentA you have to provide some utterance that will trigger it. In your case something like

"I would like to depart from {city}"

or just (if it doesn't break your VUI)

"{city}"

This way you the user can switch context in middle of a conversation and comeback easily. Once the intent is re-triggered you can use any Dialog model directives.

Read this blog post for more info about context switching.
More on Dialog Interface here.

I was searching for this and after searching for hours I could not find exactly what I needed. After reading through several posts and articles I got what I needed. I joined together the bits and pieces to implement the Amazon.RepeatIntent by using Request and Response Interceptors. I wrote a blog post on this in details for this. You can check the post here.

Related