Prevent PromptValidator from showing a prompt

The PromptValidator in the Bot Framework is a powerful mechanism for collecting form information. However, one slight snag with it is that it only allows a limited control of the flow, i.e. you can say true/false and you can alter the (re)prompt. In certain situations you may want the validator to restart your dialog. That’s relatively easy, you just call dialogContext.ReplaceDialogAsync(this.Id). The problem is that whilst the framework will honor the replace request it will also continue with the retry prompt, almost certainly not what you want. To workaround this problem you provide a non-textual prompt and everything appears good to the user. E.g.

promptContext.Options.Prompt = new Activity(type: ActivityTypes.Typing);

2 thoughts on “Prevent PromptValidator from showing a prompt

  1. Tom November 15, 2018 / 8:09 am

    Hi! First of all, congratulations for your blog. I really would like to understand what you are talking about the the bot framework V4. The Microsoft reference is like talking Greek to me and I am struggling to find something that will not just conduct me into a step by step publishing bot process but mainly I would like to understand the logic and rationale between all classes and methods regarding the SDK V4. I am a complete beginner and discover that many (if all) the material available is a) directed to experienced developers or b) outdated (V3). Please, did you know some really friendly and updated book or any kind of material which can help me?

    • pauliom November 15, 2018 / 9:26 pm

      Hi Tom. Thanks. I would recommend you download and work through them in their numbered order. However, I agree it can be a bit confusing. If there is something you’d like to know maybe I can write up a guide for you?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s