AWS Lex - Default slot type has no limits

◇◆丶佛笑我妖孽 提交于 2020-11-29 09:27:25

问题


In AWS Lex, I am using the default AMAZON.Country as a slot type. However, when I interact with the test bot, I can enter any value (for instance "I don't know") and the JSON when I inspect the response says that the value for 'country' is "I don't know".

The purpose of a slot type, is that it limits the answers to existing country names. Not some random sentences. Any idea why I don't get the expected behaviour?


回答1:


"The purpose of a slot type, is that it limits the answers...."

That is not actually true and is a common misconception when starting to develop with Lex.

Experience has taught us that the main purpose of slot types is simply to improve input recognition and fill the slot with what is most expected or desired but it does not limit the values that can fill the slot.

This is why we Lex developers also write parsing and validation code in Lambda to double check the slot values or the inputTranscript ourselves.

It might seem like Lex should do a better job of this for you, (I think we all start out assuming that) but once you start doing your own parsing/validating, you realize how much more control you actually have to make your bot smarter and more natural.


Documentation

Amazon Lex Built-In Slot Types refers Lex developers to Alexa docs.

Amazon Lex supports built-in slot types from the Alexa Skills Kit.
...see Slot Type Reference in the Alexa Skills Kit documentation

There is a warning message in Slot Type Reference in Alexa Skills Kit:

Important: A built-in slot type is not the equivalent of an enumeration. Values outside the list are still returned if recognized by the spoken language understanding system. Although input to the 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.



来源:https://stackoverflow.com/questions/50989732/aws-lex-default-slot-type-has-no-limits

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!