WaterfallDialog Class

public class WaterfallDialog
extends Dialog

Dialog optimized for prompting a user with a series of questions. Waterfalls accept a stack of functions which will be executed in sequence. Each waterfall step can ask a question of the user and the user's response will be passed as an argument to the next waterfall step.

Constructor Summary

Constructor Description
WaterfallDialog(String dialogId, List<WaterfallStep> actions)

Initializes a new instance of the WaterfallDialog class.

Method Summary

Modifier and Type Method and Description
WaterfallDialog addStep(WaterfallStep step)

Adds a new step to the waterfall.

java.util.concurrent.CompletableFuture<DialogTurnResult> beginDialog(DialogContext dc, Object options)

Called when the waterfall dialog is started and pushed onto the dialog stack.

java.util.concurrent.CompletableFuture<DialogTurnResult> continueDialog(DialogContext dc)

Called when the waterfall dialog is _continued_, where it is the active dialog and the user replies with a new activity.

java.util.concurrent.CompletableFuture<java.lang.Void> endDialog(TurnContext turnContext, DialogInstance instance, DialogReason reason)

Called when the dialog is ending.

java.lang.String getVersion()

Gets a unique String which represents the version of this dialog.

protected java.util.concurrent.CompletableFuture<DialogTurnResult> onStep(WaterfallStepContext stepContext)

Called when an individual waterfall step is being executed.

java.util.concurrent.CompletableFuture<DialogTurnResult> resumeDialog(DialogContext dc, DialogReason reason, Object result)

Called when a child waterfall dialog completed its turn, returning control to this dialog.

protected java.util.concurrent.CompletableFuture<DialogTurnResult> runStep(DialogContext dc, int index, DialogReason reason, Object result)

Excutes a step of the waterfall dialog.

Methods inherited from Dialog

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Constructor Details

WaterfallDialog

public WaterfallDialog(String dialogId, List actions)

Initializes a new instance of the WaterfallDialog class.

Parameters:

dialogId - The dialog ID.
actions - Optional actions to be defined by the caller.

Method Details

addStep

public WaterfallDialog addStep(WaterfallStep step)

Adds a new step to the waterfall.

Parameters:

step - Step to add.

Returns:

Waterfall dialog for fluent calls to AddStep().

beginDialog

public CompletableFuture beginDialog(DialogContext dc, Object options)

Called when the waterfall dialog is started and pushed onto the dialog stack.

Overrides:

WaterfallDialog.beginDialog(DialogContext dc, Object options)

Parameters:

dc - The
options - Optional, initial information to pass to the dialog.

Returns:

A CompletableFuture representing the asynchronous operation.
     If the task is successful, the result indicates whether the dialog is
     still active after the turn has been processed by the dialog.

continueDialog

public CompletableFuture continueDialog(DialogContext dc)

Called when the waterfall dialog is _continued_, where it is the active dialog and the user replies with a new activity.

Overrides:

WaterfallDialog.continueDialog(DialogContext dc)

Parameters:

dc - The

Returns:

A CompletableFuture representing the asynchronous operation.
     If the task is successful, the result indicates whether the dialog is
     still active after the turn has been processed by the dialog. The
     result may also contain a return value.

endDialog

public CompletableFuture endDialog(TurnContext turnContext, DialogInstance instance, DialogReason reason)

Called when the dialog is ending.

Overrides:

WaterfallDialog.endDialog(TurnContext turnContext, DialogInstance instance, DialogReason reason)

Parameters:

turnContext - Context for the current turn of the conversation.
instance - The instance of the current dialog.
reason - The reason the dialog is ending.

Returns:

A task that represents the work queued to execute.

getVersion

public String getVersion()

Gets a unique String which represents the version of this dialog. If the version changes between turns the dialog system will emit a DialogChanged event.

Overrides:

WaterfallDialog.getVersion()

Returns:

Version will change when steps count changes (because dialog has no way of evaluating the content of the steps.

onStep

protected CompletableFuture onStep(WaterfallStepContext stepContext)

Called when an individual waterfall step is being executed.

Parameters:

stepContext - Context for the waterfall step to execute.

Returns:

A task that represents the work queued to execute.

resumeDialog

public CompletableFuture resumeDialog(DialogContext dc, DialogReason reason, Object result)

Called when a child waterfall dialog completed its turn, returning control to this dialog.

Overrides:

WaterfallDialog.resumeDialog(DialogContext dc, DialogReason reason, Object result)

Parameters:

dc - The dialog context for the current turn of the conversation.
reason - Reason why the dialog resumed.
result - Optional, value returned from the dialog that was called. The type of the value returned is dependent on the child dialog.

Returns:

A CompletableFuture representing the asynchronous operation.

runStep

protected CompletableFuture runStep(DialogContext dc, int index, DialogReason reason, Object result)

Excutes a step of the waterfall dialog.

Parameters:

dc - The DialogContext for the current turn of conversation.
index - The index of the current waterfall step to execute.
reason - The reason the waterfall step is being executed.
result - Result returned by a dialog called in the previous waterfall step.

Returns:

A task that represents the work queued to execute.

Applies to