8

I have two intents that use the same slot types. However, if the input is a random string, Alexa automatically identifies an intent in its JSON request even though it is not part of the utterances. For example, in the example below, if the user input was 'bla bla bla', GetAccountBalance is identified as the intent with no slot value even though it is not part of provided utterances.

What is the way to error-check for these cases and what is the best practice to avoid cases like this when developing the intent schema? Is there a way to create an intent that can handle all random inputs?

Example Schema:

{
  "intents": [
    {
      "intent": "GetAccountBalance",
      "slots": [
        {
          "name": "AccountType",
          "type": "ACCOUNT_TYPE"
        }
      ]
    },
    {
      "intent": "GetAccountNumber",
      "slots": [
        {
          "name": "AccountType",
          "type": "ACCOUNT_TYPE"
        }
      ]
    }
  ]
}

Utterances:

GetAccountBalance what is my account balance for {AccountType} Account
GetAccountBalance what is my balance for {AccountType} Account
GetAccountBalance what is the balance for my {AccountType} Account
GetAccountBalance what is {AccountType} account balance
GetAccountBalance what is my account balance
GetAccountBalance what is account balance
GetAccountBalance what is the account balance
GetAccountBalance what is account balance

GetAccountNumber what is my account number for {AccountType} Account
GetAccountNumber what is my number for {AccountType} Account
GetAccountNumber what is the number for my {AccountType} Account
GetAccountNumber what is {AccountType} account number
GetAccountNumber what is my account number
GetAccountNumber what is account number
GetAccountNumber what is the account number
GetAccountNumber what is account number
skbrhmn
  • 1,124
  • 1
  • 14
  • 36

4 Answers4

3

There is one hack to resolve this problem:

If no any match found(random string) Amazon always take intent with highest no of utterances. So I created one intent 'DidNotUnderstand' and add as many random utterances as I can (Be moderate enough) in result if no any match found alexa will call 'DidNotUnderstand' intent.

Please refer first reply from below link: https://forums.developer.amazon.com/questions/4856/intent-triggering-without-utterance-match.html

Nidhish
  • 91
  • 4
  • You can always have 'Unhandled' handler which will return 'true' from canHandle() function. Then you got to put this handler at the last of parameter values in addRequestHandler() function. – AkshayM Jul 16 '18 at 12:37
2

When developing an Alexa skill, Alexa will always pick an intent to fire even if the user speaks pure gibberish. As far as I'm aware, there isn't a way to set a default / catch-all intent.

In terms of error handling, the following passage from the docs is really important.

Note that a custom slot type is not the equivalent of an enumeration. Values outside the list are still returned if recognised by the spoken language understanding system. Although input to a custom slot type is weighted towards the values in the list, it is not constrained to just the items on the list. Your code still needs to include validation and error checking when using slot values.

The link above also has a few follow up links which dive further into the topic error handling.

user3508122
  • 664
  • 3
  • 10
1

As per the documentation:

The AMAZON.FallbackIntent (available in English (US) only) is triggered when the user's spoken input does not match any of the other intents in the skill. AMAZON.FallbackIntent is matched to an automatically-generated out-of-domain model.

Code snippet:

'AMAZON.FallbackIntent': function (intent, session, response) {
    response.ask("Optimus Prime didn't get that one....","");
}
dd619
  • 5,910
  • 8
  • 35
  • 60
0

A slot with SearchQuery slot type may help you.but it would need some extra phrases with it.like

Fname->where Fname is a slot of type Amazon.SearchQuery

my name is {Fname}

it will work for the example

my name is bffblselsk my name is snfdslnel etc...

visit Amazon.SearchQuery Slot for more referrences....