( Alexa ) Is it possible to get the response in same Intent Handler?

202 Views Asked by At

I have a custom Alexa Skill similar to some Q&A skill , in which I'm asking the user for a response (say option_1, option_2, option_3), but when the user responds with one of these asked options a different intent (say ruleIntent) is triggered because the option text is somewhat similar to its utterances.

I think it is not a good design if more than one IntentHandler is triggered for same( or similar) phrase, but then I don't know the text of options in advance to avoid this (or what the user is going to speak out as the answer of asked question). What if I can somehow maintain the context of user's response, I think that will be one of the solutions.

Example : -

1.User : Start a Science test  {Invokes testIntent }.
2.Alexa : Okay, but before starting do you want to know the rules. Please answer in Yes or No. { response generated from testIntentHandler}
3.User : Yes { invokes many intents }

In line 3 even if I hard-code this to a Intent (say ruleIntent) , then what will happen if some question contains its options as Yes or No. How will I differentiate that and map that to the response of asked question.

2

There are 2 best solutions below

0
On

One way to deal with this is to track the state using persistent or session attributes.

You can do a check of the state in the canhandle method to route the user to appropriate test intent

0
On

One way to solve this could be to use Dialogs. You can use auto delegation for dialogs

Enable auto delegation, either for the entire skill or for specific intents. In this case, Alexa completes all of the dialog steps based on your dialog model. Alexa sends your skill a single IntentRequest when the dialog is complete

Delegate the Dialog to Alexa