ComponentDialog Class

public class ComponentDialog
extends DialogContainer

A Dialog that is composed of other dialogs. A component dialog has an inner DialogSet and DialogContext ,which provides an inner dialog stack that is hidden from the parent dialog.

Field Summary

Modifier and Type Field and Description
static final java.lang.String PERSISTEDDIALOGSTATE

The id for the persisted dialog state.

Constructor Summary

Constructor Description
ComponentDialog(String dialogId)

Initializes a new instance of the ComponentDialog class.

Method Summary

Modifier and Type Method and Description
ComponentDialog addDialog(Dialog dialog)

Adds a new Dialog to the component dialog and returns the updated component.

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

Called when the dialog is started and pushed onto the parent's dialog stack.

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

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

DialogContext createChildContext(DialogContext dc)

Creates an inner DialogContext .

protected java.util.concurrent.CompletableFuture<DialogTurnResult> endComponent(DialogContext outerDc, Object result)

Ends the component dialog in its parent's context.

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

Called when the dialog is ending.

protected java.util.concurrent.CompletableFuture<java.lang.Void> ensureInitialized(DialogContext outerDc)

Ensures the dialog is initialized.

java.lang.String getInitialDialogId()

Gets the id assigned to the initial dialog.

protected java.util.concurrent.CompletableFuture<DialogTurnResult> onBeginDialog(DialogContext innerDc, Object options)

Called when the dialog is started and pushed onto the parent's dialog stack.

protected java.util.concurrent.CompletableFuture<DialogTurnResult> onContinueDialog(DialogContext innerDc)

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

protected java.util.concurrent.CompletableFuture<java.lang.Void> onEndDialog(TurnContext context, DialogInstance instance, DialogReason reason)

Called when the dialog is ending.

protected java.util.concurrent.CompletableFuture<java.lang.Void> onInitialize(DialogContext dc)

Initilizes the dialog.

protected java.util.concurrent.CompletableFuture<java.lang.Void> onRepromptDialog(TurnContext turnContext, DialogInstance instance)

Called when the dialog should re-prompt the user for input.

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

Called when the dialog should re-prompt the user for input.

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

Called when a child dialog on the parent's dialog stack completed this turn, returning control to this dialog component.

void setInitialDialogId(String withInitialDialogId)

Sets the id assigned to the initial dialog.

Methods inherited from Dialog

Methods inherited from DialogContainer

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

Field Details

PERSISTEDDIALOGSTATE

public static final String PERSISTEDDIALOGSTATE

The id for the persisted dialog state.

Constructor Details

ComponentDialog

public ComponentDialog(String dialogId)

Initializes a new instance of the ComponentDialog class.

Parameters:

dialogId - The D to assign to the new dialog within the parent dialog set.

Method Details

addDialog

public ComponentDialog addDialog(Dialog dialog)

Adds a new Dialog to the component dialog and returns the updated component.

Parameters:

dialog - The dialog to add.

Returns:

The ComponentDialog after the operation is complete.
     The added dialog's <xref uid="com.microsoft.bot.dialogs.Dialog.telemetryClient" data-throw-if-not-resolved="false" data-raw-source="Dialog#telemetryClient"></xref> is set to the
     <xref uid="com.microsoft.bot.dialogs.DialogContainer.telemetryClient" data-throw-if-not-resolved="false" data-raw-source="DialogContainer#telemetryClient"></xref> of the component dialog.

beginDialog

public CompletableFuture beginDialog(DialogContext outerDc, Object options)

Called when the dialog is started and pushed onto the parent's dialog stack.

Overrides:

ComponentDialog.beginDialog(DialogContext outerDc, Object options)

Parameters:

outerDc - The parent DialogContext for the current turn of conversation.
options - Optional, initial information to pass to the dialog.

Returns:

A CompletableFuture representing the hronous 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 outerDc)

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

Overrides:

ComponentDialog.continueDialog(DialogContext outerDc)

Parameters:

outerDc - The parent DialogContext for the current turn of conversation.

Returns:

A CompletableFuture representing the hronous 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. If this method is *not*
     overridden, the component dialog calls the
     <xref uid="com.microsoft.bot.dialogs.DialogContext.continueDialog*" data-throw-if-not-resolved="false" data-raw-source="DialogContext#continueDialog(CancellationToken)"></xref> method on its
     inner dialog context. If the inner dialog stack is empty, the
     component dialog ends, and if a <xref uid="com.microsoft.bot.dialogs.DialogTurnResult.result" data-throw-if-not-resolved="false" data-raw-source="DialogTurnResult#result"></xref> is
     available, the component dialog uses that as its return value.

createChildContext

public DialogContext createChildContext(DialogContext dc)

Creates an inner DialogContext .

Overrides:

ComponentDialog.createChildContext(DialogContext dc)

Parameters:

dc - The parent DialogContext .

Returns:

The created Dialog Context.

endComponent

protected CompletableFuture endComponent(DialogContext outerDc, Object result)

Ends the component dialog in its parent's context.

Parameters:

outerDc - The parent DialogContext for the current turn of conversation.
result - Optional, value to return from the dialog component to the parent context.

Returns:

A task that represents the work queued to execute.
     If the task is successful, the result indicates that the dialog ended
     after the turn was processed by the dialog. In general, the parent
     context is the dialog or bot turn handler that started the dialog. If
     the parent is a dialog, the stack calls the parent's
     <xref uid="com.microsoft.bot.dialogs.Dialog.resumeDialog(com.microsoft.bot.dialogs.DialogContext,com.microsoft.bot.dialogs.DialogReason,java.lang.Object)" data-throw-if-not-resolved="false" data-raw-source="Dialog#resumeDialog(DialogContext, DialogReason, Object)"></xref>
     method to return a result to the parent dialog. If the parent dialog
     does not implement `ResumeDialog`, then the parent will end, too, and
     the result is passed to the next parent context, if one exists. The
     returned <xref uid="com.microsoft.bot.dialogs.DialogTurnResult" data-throw-if-not-resolved="false" data-raw-source="DialogTurnResult"></xref> contains the return value in its
     <xref uid="com.microsoft.bot.dialogs.DialogTurnResult.result" data-throw-if-not-resolved="false" data-raw-source="DialogTurnResult#result"></xref> property.

endDialog

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

Called when the dialog is ending.

Overrides:

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

Parameters:

turnContext - The context Object for this turn.
instance - State information associated with the instance of this component dialog on its parent's dialog stack.
reason - Reason why the dialog ended.

Returns:

A CompletableFuture representing the hronous operation.
     When this method is called from the parent dialog's context, the
     component dialog cancels all of the dialogs on its inner dialog stack
     before ending.

ensureInitialized

protected CompletableFuture ensureInitialized(DialogContext outerDc)

Ensures the dialog is initialized.

Parameters:

outerDc - The outer DialogContext .

Returns:

A CompletableFuture representing the hronous operation.

getInitialDialogId

public String getInitialDialogId()

Gets the id assigned to the initial dialog.

Returns:

the InitialDialogId value as a String.

onBeginDialog

protected CompletableFuture onBeginDialog(DialogContext innerDc, Object options)

Called when the dialog is started and pushed onto the parent's dialog stack.

Parameters:

innerDc - The inner DialogContext for the current turn of conversation.
options - Optional, initial information to pass to the dialog.

Returns:

A CompletableFuture representing the hronous operation.
     If the task is successful, the result indicates whether the dialog is
     still active after the turn has been processed by the dialog. By
     default, this calls the
     <xref uid="com.microsoft.bot.dialogs.Dialog.beginDialog(com.microsoft.bot.dialogs.DialogContext,java.lang.Object)" data-throw-if-not-resolved="false" data-raw-source="Dialog#beginDialog(DialogContext, Object)"></xref> method of the
     component dialog's initial dialog, as defined by
     InitialDialogId . Override this method in a derived class to
     implement interrupt logic.

onContinueDialog

protected CompletableFuture onContinueDialog(DialogContext innerDc)

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

Parameters:

innerDc - The inner DialogContext for the current turn of conversation.

Returns:

A CompletableFuture representing the hronous 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. By default, this calls the
     currently active inner dialog's
     <xref uid="com.microsoft.bot.dialogs.Dialog.continueDialog(com.microsoft.bot.dialogs.DialogContext)" data-throw-if-not-resolved="false" data-raw-source="Dialog#continueDialog(DialogContext)"></xref> method. Override this
     method in a derived class to implement interrupt logic.

onEndDialog

protected CompletableFuture onEndDialog(TurnContext context, DialogInstance instance, DialogReason reason)

Called when the dialog is ending.

Parameters:

context - The context Object for this turn.
instance - State information associated with the inner dialog stack of this component dialog.
reason - Reason why the dialog ended.

Returns:

A CompletableFuture representing the hronous operation.
     Override this method in a derived class to implement any additional
     logic that should happen at the component level, after all inner
     dialogs have been canceled.

onInitialize

protected CompletableFuture onInitialize(DialogContext dc)

Initilizes the dialog.

Parameters:

dc - The DialogContext to initialize.

Returns:

A CompletableFuture representing the hronous operation.

onRepromptDialog

protected CompletableFuture onRepromptDialog(TurnContext turnContext, DialogInstance instance)

Called when the dialog should re-prompt the user for input.

Parameters:

turnContext - The context Object for this turn.
instance - State information associated with the inner dialog stack of this component dialog.

Returns:

A CompletableFuture representing the hronous operation.
     Override this method in a derived class to implement any additional
     logic that should happen at the component level, after the re-prompt
     operation completes for the inner dialog.

repromptDialog

public CompletableFuture repromptDialog(TurnContext turnContext, DialogInstance instance)

Called when the dialog should re-prompt the user for input.

Overrides:

ComponentDialog.repromptDialog(TurnContext turnContext, DialogInstance instance)

Parameters:

turnContext - The context Object for this turn.
instance - State information for this dialog.

Returns:

A CompletableFuture representing the hronous operation.

resumeDialog

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

Called when a child dialog on the parent's dialog stack completed this turn, returning control to this dialog component.

Overrides:

ComponentDialog.resumeDialog(DialogContext outerDc, DialogReason reason, Object result)

Parameters:

outerDc - The DialogContext for the current turn of 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 hronous operation.
     If the task is successful, the result indicates whether this dialog
     is still active after this dialog turn has been processed. Generally,
     the child dialog was started with a call to
     BeginDialog(DialogContext, Object) in the parent's context.
     However, if the <xref uid="com.microsoft.bot.dialogs.DialogContext.replaceDialog(java.lang.String,java.lang.Object)" data-throw-if-not-resolved="false" data-raw-source="DialogContext#replaceDialog(String, Object)"></xref>
     method is called, the logical child dialog may be different than the
     original. If this method is *not* overridden, the dialog
     automatically calls its RepromptDialog(TurnContext,
     DialogInstance) when the user replies.

setInitialDialogId

public void setInitialDialogId(String withInitialDialogId)

Sets the id assigned to the initial dialog.

Parameters:

withInitialDialogId - The InitialDialogId value.

Applies to