WaterfallDialog class
A waterfall is a dialog that's optimized for prompting a user with a series of questions.
- Extends
-
Dialog<O>
Constructors
| Waterfall |
Creates a new waterfall dialog containing the given array of steps. |
Properties
| id | Unique ID of the dialog. |
Inherited Properties
| End |
Gets a default end-of-turn result. |
Methods
| add |
Adds a new step to the waterfall. |
| begin |
Called when the WaterfallDialog is started and pushed onto the dialog stack. |
| continue |
Called when the WaterfallDialog is continued, where it is the active dialog and the user replies with a new Activity. |
| get |
Gets the dialog version, composed of the ID and number of steps. |
| resume |
Called when a child WaterfallDialog completed its turn, returning control to this dialog. |
Inherited Methods
| configure(Record<string, unknown>) | Fluent method for configuring the object. |
| end |
When overridden in a derived class, performs clean up for the dialog before it ends. |
| get |
Gets the converter for the selector configuration. * |
| on |
Called when an event has been raised, using DialogContext.emitEvent method, by either the current dialog or a dialog that the current dialog started. |
| reprompt |
When overridden in a derived class, prompts the user again for input. |
Constructor Details
WaterfallDialog<O>(string, WaterfallStep<O>[])
Creates a new waterfall dialog containing the given array of steps.
new WaterfallDialog(dialogId: string, steps?: WaterfallStep<O>[])
Parameters
- dialogId
-
string
Unique ID of the dialog within the component or set its being added to.
- steps
-
WaterfallStep<O>[]
(Optional) array of asynchronous waterfall step functions.
Remarks
See the addStep function for details on creating a valid step function.
Property Details
id
Unique ID of the dialog.
string id
Property Value
string
The Id for the dialog.
Inherited Property Details
EndOfTurn
Gets a default end-of-turn result.
static EndOfTurn: DialogTurnResult<any>
Property Value
DialogTurnResult<any>
Remarks
This result indicates that a dialog (or a logical step within a dialog) has completed processing for the current turn, is still active, and is waiting for more input.
Inherited From Dialog.EndOfTurn
Method Details
addStep(WaterfallStep<O>)
Adds a new step to the waterfall.
function addStep(step: WaterfallStep<O>): WaterfallDialog<O>
Parameters
- step
Asynchronous step function to call.
Returns
Waterfall dialog for fluent calls to addStep().
beginDialog(DialogContext, O)
Called when the WaterfallDialog is started and pushed onto the dialog stack.
function beginDialog(dialogContext: DialogContext, options?: O): Promise<DialogTurnResult<any>>
Parameters
- dialogContext
- DialogContext
The DialogContext for the current turn of conversation.
- options
-
O
Optional, initial information to pass to the Dialog.
Returns
Promise<DialogTurnResult<any>>
A Promise representing the asynchronous operation.
Remarks
If the task is successful, the result indicates whether the Dialog is still active after the turn has been processed by the dialog.
continueDialog(DialogContext)
Called when the WaterfallDialog is continued, where it is the active dialog and the user replies with a new Activity.
function continueDialog(dialogContext: DialogContext): Promise<DialogTurnResult<any>>
Parameters
- dialogContext
- DialogContext
The DialogContext for the current turn of conversation.
Returns
Promise<DialogTurnResult<any>>
A Promise representing the asynchronous operation.
Remarks
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.
getVersion()
Gets the dialog version, composed of the ID and number of steps.
function getVersion(): string
Returns
string
Dialog version, composed of the ID and number of steps.
resumeDialog(DialogContext, DialogReason, any)
Called when a child WaterfallDialog completed its turn, returning control to this dialog.
function resumeDialog(dc: DialogContext, reason: DialogReason, result?: any): Promise<DialogTurnResult<any>>
Parameters
The DialogContext for the current turn of the conversation.
- reason
- DialogReason
DialogReason why the dialog resumed.
- result
-
any
Optional, value returned from the dialog that was called. The type of the value returned is dependent on the child dialog.
Returns
Promise<DialogTurnResult<any>>
A Promise representing the asynchronous operation.
Inherited Method Details
configure(Record<string, unknown>)
Fluent method for configuring the object.
function configure(config: Record<string, unknown>): WaterfallDialog<O>
Parameters
- config
-
Record<string, unknown>
Configuration settings to apply.
Returns
The Configurable after the operation is complete.
Inherited From Dialog.configure
endDialog(TurnContext, DialogInstance<any>, DialogReason)
When overridden in a derived class, performs clean up for the dialog before it ends.
function endDialog(_context: TurnContext, _instance: DialogInstance<any>, _reason: DialogReason): Promise<void>
Parameters
- _context
- TurnContext
The context object for the turn.
- _instance
-
DialogInstance<any>
Current state information for this dialog.
- _reason
- DialogReason
The reason the dialog is ending.
Returns
Promise<void>
Remarks
Derived dialogs that need to perform logging or cleanup before ending should override this method. By default, this method has no effect.
The DialogContext calls this method when the current dialog is ending.
Inherited From Dialog.endDialog
getConverter(string)
Gets the converter for the selector configuration. *
function getConverter(_property: string): Converter<unknown, unknown> | ConverterFactory<unknown, unknown>
Parameters
- _property
-
string
The key of the conditional selector configuration. *
Returns
Converter<unknown, unknown> | ConverterFactory<unknown, unknown>
The converter for the selector configuration.
Inherited From Dialog.getConverter
onDialogEvent(DialogContext, DialogEvent)
Called when an event has been raised, using DialogContext.emitEvent method, by either the current dialog or a dialog that the current dialog started.
function onDialogEvent(dialogContext: DialogContext, event: DialogEvent): Promise<boolean>
Parameters
- dialogContext
- DialogContext
The dialog context for the current turn of conversation.
- event
- DialogEvent
The event being raised.
Returns
Promise<boolean>
True if the event is handled by the current dialog and bubbling should stop.
Inherited From Dialog.onDialogEvent
repromptDialog(TurnContext, DialogInstance<any>)
When overridden in a derived class, prompts the user again for input.
function repromptDialog(_context: TurnContext, _instance: DialogInstance<any>): Promise<void>
Parameters
- _context
- TurnContext
The context object for the turn.
- _instance
-
DialogInstance<any>
Current state information for this dialog.
Returns
Promise<void>
Remarks
Derived dialogs that support validation and re-prompt logic should override this method. By default, this method has no effect.
The DialogContext calls this method when the current dialog should re-request input from the user. This method is implemented for prompt dialogs.
Inherited From Dialog.repromptDialog