Peter234
Peter234

Reputation: 1052

Amazon Alexa hierarchical dialog

I'm playing with the Amazon Alexa SDK and I'm programming my first skill. My goal is to programm a dialog like this:

  1. Where do you live?
  2. How long have you been living there?

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.

Upvotes: 0

Views: 359

Answers (3)

Warren Blackwell
Warren Blackwell

Reputation: 11

Bill is 100 percent correct fix your slot values as he recommended and the flow should work correctly . I did somewhat the same in skill MedTime if you wish to give it a try and provide me some feedback. I will be glad to work with you on building skills for Alexa.

Upvotes: 0

Ron Lisle
Ron Lisle

Reputation: 1164

I think Bill's answer is the best solution. Yes, you can use multiple questions, but the 2nd question needs to have the response information passed to it by the first response. You can do this using a DB such as DynamoDB keyed to the user's ID, but I think it is much easier to pass it in the session.

Upvotes: 0

Bill
Bill

Reputation: 1257

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.

Upvotes: 1

Related Questions