Botframework-sdk: Retry a dialog step in waterfall

Created on 23 Jun 2016  路  7Comments  路  Source: microsoft/botframework-sdk

Hi,

Hoping to get a bit more documentation for an issue I am having.

Am using nodejs, and can't see from the documentation or examples how to repeat a waterfall step until the user supplies something that can be used. I can see 2 potential candidates,

http://docs.botframework.com/sdkreference/nodejs/interfaces/_botbuilder_d_.ipromptoptions.html
(that has maxTries and retryPrompt)

http://docs.botframework.com/sdkreference/nodejs/classes/_botbuilder_d_.dialogaction.html#validated
(prompt for validating a prompt response)

But I can't see how to tie the 3 concepts together (waterfall, promptOptions and validatedPrompt). Example scenarios are:-

  • User enters a date, but the date isn't valid because of business logic (in the past, unavailable)
  • User enters a location, so need to check against list of available locations (perhaps from an api call)

Any help would be appreciated. Loving the work with botbuilder and LUIS BTW.

Thanks,
Jarrod

Most helpful comment

A couple of comments... Sorry I'm coming late. As of v3.1.x I believe, prompts no longer return until the user successfully provides an answer. MaxRetries is essentially infinite by default now. You can use a validated prompt or you can build a dialog which acts like a custom prompt.

I'm about to re-write the prompt system such that building rich custom prompts is going to be WAY easier. The validatedPrompt() stuff will be deprecated at that point. More details coming.

All 7 comments

I am looking for this too.

I'm especially interested in asynchronous version of validatedPrompt(), since I want to validate user input by LUIS.

I suggest you to think more in a modular way. By keeping your waterfall,luis calls,prompts as different functions and based on the user response traverse to and fro.

@McGern

First it's better that each waterfall step is a variable function, so that you can use it more than once. Assumed that you do

session.userData.corrections =  {
                        text : corrections.text,
                        result : corrections.result
                      };
// This prompt already knows to look for several variants of the yes & no.
                      // The returned result.response will be a simple Boolean so way easier to check.
                      // @see https://github.com/Microsoft/BotBuilder/issues/183
                      BotBuilder.Prompts.confirm(session, msg );

supposed that you are applying some text corrections to the user input in this case and then asking the user for a confirmation. At that point in the waterfall step 2 you do

var response=results.response;
            if( response ) { // BotBuilder.Prompts.confirm bool

              // replace query and session
              // @see https://github.com/Microsoft/BotBuilder/issues/183
              if( session.userData.corrections.text ) {
                session.message.text=session.userData.corrections.result;
              }
              session.replaceDialog('/');
            }

to get the response, and the replace the input text to yours and redo the query with the replaceDialog function.

Closing this issue. Thanks for your answer @loretoparisi !

A couple of comments... Sorry I'm coming late. As of v3.1.x I believe, prompts no longer return until the user successfully provides an answer. MaxRetries is essentially infinite by default now. You can use a validated prompt or you can build a dialog which acts like a custom prompt.

I'm about to re-write the prompt system such that building rich custom prompts is going to be WAY easier. The validatedPrompt() stuff will be deprecated at that point. More details coming.

I have exact same task:

  • User enters a date, but the date isn't valid because of business logic (in the past, unavailable)
  • User enters a location, so need to check against list of available locations (perhaps from an api call)

Guys, could You point me to workable code for BotBuilder 3.9 please: how to implement this? Thanks!

P.S. Answered here: https://stackoverflow.com/q/45766908/630169

Was this page helpful?
0 / 5 - 0 ratings