botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

Microsoft Bot Framework, Prompt.confirm: Is there anyway to restart the form if a field is entered incorrectly for a particular number of times???

Open PrasadGautham opened this issue 10 years ago β€’ 12 comments

For example if the user types something random other than yes/no/ok fro a prompt confirm, the form should be reset. and the toomanyattempts exception should not be shown. :)

PrasadGautham avatar Nov 29 '16 06:11 PrasadGautham

Simply set retry numbers as int, then on too many exemptions, reset the conversation by setting a boolean. And when boolen is true reset the conversation. You cannot reset a part of conversation.

alokraj68 avatar Nov 30 '16 07:11 alokraj68

@alokraj68 Thanks a lot for your reply :+1: ..Actually I am a newbie to this. Could you please suggest the changes PromptOptions PromptOptions = new LUISLogic().GetPromptOption("Are you satisfied with the answer?"); PromptDialog.Confirm(context, FeedbackConfirm, PromptOptions.Prompt, PromptOptions.Retry, PromptOptions.Attempts, PromptStyle.Auto); What is the change which I should make here to reset. if the user response is something other than yes or no. I am sorry if I sound stupid.

PrasadGautham avatar Nov 30 '16 07:11 PrasadGautham

Its simple, to prompt options.attempts pass the int with value how many reties should be allowed. Set a boolen value in a class as static public. Check if that boolen is true at start of each message received event. Then catch the too many attempts exception after the prompt. Once exceotion comes set the boolen true. Next time user comes, conversation will be reser

alokraj68 avatar Nov 30 '16 07:11 alokraj68

ok thanks a lot again :+1: . but still on the chat box the message "too many attempts" will be shown? Cant this be prevented?? Let me be more clear: An Example: The prompt dialog is asked for confirmation, but the user doesnt respond, the user comes back after sometime and says "Hi" instead of the answer to the previous question(PromptDialog.confirm). Now the bot would reply "too many attempts" before going to the next code. This is what I want to prevent...Hope I didnt mess up the question!

PrasadGautham avatar Nov 30 '16 10:11 PrasadGautham

Yes you can prevent that, simply dont send the exception to user, just echo your custom error message. Thats the best way. You should let user know that the bot is resetting

On 30-Nov-2016 3:58 PM, "GP@93" [email protected] wrote:

ok thanks a lot again πŸ‘ . but still on the chat box the message "too many attempts" will be shown? Cant this be prevented??

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Microsoft/BotBuilder/issues/1757#issuecomment-263838103, or mute the thread https://github.com/notifications/unsubscribe-auth/AIyDm1ft70f3HYz-0j-0lJKQBHjq51ogks5rDU-6gaJpZM4K-nQe .

alokraj68 avatar Nov 30 '16 10:11 alokraj68

Thanks a lot again :+1: but,I didnt do any code to send the exception to the chat box.Automatically the message "too many attempts" pops up.

PrasadGautham avatar Nov 30 '16 11:11 PrasadGautham

Simply put the code block in try catch block. Try the prompt, then you will get the exception. Catch it and do as i told above ;)

On 30-Nov-2016 5:05 PM, "GP@93" [email protected] wrote:

Thanks a lot again πŸ‘ but,I didnt do any code to send the exception to the chat box.Automatically the message "too many attempts" pops up.

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Microsoft/BotBuilder/issues/1757#issuecomment-263852277, or mute the thread https://github.com/notifications/unsubscribe-auth/AIyDmxtj4ZDgt7lqyaOOazijuy3ef70_ks5rDV9qgaJpZM4K-nQe .

alokraj68 avatar Nov 30 '16 11:11 alokraj68

Thanks again..I did try that...I did debugging as well...But even before the control reaches the catch statement...the "too many attempts" message is shown at the chat box...then when the control reaches the catch statement...the new custom error message too will be shown...I want to eliminate the "toomany attempts" message....Thanks again :+1:

PrasadGautham avatar Nov 30 '16 11:11 PrasadGautham

Try catching the toomany exceptions . Can i see your code segment? And i think its better to move to stack overflow as this aint any bug. And this forum is for bug posting.

On 30-Nov-2016 5:28 PM, "GP@93" [email protected] wrote:

Thanks again..I did try that...I did debugging as well...But even before the control reaches the catch statement...the "too many attempts" message is shown at the chat box...then when the control reaches the catch statement...the new custom error message too will be shown...I want to eliminate the "toomany attempts" message....Thanks again πŸ‘

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Microsoft/BotBuilder/issues/1757#issuecomment-263856535, or mute the thread https://github.com/notifications/unsubscribe-auth/AIyDm75sKxt5KPwquuzdsT8Vaiq_Scyhks5rDWTZgaJpZM4K-nQe .

alokraj68 avatar Nov 30 '16 12:11 alokraj68

You can just override the TooManyAttempts message by passing your own string in the PromptOptions constructor (https://github.com/Microsoft/BotBuilder/blob/10893730134135dd4af4250277de8e1b980f81c9/CSharp/Library/Dialogs/PromptDialog.cs#L157). Also, please update the subject as this whole thread is not related to FormFlow.

You can even inherit from your dialog and override the MessageReceivedAsync to remove the throw of the exception. https://github.com/Microsoft/BotBuilder/blob/10893730134135dd4af4250277de8e1b980f81c9/CSharp/Library/Dialogs/PromptDialog.cs#L736

ejadib avatar Nov 30 '16 12:11 ejadib

ok :+1: Thanks a lot... both of you guys....

PrasadGautham avatar Dec 01 '16 06:12 PrasadGautham

@Ezequiel Jadib : You can even inherit from your dialog and override the MessageReceivedAsync to remove the throw of the exception.

Can you please elaborate with a sample example for your above statement.

My Requirement: When we try to select any other value other than option I should send the request to LUIS again which I am doing in OptionPromptAsync method.

I don’t want to throw the exception in UI. (Too Many Attempts)

I am using as shown below

PromptOptions<string> optionSettings = new PromptOptions<string>(userFlowResposeDTO.ResponseText, "", null, options, 0);

PromptDialog.Choice<string>(context, OptionPromptAsync, optionSettings);

private async Task OptionPromptAsync(IDialogContext context, IAwaitable<string> result)
{
Try
{
	var choosenOptionString = await result;
	….
}

catch (TooManyAttemptsException)
            {
                Activity myActivity = (Activity)context.Activity;
                myActivity.Text = messageTextQuestion;
                await MessageReceivedAsync(context, Awaitable.FromItem(myActivity));
            } 
}

microsofttechie34 avatar Jan 29 '18 06:01 microsofttechie34