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...
添加回答
舉報