66using Microsoft . Bot . Builder . Dialogs ;
77using Microsoft . Bot . Builder . Dialogs . Choices ;
88using Microsoft . Bot . Builder . Skills . Auth ;
9- using Microsoft . Bot . Builder . Skills . Dialogs ;
109using Microsoft . Bot . Builder . Skills . Models ;
1110using Microsoft . Bot . Builder . Skills . Models . Manifest ;
1211using Microsoft . Bot . Builder . Solutions ;
1312using Microsoft . Bot . Builder . Solutions . Authentication ;
13+ using Microsoft . Bot . Builder . Solutions . Dialogs ;
1414using Microsoft . Bot . Builder . Solutions . Resources ;
1515using Microsoft . Bot . Schema ;
1616using Microsoft . Recognizers . Text ;
@@ -76,8 +76,8 @@ public SkillDialog(
7676 AddDialog ( authDialog ) ;
7777 }
7878
79- AddDialog ( new WaterfallDialog ( DialogIds . ConfirmFlow , intentSwitching ) ) ;
80- AddDialog ( new ConfirmPrompt ( DialogIds . CancelPrompt ) ) ;
79+ AddDialog ( new WaterfallDialog ( DialogIds . ConfirmSkillSwitchFlow , intentSwitching ) ) ;
80+ AddDialog ( new ConfirmPrompt ( DialogIds . ConfirmSkillSwitchPrompt ) ) ;
8181 }
8282
8383 public async Task < DialogTurnResult > ConfirmIntentSwitch ( WaterfallStepContext sc , CancellationToken cancellationToken )
@@ -86,7 +86,7 @@ public async Task<DialogTurnResult> ConfirmIntentSwitch(WaterfallStepContext sc,
8686 {
8787 var newIntentName = skillSwitchConfirmOption . TargetIntent ;
8888 var intentResponse = string . Format ( CommonStrings . ConfirmSkillSwitch , newIntentName ) ;
89- return await sc . PromptAsync ( DialogIds . CancelPrompt , new PromptOptions ( )
89+ return await sc . PromptAsync ( DialogIds . ConfirmSkillSwitchPrompt , new PromptOptions ( )
9090 {
9191 Prompt = new Activity ( type : ActivityTypes . Message , text : intentResponse , speak : intentResponse ) ,
9292 } ) ;
@@ -109,12 +109,8 @@ public async Task<DialogTurnResult> FinishIntentSwitch(WaterfallStepContext sc,
109109 sc . Context . Activity . Text = skillSwitchConfirmOption . UserInputActivity . Text ;
110110 sc . Context . Activity . Speak = skillSwitchConfirmOption . UserInputActivity . Speak ;
111111
112- // 3) End dialog with target intent
113- var intent = new DispatchIntent ( )
114- {
115- Intent = skillSwitchConfirmOption . TargetIntent ,
116- } ;
117- return await sc . EndDialogAsync ( intent ) ;
112+ // 3) End dialog
113+ return await sc . EndDialogAsync ( true ) ;
118114 }
119115
120116 // Cancel skill switching
@@ -239,7 +235,7 @@ enabling the Skill to perform it's own action identification. */
239235 }
240236 }
241237
242- if ( innerDc . ActiveDialog != null )
238+ if ( innerDc . ActiveDialog ? . Id == DialogIds . ConfirmSkillSwitchPrompt )
243239 {
244240 var result = await base . OnContinueDialogAsync ( innerDc , cancellationToken ) ;
245241
@@ -250,8 +246,14 @@ enabling the Skill to perform it's own action identification. */
250246 else
251247 {
252248 // SkillDialog only truely end when confirm skill switch.
249+ if ( result . Result is bool dispatchResult && dispatchResult )
250+ {
251+ // Restart and redispatch
252+ result . Result = new RouterDialogTurnResult ( RouterDialogTurnStatus . Restart ) ;
253+ }
254+
253255 // If confirm dialog is ended without skill switch, means previous activity has been resent and SkillDialog can continue to work
254- if ( ! ( result . Result is DispatchIntent ) )
256+ else
255257 {
256258 result . Status = DialogTurnStatus . Waiting ;
257259 }
@@ -346,7 +348,7 @@ private async Task<DialogTurnResult> ForwardToSkillAsync(DialogContext innerDc,
346348 UserInputActivity = innerDc . Context . Activity ,
347349 } ;
348350
349- return await innerDc . BeginDialogAsync ( DialogIds . ConfirmFlow , options ) ;
351+ return await innerDc . BeginDialogAsync ( DialogIds . ConfirmSkillSwitchFlow , options ) ;
350352 }
351353
352354 await _skillTransport . CancelRemoteDialogsAsync ( innerDc . Context ) ;
@@ -414,8 +416,8 @@ private Action<Activity> GetFallbackCallback(DialogContext dialogContext)
414416
415417 private class DialogIds
416418 {
417- public const string CancelPrompt = "cancelPrompt " ;
418- public const string ConfirmFlow = "confirmFlow " ;
419+ public const string ConfirmSkillSwitchPrompt = "confirmSkillSwitchPrompt " ;
420+ public const string ConfirmSkillSwitchFlow = "confirmSkillSwitchFlow " ;
419421 }
420422 }
421423}
0 commit comments