AWS Lex - 默认插槽类型没有限制

AWS Lex - Default slot type has no limits

在 AWS Lex 中,我使用默认的 AMAZON.Country 作为插槽类型。 但是,当我与测试机器人交互时,我可以输入任何值(例如 "I don't know"),当我检查响应时 JSON 表示 'country' 的值是 "I don't know".

插槽类型的用途是限制对现有国家/地区名称的回答。不是一些随意的句子。知道为什么我没有得到预期的行为吗?

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

事实并非如此,这是开始使用 Lex 进行开发时的一个常见误解。

经验告诉我们,插槽类型的主要目的只是提高输入识别并用最期望或最想要的内容填充插槽,但它不会限制值可以填补空缺。

这就是为什么我们 Lex 开发人员也在 Lambda 中编写解析和验证代码,以自己仔细检查槽值或 inputTranscript。

看起来 Lex 应该为您做得更好,(我想我们都开始假设)但是一旦您开始自己做 parsing/validating,您就会意识到自己的控制力有多大实际上必须让你的机器人更聪明、更自然。


文档

Amazon Lex Built-In Slot Types 将 Lex 开发人员引向 Alexa 文档。

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

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.