您可以通过Lex控制台或使用AWS SDK添加“Slot capture: failure response”选项。下面是使用AWS CLI添加此选项的代码示例:
1.首先,创建一个JSON文件,用于配置“Slot capture: failure response”选项。以下是示例JSON文件:
{ "intermediate": { "messages": { "failure": { "content": "I'm sorry, I didn't understand. Could you please try again?", "contentType": "PlainText" } } } }
2.使用以下命令将其中间结果(即示例JSON文件)部分添加到您的Bot中的槽中:
aws lex-models put-slot-type --name
例如,如果您的JSON文件名为“slot_failure_response.json”,并且要将选项添加到名为“MySlotType”的槽类型,请运行以下命令:
aws lex-models put-slot-type --name MySlotType --cli-input-json file://slot_failure_response.json
3.现在您已经添加了“Slot capture: failure response”选项。当当前槽的值无法捕获时,此选项将向用户提供自定义错误消息。