How to call dialog inside botframework v4 in net-core?

旧街凉风 提交于 2019-12-11 15:54:36

问题


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!

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.

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.

The issue is:

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.

Thank you for ever help me!


回答1:


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".

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.

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.



来源:https://stackoverflow.com/questions/57612500/how-to-call-dialog-inside-botframework-v4-in-net-core

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!