Microsoft Bot Framework, Prompt.confirm: Is there anyway to restart the form if a field is entered incorrectly for a particular number of times???
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. :)
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 Thanks a lot for your reply :+1: ..Actually I am a newbie to this. Could you please suggest the changes
PromptOptions
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
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!
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 .
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.
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 .
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:
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 .
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
ok :+1: Thanks a lot... both of you guys....
@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));
}
}