I'm playing with the Amazon Alexa SDK and I'm programming my first skill. My goal is to programm a dialog like this:
The problem is that I can answer the question number one with keywords from the second question and then Alexa assumes that I answered to the second question and will provide me the answer for question number two. Is there a way to prevent this?
I know I could use session attributes but this looks rather hacky to me...
Thanks for your help =)
PS: I'm using flask-ask for my Alexa Skill.
There are a few ways you could structure this dialog. The first way, similar to what you're doing currently, is to use a series of single turn dialogs. My guess is that you're not using the right slot types in your existing interaction model, which is why the wrong intents are matched.
If I were using a single turn approach, I'd have two intents.
The first intent would match responses to the question "Where do you live?"
Intent: GetAddressCity
Utterance 1: {AMAZON.US_CITY}
Utterance 2: I live in {AMAZON.US_CITY}
The second would match responses to the question "How long have you been living there?"
Intent: GetAddressDuration
Utterance 1: {AMAZON.NUMBER}
Utterance 2: {AMAZON.NUMBER} years
Utterance 3: For {AMAZON.NUMBER} years
A different approach altogether (and one that I'd likely use in this situation) would be to structure the conversation using a Multi-turn Dialog. This approach would define a single intent, with multiple required slot values.
Intent: GetLivingInfo
Utterance 1: I live in {AMAZON.US_CITY}
Utterance 2: I've lived in {AMAZON.US_CITY} for {AMAZON.NUMBER} years
One intent, with two required slots. If the user says I live in Boston, Utterance 1
will match, and Alexa will respond with a prompt asking for the number of years they've lived there. Look into Multi-turn Dialogs for more details.