如何让 AWS Lex 机器人在意图实现后提示跟进(使用 Lambda)?
How to make AWS Lex bot prompt for followup after intent fulfillment (using Lambda)?
即使在 Intent 的 'Response' 部分中设置了机器人,它也不会显示后续提示。如果选择 'ReturnParametersToClient' 作为 Fulfillment 选项,这将起作用。当 fulfillment 改为 AWS Lambda function 后,就不再出现后续问题了。
例如:
如果我的用户输入
3x10
我有一个 Lambda 函数来执行此计算,return 结果为 Lex 期望的 JSON 格式。因此它显示
30
然后,应该提出后续问题
Would you like me to do another calculation?
用户可以回复的内容
No
据我了解,Intent 编辑器页面中的 'Response' 部分正是我应该能够配置问题 'Would you like me to do another calculation?' 和另一条消息(在 'Wait for user reply' 部分中如果用户的回答是否定的。
是的,一切正常。
你可以做一个或另一个。
(1) 在实现意图时在 Lex 控制台中设置响应。
或者 (2) 在实现意图时在 Lambda 中构建您自己的响应。
使用 Lambda 函数可以让您更好地控制您的机器人,并让您响应更动态和定制的消息。
因此,如果您转而使用 Lambda,则必须在实现意图时自行创建该响应。对于 yes/no 类型的问题,您可能希望使用 confirmIntent
。
查看 Lambda-Lex Response Format(在页面中途确认意图)
ConfirmIntent — Informs Amazon Lex that the user is expected to give a yes or no answer to confirm or deny the current intent.
将该响应作为 confirmIntent 发送将如下所示:
"dialogAction": {
"type": "ConfirmIntent",
"message": {
"contentType": "PlainText",
"content": "Would you like me to do another calculation?"
},
"intentName": "intent-name",
"slots": {
"slot-name": "value",
"slot-name": "value",
"slot-name": "value"
},
}
然后您的 Lambda 需要处理该问题的答案。
用户的答案将返回到相同的意图并且 confirmationStatus
将是:
None
- 未使用 confirmIntent
Confirmed
- 用户对 confirmIntent 问题
说 'yes'
Denied
- 用户对 confirmIntent 问题
说 'no'
查看页面顶部附近相同的link,了解 Lex 到 Lambda 输入事件的格式。
提示:
您可以改为使用 close
消息来实现意图,然后向用户询问 "How else may I help you?"
然后用户可以立即提出另一个计算,而不必在每个计算问题之前都说是或否。
即使在 Intent 的 'Response' 部分中设置了机器人,它也不会显示后续提示。如果选择 'ReturnParametersToClient' 作为 Fulfillment 选项,这将起作用。当 fulfillment 改为 AWS Lambda function 后,就不再出现后续问题了。
例如: 如果我的用户输入
3x10
我有一个 Lambda 函数来执行此计算,return 结果为 Lex 期望的 JSON 格式。因此它显示
30
然后,应该提出后续问题
Would you like me to do another calculation?
用户可以回复的内容
No
据我了解,Intent 编辑器页面中的 'Response' 部分正是我应该能够配置问题 'Would you like me to do another calculation?' 和另一条消息(在 'Wait for user reply' 部分中如果用户的回答是否定的。
是的,一切正常。
你可以做一个或另一个。
(1) 在实现意图时在 Lex 控制台中设置响应。
或者 (2) 在实现意图时在 Lambda 中构建您自己的响应。
使用 Lambda 函数可以让您更好地控制您的机器人,并让您响应更动态和定制的消息。
因此,如果您转而使用 Lambda,则必须在实现意图时自行创建该响应。对于 yes/no 类型的问题,您可能希望使用 confirmIntent
。
查看 Lambda-Lex Response Format(在页面中途确认意图)
ConfirmIntent — Informs Amazon Lex that the user is expected to give a yes or no answer to confirm or deny the current intent.
将该响应作为 confirmIntent 发送将如下所示:
"dialogAction": {
"type": "ConfirmIntent",
"message": {
"contentType": "PlainText",
"content": "Would you like me to do another calculation?"
},
"intentName": "intent-name",
"slots": {
"slot-name": "value",
"slot-name": "value",
"slot-name": "value"
},
}
然后您的 Lambda 需要处理该问题的答案。
用户的答案将返回到相同的意图并且 confirmationStatus
将是:
None
- 未使用 confirmIntent
Confirmed
- 用户对 confirmIntent 问题
说 'yes'
Denied
- 用户对 confirmIntent 问题
查看页面顶部附近相同的link,了解 Lex 到 Lambda 输入事件的格式。
提示:
您可以改为使用 close
消息来实现意图,然后向用户询问 "How else may I help you?"
然后用户可以立即提出另一个计算,而不必在每个计算问题之前都说是或否。