2 回答

TA贡献1852条经验 获得超1个赞
在Skill
你可以添加validation
到Slot
:
从 Intent 中选择槽
意图 > yourslot > 验证
Beloe Image 帮助您:

TA贡献1845条经验 获得超8个赞
Alexa 在 Alexa 开发人员控制台中提供的验证更简单,因为它完全由 Alexa 管理。
但实际上您也可以在 lambda 函数上管理所有内容。例如,如果您使用的是 pythonask-sdk-core库,您可以捕获槽值,使用您决定的自定义规则对其进行验证,ElicitSlotDirective如果不满足则返回一个。
示例代码:
if slot_value is not in ['accepted', 'values']:
prompt = "The slot value is invalid, say something else"
return handler_input.response_builder.ask(prompt).add_directive(
ElicitSlotDirective(
slot_to_elicit=slot_name
)).response
这将导致 alexa 向用户询问插槽的另一个值,同时保留有关意图的所有其他信息,例如其他插槽、实际意图、会话 ID...
添加回答
举报