Amazon Lex在任何响应上接受ConfirmIntent [英] Amazon Lex accepting ConfirmIntent on any response
问题描述
我有一个intent-A
,它由某些用户输入触发.当给用户响应时,我使用了ConfirmIntent
而不是Close
,以便我可以切换/链接另一个意图(让我们说intent-B
).
I have an intent-A
which is triggered by some user input. When the response is given to user I have used ConfirmIntent
instead of Close
so that I can switch/chain another intent (lets say intent-B
).
理想情况下,如果用户键入"yes"
,则应触发意图,而如果用户键入"no"
,则不应触发意图.问题是无论输入什么,都会触发intent-B
.
Ideally if user type "yes"
then intent should be triggered and if user type "no"
then it should not. Problem is that intent-B
is being triggered no matter what I type.
我从此处了解了有关ConfirmIntent
的信息. ,此处和此处.
I have read about ConfirmIntent
from here, here and here.
呼叫代码:
session_attributes = {"confirmationContext": "AutoPopulate"}
return confirm_intent(session_attributes , 'intent-B', slots, 'Do you want to invoke intent-B')
确认意图代码:
def confirm_intent(session_attributes, intent_name, slots, message):
return {
'sessionAttributes': session_attributes,
'dialogAction': {
'type': 'ConfirmIntent',
'intentName': intent_name,
'slots': slots,
'message': {
'contentType': 'PlainText',
'content': message
}
}
}
在日志中,当我键入"no
时,我可以看到confirmationStatus': 'Denied'
",但即使这样,也会调用intent-B
.
In the logs I can see that confirmationStatus': 'Denied'
when I type "no
" but even then intent-B
is being called.
我错过了什么吗?还是这样设计的?
Am I missing something or is it designed this way?
注意:为解决此问题,我在intent-B
NOTE: For workaround I am adding below code in the DialogCodeHook of intent-B
if 'confirmationStatus' in intent_request['currentIntent'] and intent_request['currentIntent']['confirmationStatus'] == 'Denied':
return close("Ok, let me know if you need anything else.", session_attributes)
推荐答案
您正在正确处理此问题.
You are handling this correctly.
将intent-B
传递到confirm_intent
请求中时.您正在告诉Lex将用户响应传递给intent-B
.当用户用"no"
响应时,将正确传递Denied
值.
When you are passing intent-B
into your confirm_intent
request. You are telling Lex to pass the users response to intent-B
. When the user responds with "no"
, the Denied
value is correctly passed on.
或者,您可以在confirm_intent
请求中包含intent-A
.然后,当响应达到intent-A
时,可以在拒绝上使用Close
,在confirmation
上使用Delegate
将流传递到intent-B
.这是更正确的",但会导致额外的计算,因此这是一个折衷方案.
Alternatively, you could have intent-A
in your confirm_intent
request. Then when the response hits intent-A
you can use Close
on denial and Delegate
on confirmation
to pass the flow to intent-B
. This is "more correct" but will result in additional computation, so it's a trade off.
如果您有多个跟进请求,则可以考虑使用ElicitIntent
代替询问用户"What can I help you with?"
.意图带有诸如"nothing"
,"goodbye"
之类的话语的人会得到负面的回应.这是一个稍微不同的用例,可能不适合您.
If you have multiple follow up requests, you could consider using ElicitIntent
to instead ask the user "What can I help you with?"
. Having an an intent with utterances such as "nothing"
, "goodbye"
will catch negative responses. This is a slightly different use case and may not be appropriate for you.
这篇关于Amazon Lex在任何响应上接受ConfirmIntent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!