简体   繁体   中英

Alexa custom intent accepts values which are not stored in the possible slot.values that should trigger it

I have an intent that gets triggered if the user asks Alexa to play one of the radios that I have provided in the JSON file for the slot {radio} on the Alexa console. However, if the user asks Alexa to play "random_english_words", the intent works too.
To simplify here's what happens:

-User: Alexa play A better radio  
-Alexa: I will play A better radio  
=> Alexa does her job just fine.  
-User: Alexa play what the Movie  
-Alexa: I will play what the Movie  

Alexa should send an error because "what the Movie" is not a possible radio name in the radio_slot values. But wait this gets even weirder.

User: Alexa play aenjaejfn  
Alexa: There was a problem with the requested skill's response 

Alexa does her job fine since aenjaejfn is NOT a possible radio name in the radio_slot values.

So I have two questions:

  1. Aren't intents which use slots supposed to be triggered only if a slot.value provided by the user is valid?
  2. Why is Alexa accepting "What the Movie" and not "aenjaejfn" , after all both of them are not radio_name and should not trigger the intent in the first place.

When you create a custom slot type, a key concept to understand is that this is training data for Alexa's NLP (natural language processing). The values you provide are NOT a strict enum or array that limit what the user can say. This has two implications

1) words and phrases not in your slot values will be passed to you,

2) your code needs to perform any validation you require if what's said is unknown.

Since you know the acceptable values for that slot, always perform a slot-value validation on your code. In this way when you get something like "aenjaejfn" or something which you dont support, you can always politely respond back like

"Sorry I didn't understand, can you repeat"

or

"Sorry we dont have aenjaejfn in our list. can you please select something from [give some samples from your list]"

More info here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM