如果 he/she 发现输入不正确,我如何提示用户重新输入之前的瀑布步骤

How do i prompt user to re-enter input for previous waterfall step if he/she finds the input entered to be incorrect

场景如下:

如果用户提供的输入在瀑布步骤中似乎不正确(例如不正确的名称、不正确的日期) 用户想通过说“(重新输入)”或(再次输入)再次输入最后的输入。

就好比瀑布对话框有3个步骤:Step1->Step2->Step3

在为第 2 步提供输入后,如果用户发现输入不正确,他想通过说出上述任何词来中断流程以输入上一步的输入。

我找不到返回上一个瀑布步骤的方法。

返回上一步的解决方案很少,但我无法在 python 中复制相同的解决方案。

Link1:- Bot framework v4.0 how to execute the previous waterfall step in a dialog

Link2:- https://pauliom.com/2018/08/08/manipulating-waterfall-steps-botframework-v4/

我尝试使用中断处理该场景,但问题仍然存在,因为下一个回合从对话中断的地方继续。

您可以使用的是 Validators,查看此 article 了解更多信息或查找以下代码片段 [c#]作为总结。
我还在最后添加了一个 Python 片段

当用户回复您的提示时,将触发验证。 如果验证returns false,将向用户发送重试提示

如果您实现了验证器,则无需返回上一步

            AddDialog(new TextPrompt("TextPromptId", UserNameValidation));
            AddDialog(new NumberPrompt<int>("NumberPromptId", MobileNumberValidation));
            AddDialog(new ChoicePrompt("ChoicePromptId", ChoiceValidataion));

用户名验证器:


    private Task<bool> UserNameValidation(PromptValidatorContext<string> promptContext, CancellationToken cancellationToken)  
           {  
               return Task.FromResult(true);  
           } 

选择验证器:



    private Task<bool> ChoiceValidataion(PromptValidatorContext<FoundChoice> promptContext, CancellationToken cancellationToken)  
            {  
                return Task.FromResult(true);  
            }  

手机Phone验证者:




    private async Task<bool> MobileNumberValidation(PromptValidatorContext<int> promptcontext, CancellationToken cancellationtoken)  
            {  
                if (!promptcontext.Recognized.Succeeded)  
                {  
                    await promptcontext.Context.SendActivityAsync("Hello, Please enter the valid mobile no",  
                        cancellationToken: cancellationtoken);  

                    return false;  
                }  

                int count = Convert.ToString(promptcontext.Recognized.Value).Length;  
                if (count != 10)  
                {  
                    await promptcontext.Context.SendActivityAsync("Hello , you are missing some number !!!",  
                        cancellationToken: cancellationtoken);  
                    return false;  
                }  

                return true;  
            }   

我不是 Python 开发人员,但您在 Python 选项卡的 Here 中找到了 python 样本和以下代码段:

async def age_prompt_validator(prompt_context: PromptValidatorContext) -> bool:
    # This condition is our validation rule. You can also change the value at this point.
    return (
        prompt_context.recognized.succeeded
        and 0 < prompt_context.recognized.value < 150
    )

希望对您有所帮助

您可以使用组件对话框在每个步骤结束时使用选择提示构建一些东西。所以用户输入一个名字,Bot 回应“这是你输入的吗?”用户确认是,下一步触发,用户说不,那个对话框是 re-运行.

本月早些时候我自己也有类似的问题