Amazon Lex在任何响应上接受ConfirmIntent

编程入门 行业动态 更新时间:2024-10-11 17:20:12
本文介绍了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

本文发布于:2023-11-28 05:58:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641205.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Amazon   Lex   ConfirmIntent

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!