ReplaceDialogAsync doesn't change ActiveDialog
See original GitHub issueVersion
4.4.4
Describe the bug
After calling ReplaceDialogAsync, if we use an AdaptiveCard with a submit button, the OnEventAsync method should show, on our ActiveDialog property, the value of the new Dialog, but it shows the old Dialog.
For example, you have your MainDialog, which calls StartDialogAsync(nameof(FAQDialog))
.
On your FAQDialog, you call ReplaceDialogAsync(nameof(AnotherDialog))
.
If you use an AdaptiveCard with a Submit button on the “AnotherDialog”, the event caught on the MainDialog (with the function “OnEventAsync”) should show the ActiveDialog as “AnotherDialog”, but shows as “FAQDialog”.
To Reproduce
Steps to reproduce the behavior:
- Create a Virtual Assistant
- Use ReplaceDialogAsync on a Dialog A to Dialog B
- Insert an Adaptive Card with a Submit button on Dialog B
- Click the submit button
- Check the value of the ActiveDialog on the MainDialog
Expected behavior
Active Dialog should have the value of the dialog which replaced the old one.
[bug]
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Botframework V4: ID of active dialog not changing even ...
I need to do a condition depending on the Id of the active dialog something like this. var dc = await _dialogs.CreateContextAsync(turnContext); ...
Read more >DialogContext.ReplaceDialogAsync(String, Object ...
Starts a new dialog and replaces on the stack the currently active dialog with the new one. ... ReplaceDialogAsync(String, Object, CancellationToken) Method.
Read more >DialogContext class
Requests the active dialog to re-prompt the user for input. Constructor Details. DialogContext(DialogSet, DialogContext, DialogState). Creates an new instance ...
Read more >Source File Press 'n' to go to next uncovered line, 'b' for ...
Gets the set of dialogs that can be called from this context. ... Gets the cached <see cref="DialogInstance"/> of the active dialog on...
Read more >Exam AI-102 topic 5 question 14 discussion
You need to ensure that you can dispose of the property when the last active dialog ends. Which scope should you assign to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@tiagodenoronha I hit this issue some time ago.
If I have understood this correctly (I have spent quite a bit of time looking into the code around this tonight), the ActiveDialog value is set when the inner dialog context state is re-hydrated when calling ContinueDialogAsync on the context, which only currently happens within the VA solution when continuing the current dialog (when a MessageActivity is received - https://github.com/microsoft/botframework-solutions/blob/c4ecbadc99d211f8f029c9da7d4899d5de4b287f/templates/Customer-Support-Template/CustomerSupportTemplate/Dialogs/Shared/RouterDialog.cs#L29). Because you are receiving an event, this gets handled within the MainDialog, which means your ActiveDialog will be showing as ‘MainDialog’ at this stage.
I am not totally clear at this point if this is actually bug, or simply a side effect of not continuing the current dialog, which the team may be able to clear up. However, until then I thought it might be useful to show you what I did to workaround this, which was by checking the state value of the ActiveDialog (MainDialog) instance for child dialogs on the stack. I realise it is not the nicest / cleanest solution, but hopefully it helps.
Could it be that it’s the Adaptive Cards that are returning to MainDialog? It might not be related to the ReplaceDialogAsync…