如何在Net-Core的botframework v4内部调用对话框? [英] How to call dialog inside botframework v4 in net-core?
问题描述
我终于将一个机器人从v3迁移到v4,并且可以正常工作.没有这个社区是不可能的.谢谢大家!
I finally migrated a bot from v3 to v4 and it is working. It wouldn't be possible with out this community. Thank you all!
现在,我试图在我的漫游器中包含对话框.我已经阅读了文档,并研究了github(botframework v4存储库)中的示例,在这种情况下,所有示例始终以对话开头.
Now I am trying to include dialog in my bot. I've read documentation and have studied samples in github (botframework v4 repository), in this case all samples always start with dialog.
我不需要从对话框开始,因为不是所有来自用户的消息都需要对话框.来自用户的大部分消息都称为Luis,足以产生独特的响应.
I don't need to start with dialogs because not all messages from the users require dialog. The most of messages from users call Luis and it is enough to unique response.
问题是:
在某些情况下,我的逻辑确定用户消息需要更多详细信息,然后我需要启动一个对话框以询问更多详细信息.用户发送了几则不需要在同一会话中进行对话的消息后,我不知道如何启动该对话框.
In some cases, my logic identify that user message requires more details, then I need to start a dialog to ask for more detail. I don't know how to start the dialog after user has sent several messages that doesn't require dialogs in the same session.
谢谢您对我的帮助!
推荐答案
您无需使用Dialog处理单回合响应.在您的情况下,您可以处理ActivityHandler
中OnMessageActivityAsync
中的用户输入,针对Luis运行,然后使用SendActivityAsync直接将响应发送回以获取简单的意图,或者在需要时运行dialog.RunAsync
以启动对话框.
You don't need to use Dialog to process single turn responses. In your case you can process the user input in OnMessageActivityAsync
from your ActivityHandler
, run against Luis, then use SendActivityAsync to send response back directly for simple intents, or run dialog.RunAsync
to start a dialog when needed.
您的简单意图没有状态,因此您无需担心先前的消息".
Your simple intents don't have a state, so there is nothing you need to worry about "previous messages".
但是,我个人建议您从处理意图识别和意图处理的父对话框开始.这样,您的意图识别/处理逻辑就可以移出ActivityHandler
了,添加诸如身份验证之类的内容会变得更加容易.
However, I personally would suggest you start with a parent dialog which handles intent identification and intent processing. By doing that your intent identification/processing logic can be moved out of the ActivityHandler
and it's easier to add things like authentication.
这确实需要一些代码.我试图在我的一个项目中简化这种情况,以便机器人开发人员可以专注于他们的业务逻辑.我在 git中心上共享了代码,并提供了一些示例.如果您有兴趣,可以查看一下.
This does require a bit of code though. I tried to simplify this kind of situation in one of my projects so that bot developers can focus on their business logic. I shared the code on git hub with some sample. If you are interested you can check it out.
这篇关于如何在Net-Core的botframework v4内部调用对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!