Subrata Sarkar
Subrata Sarkar

Reputation: 3064

What is the best practice to avoid utterance conflicts in an Alexa Skill

In the screenshot below, I have got an utterance conflict, which is obvious because I am using similar patterns of samples in both the utterances.

enter image description here

My question is, the skill I am developing requires similar kind of patterns in multiple utterances and I cannot force users to say something like “Yes I want to continue”, or “I want to store…”, something like this.

In such a scenario what is the best practice to avoid utterance conflicts and that too having the multiple similar patterns?

I can use a single utterance and based on what a user says, I can decide what to do.

Here is an example of what I have in my mind:

User says something against {note} In the skill I check this:

if(this$inputs.note.value === "no") {
  // auto route to stop intent
} else if(this$inputs.note.value === "yes") {
  // stays inside the same intent
} else {
  // does the database stuff and saves the value.
  // then asks the user whether he wants to continue
}

The above loop continues until the user says “no”.

But is this the right way to do it? If not, what is the best practice? Please suggest.

Upvotes: 0

Views: 704

Answers (1)

Jonathan Porter
Jonathan Porter

Reputation: 1556

The issue is really that for those two intents you have slots with no context around them. I'm also assuming you're using these slots as catch-all slots meaning you want to capture everything the person says.

From experience: this is very difficult/annoying to implement and will not result in a good user experience.

For the HaveMoreNotesIntent what you want to do is have a separate YesIntent and NoIntent and then route the user to the correct function/intent based on the intent history (aka context). You'll have to just enable this in your config file.

YesIntent() {
  console.log(this.$user.$context.prev[0].request.intent);
  // Check if last intent was either of the following
  if (
    ['TutorialState.TutorialStartIntent', 'TutorialLearnIntent'].includes(
      this.$user.$context.prev[0].request.intent
    )
  ) {
    return this.toStateIntent('TutorialState', 'TutorialTrainIntent');
  } else {
    return this.toStateIntent('TutorialState', 'TutorialLearnIntent');
  }
}

OR if you are inside a state you can have yes and no intents inside that state that will only work in that state.

ISPBuyState: {
  async _buySpecificPack() {
    console.log('_buySpecificPack');
    this.$speech.addText(
      'Right now I have a "sports expansion pack". Would you like to hear more about it?'
    );
    return this.ask(this.$speech);
  },
  async YesIntent() {
    console.log('ISPBuyState.YesIntent');
    this.$session.$data.productReferenceName = 'sports';
    return this.toStatelessIntent('buy_intent');
  },
  async NoIntent() {
    console.log('ISPBuyState.NoIntent');
    return this.toStatelessIntent('LAUNCH');
  },
  async CancelIntent() {
    console.log('ISPBuyState.CancelIntent()');
    return this.toStatelessIntent('LAUNCH');
  }
}

I hope this helps!

Upvotes: 1

Related Questions