简体   繁体   English

如何在@assistant/conversation 中关闭对话

[英]How to close a conversation in the @assistant/conversation

I have created a cloud function to handle some logics in which i would like to close the conversation.我创建了一个云函数来处理一些我想关闭对话的逻辑。

I have tried the following but i have got an error stating that there is no method named close in the conversation我尝试了以下操作,但出现错误,指出对话中没有名为 close 的方法

conv.close('Thankyou');

I have checked the documentation of @assistant/conversation where there is no method to close a conversation我检查了@assistant/conversation的文档,其中没有关闭对话的方法

在此处输入图片说明

I would like to know how to close a conversation from the cloud function as well as is it possible to use the system scenes in the cloud function for example我想知道如何从云功能中关闭对话以及是否可以使用云功能中的系统场景

To end a conversation in a scene we would transit to the End conversation scene.要在场景中结束对话,我们将过渡到结束对话场景。 Similarly in the cloud function can we use it同样在云函数中我们可以使用它吗

conv.scene.next.name = 'End conversation'

For the custom scene which we create, it works fine but if we try to use the system scenes in the cloud function it fails.对于我们创建的自定义场景,它工作正常,但如果我们尝试在云功能中使用系统场景,它就会失败。

The simplest way to transition to exit directly is to use the special "End Conversation" scene name: actions.page.END_CONVERSATION .直接过渡到退出的最简单方法是使用特殊的“结束对话”场景名称: actions.page.END_CONVERSATION

Another reasonable approach, however, would be to transition to a Scene, and the primary thing that Scene does is transition to ending the conversation.另一种合理的方法,但是,这是过渡到一个场景,场景做的主要事情是过渡到结束对话。 Since you can't transition as part of the Entry message, you'll need to create a condition that is "true".由于您不能作为 Entry 消息的一部分进行转换,因此您需要创建一个“真”条件。

出口场景插图

This may seem like an unnecessary hack, but this isn't as crazy as it sounds - for some Actions, it would make sense to have a common closing and cleanup process, and centralizing them in one logical place makes sense.这似乎是一种不必要的 hack,但这并不像听起来那么疯狂 - 对于某些 Actions,有一个共同的关闭和清理过程是有意义的,并且将它们集中在一个合乎逻辑的地方是有意义的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM