我将使用哪个提示对话框进行密码重置功能

时间:2017-03-07 06:18:28

标签: botframework

我正在为访问功能开发一个简单的聊天机器人。我需要有密码重置功能的提示对话框。如果用户帐号被忘记密码/锁定了,我要求用户提出密码问题,如果问题的答案是匹配问题那么,我将生成一次性密码,否则重试选项给用户.. 这是我的代码.. boolChoice(它是一个LuisIntent)是用户想要休息时的密码。然后我会提示

 if (boolChoice.ToLower().Equals("yes"))
            {
                PromptDialog.Text(
                context: context,
                resume: ResumeAfterSecretAnswer,
                prompt: "Ok. I need you to answer your secret question: "+getSecretQuestionForUser(),
                retry: "I didn't understand. Please try again.");
            }
private string getSecretQuestionForUser()
        {
            return "What is your favorite color?";
        }

private async Task ResumeAfterSecretAnswer(IDialogContext context, IAwaitable<string> result)
        {
            string answer = await result;
            //suppose right answer is blue.. then what next i need to do . do I need to prompt here or how do I compare and generate the one time password.
// need a flow,...
        }

现在在ResumeAfterSecret内部如果答案是匹配我需要做什么然后我需要提示用户一次性密码或如果不匹配那么我需要再次提示他。以及哪个promptdialog我需要使用PromoptDialog.Confirm或其他任何东西..

我对流程感到困惑..这里的流程应该是什么..

现在我改变了方法......

我现在改变了方法..

private async Task ResumeAfterSecretAnswer(IDialogContext context, IAwaitable<string> result)
        {
            string answer = await result;

            if (answer.ToLower() == getSecretAnswerForUser())
                await context.PostAsync("Your One time password is: "+ getOneTimePasswordForUser());
            else
                await context.PostAsync("The answers do not match. Please try again.");

            context.Wait(MessageReceived);

        }

如果答案不匹配,我应该在其他部分做什么。我需要再次提示用户..我该怎么做,怎么做......我实现了这个目标。

请帮忙。

1 个答案:

答案 0 :(得分:0)

你只需要在else上再次调用它,我建议你把它放在一个方法中:

PromptDialog.Text(
                context: context,
                resume: ResumeAfterSecretAnswer,
                prompt: "Ok. I need you to answer your secret question: "+getSecretQuestionForUser(),
                retry: "I didn't understand. Please try again.");

小心来自else的context.wait(MessageReceived),由于对话框的多个退出,它可能会抛出异常

相关问题