我想在结束时使用 C# 在开始时重新启动我的瀑布对话框

I want to restart my watterfall dialog at it's beginning when it ends, using C#

我正在使用 Bot Framework .Net SDK4。 我在 MainDialog 开始我的对话。 当 watterfall 对话结束时,我正在尝试重新启动我的对话。我有多个 watterfall 重定向到其他 watterfall 对话框,直到它们到达最后一个。 当我使用 stepContext.EndDialogAsync(null, cancellationToken)stepContext.CancellAllDialogsAsync(cancellationToken) 时,对话框只是 returns 到前一个父对话框。 由于循环依赖问题,我也不能只使用 BeginDialogAsync(nameof(MainDialog), null, cancellationToke) 。 我可以做些什么来在 MainDialog 处重新启动我的对话框,它会再次重新运行对话框。

使用

 return await sc.ReplaceDialogAsync(nameof(NoUnderstandDialog), cancellationToken);

重新启动您当前所在的瀑布对话框。

ReplaceDialogAsync :

Starts a new dialog and replaces on the stack the currently active dialog with the new one. This is particularly useful for creating loops or redirecting to another dialog.

你可以出于多种原因使用它,验证例如如果用户输入了错误的值,你可以重新启动对话框以再次提示。小心你的瀑布对话框应该总是 "ends" 这意味着它应该有一个 EndDialogAsync 这样你就不会陷入无限循环