I've developed a bot that calls a prompt dialog based menu at the beginning of the conversation.
Dialog call used on the Message Controller:
await Conversation.SendAsync(activity, () => new Dialogs.CustomBellaHelp());
The problem is when I execute it over the Bot Emulator prompt dialog options are properly addressed by the code.
However, when I execute it over Direct Channel prompt dialog options "leak" from the dialog code and move to the Root dialog which invokes LUIS to manage the menu options.
Thoughts on how to avoid that?
Thx!
I think you may be misunderstanding the purpose of Conversation.SendAsync()
. The MakeRoot delegate isn't a function to navigate to whatever dialog you want. It's only called at the start of the conversation and it's used to create the conversation's root dialog. If a conversation is already underway, Conversation.SendAsync()
sends the activity to whatever dialog is on top of the stack and the MakeRoot delegate is ignored. You can read more about dialogs and conversation flow here: https://docs.microsoft.com/en-us/azure/bot-service/bot-service-design-conversation-flow?view=azure-bot-service-3.0
If you want to start a dialog in the middle of a conversation you should do it from within another dialog and not from your messages controller. A typical way of doing this is to use context.Forward()
: https://docs.microsoft.com/en-us/azure/bot-service/dotnet/bot-builder-dotnet-manage-conversation-flow?view=azure-bot-service-3.0#invoke-the-new-order-dialog
As far as why Direct Line behaves differently from the emulator, you have to understand that events like conversationUpdate are channel-specific and may behave in unexpected ways on different channels.