Amazon Lex在任何响应上接受ConfirmIntent [英] Amazon Lex accepting ConfirmIntent on any response

查看:88
本文介绍了Amazon Lex在任何响应上接受ConfirmIntent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆