Documentation - v1.2.0-alpha.3
    Preparing search index...

    Base class for a dialog that contains other child dialogs.

    Component dialogs let you break your agent's logic up into components that can themselves be added as a dialog to another ComponentDialog or DialogSet. Components can also be exported as part of a node package and used within other agents.

    Type Parameters

    • O extends object = {}

      (Optional) options that can be passed into the DialogContext.beginDialog() method.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    dialogs: DialogSet = ...

    The containers dialog set.

    initialDialogId: string

    ID of the child dialog that should be started anytime the component is started.

    This defaults to the ID of the first child dialog added using addDialog().

    EndOfTurn: DialogTurnResult = ...

    Gets a default end-of-turn result.

    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.

    Accessors

    Methods

    • Adds a child Dialog or prompt to the components internal DialogSet.

      Parameters

      • dialog: Dialog

        The child Dialog or prompt to add.

      Returns this

      The ComponentDialog after the operation is complete.

      The Dialog.id of the first child added to the component will be assigned to the initialDialogId property.

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

      Parameters

      • outerDialogContext: DialogContext

        The parent DialogContext for the current turn of conversation.

      • Optionaloptions: O

        Optional, initial information to pass to the dialog.

      Returns Promise<DialogTurnResult<any>>

      A Promise 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. By default, this calls the Dialog.BeginDialogAsync(DialogContext, object, CancellationToken) method of the component dialog's initial dialog, as defined by InitialDialogId. Override this method in a derived class to implement interrupt logic.

    • Called when the dialog is continued, where it is the active dialog and the user replies with a new Activity.

      Parameters

      • outerDialogContext: DialogContext

        The parent DialogContext for the current turn of conversation.

      Returns Promise<DialogTurnResult<any>>

      A Promise representing the asynchronous operation.

      If this method is not overridden, the dialog automatically ends when the user replies. 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.

    • Called when the components last active child dialog ends and the component is ending.

      Parameters

      • outerDC: DialogContext

        Dialog context for the parents DialogSet.

      • result: any

        Result returned by the last active child dialog. Can be a value of undefined.

      Returns Promise<DialogTurnResult<any>>

      A promise resolving to the dialog turn result.

      SHOULD be overridden by components that wish to perform custom logic before the component ends. The default implementation calls outerDC.endDialog() with the result returned from the last active child dialog.

    • Returns internal version identifier for this container.

      Returns string

      Version which represents the change of the internals of this container.

      DialogContainers detect changes of all sub-components in the container and map that to a versionChanged event. Because they do this, DialogContainers "hide" the internal changes and just have the .id. This isolates changes to the container level unless a container doesn't handle it. To support this DialogContainers define a protected method getInternalVersion() which computes if this dialog or child dialogs have changed which is then examined via calls to checkForVersionChange().

    • An encoded string used to aid in the detection of agent changes on re-deployment.

      Returns string

      Unique string which should only change when dialog has changed in a way that should restart the dialog.

      This defaults to returning the dialog's id but can be overridden to provide more precise change detection logic. Any dialog on the stack that has its version change will result in a versionChanged event will be raised. If this event is not handled by the agent, an error will be thrown resulting in the agent error handler logic being run.

      Returning an empty string will disable version tracking for the component all together.

    • Called anytime an instance of the component has been started.

      Parameters

      • innerDialogContext: DialogContext

        Dialog context for the components internal DialogSet.

      • Optionaloptions: O

        (Optional) options that were passed to the component by its parent.

      Returns Promise<DialogTurnResult<any>>

      A promise resolving to the dialog turn result.

      SHOULD be overridden by components that wish to perform custom interruption logic. The default implementation calls innerDC.beginDialog() with the dialog assigned to initialDialogId.

    • Called when the component is ending.

      Parameters

      • _context: TurnContext

        Context for the current turn of conversation.

      • _instance: DialogInstance

        The components instance data within its parents dialog stack.

      • _reason: DialogReason

        The reason the component is ending.

      Returns Promise<void>

      A promise representing the asynchronous operation.

      If the reason code is equal to DialogReason.cancelCalled, then any active child dialogs will be cancelled before this method is called.

    • Called before an event is bubbled to its parent.

      Parameters

      Returns Promise<boolean>

      Whether the event is handled by the current dialog and further processing should stop.

      This is a good place to perform interception of an event as returning true will prevent any further bubbling of the event to the dialogs parents and will also prevent any child dialogs from performing their default processing.

    • Called when the component has been requested to re-prompt the user for input.

      Parameters

      • _context: TurnContext

        Context for the current turn of conversation.

      • _instance: DialogInstance

        The instance of the current dialog.

      Returns Promise<void>

      A promise representing the asynchronous operation.

      The active child dialog will have already been asked to reprompt before this method is called.

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

      Parameters

      • outerDialogContext: DialogContext

        The DialogContext for the current turn of conversation.

      • _reason: DialogReason

        Reason why the dialog resumed.

      • Optional_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.

      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 DialogContext.replaceDialog(string, object) 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(ITurnContext, DialogInstance) when the user replies.