Edit

ComponentDialog Class

A Dialog that is composed of other dialogs

Initializes a new instance of the ComponentDialog

Constructor

ComponentDialog(dialog_id: str)

Parameters

Name Description
dialog_id
Required
str

The ID to assign to the new dialog within the parent dialog set.

Variables

Name Description
state
<xref:persisted_dialog>

Methods

add_dialog

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

begin_dialog

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

If the task is successful, the result indicates whether the dialog is still active after the turn has been processed by the dialog.

continue_dialog

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

end_component

Ends the component dialog in its parent's context.

end_dialog

Called when the dialog is ending.

find_dialog

Finds a dialog by ID.

on_begin_dialog

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

on_continue_dialog

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

on_end_dialog

Ends the component dialog in its parent's context.

on_reprompt_dialog
reprompt_dialog

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

resume_dialog

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

add_dialog

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

add_dialog(dialog: Dialog) -> object

Parameters

Name Description
dialog
Required

The dialog to add.

Returns

Type Description

The updated ComponentDialog.

begin_dialog

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

If the task is successful, the result indicates whether the dialog is still active after the turn has been processed by the dialog.

async begin_dialog(dialog_context: DialogContext, options: object = None) -> DialogTurnResult

Parameters

Name Description
dialog_context
Required

The DialogContext for the current turn of the conversation.

options

Optional, initial information to pass to the dialog.

Default value: None

Returns

Type Description

Signals the end of the turn

continue_dialog

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

async continue_dialog(dialog_context: DialogContext) -> DialogTurnResult

Parameters

Name Description
dialog_context
Required

The parent dialog context for the current turn of the conversation.

Returns

Type Description

Signals the end of the turn

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.

If this method is not overriden the component dialog calls the continue_dialog method on it's inner dialog context. If the inner dialog stack is empty, the component dialog ends, and if a result is available, the component dialog uses that as it's return value.

end_component

Ends the component dialog in its parent's context.

async end_component(outer_dc: DialogContext, result: object) -> DialogTurnResult

Parameters

Name Description
outer_dc
Required

The parent dialog context for the current turn of conversation.

result
Required

Optional, value to return from the dialog component to the parent context.

Returns

Type Description

Value to return.

Remarks

If the task is successful, the result indicates that the dialog ended after the turn was processed by the dialog.

end_dialog

Called when the dialog is ending.

async end_dialog(context: TurnContext, instance: DialogInstance, reason: DialogReason) -> None

Parameters

Name Description
context
Required

The context object for this turn.

instance
Required

State information associated with the instance of this component dialog.

reason
Required

Reason why the dialog ended.

find_dialog

Finds a dialog by ID.

async find_dialog(dialog_id: str) -> Dialog

Parameters

Name Description
dialog_id
Required

The dialog to add.

Returns

Type Description

The dialog; or None if there is not a match for the ID.

on_begin_dialog

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

async on_begin_dialog(inner_dc: DialogContext, options: object) -> DialogTurnResult

Parameters

Name Description
inner_dc
Required

The inner dialog context for the current turn of conversation.

options
Required

Optional, initial information to pass to the dialog.

Remarks

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 begin_dialog method of the component dialog's initial dialog.

Override this method in a derived class to implement interrupt logic.

on_continue_dialog

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

async on_continue_dialog(inner_dc: DialogContext) -> DialogTurnResult

Parameters

Name Description
inner_dc
Required

The inner dialog context for the current turn of conversation.

on_end_dialog

Ends the component dialog in its parent's context.

async on_end_dialog(context: TurnContext, instance: DialogInstance, reason: DialogReason) -> None

Parameters

Name Description
turn_context
Required

The TurnContext for the current turn of the conversation.

instance
Required

State information associated with the inner dialog stack of this component dialog.

reason
Required

Reason why the dialog ended.

context
Required

on_reprompt_dialog

async on_reprompt_dialog(turn_context: TurnContext, instance: DialogInstance) -> None

Parameters

Name Description
turn_context
Required

The TurnContext for the current turn of the conversation.

instance
Required

State information associated with the inner dialog stack of this component dialog.

reprompt_dialog

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

async reprompt_dialog(context: TurnContext, instance: DialogInstance) -> None

Parameters

Name Description
context
Required

The context object for this turn.

instance
Required

State information for this dialog.

resume_dialog

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

async resume_dialog(dialog_context: DialogContext, reason: DialogReason, result: object = None) -> DialogTurnResult

Parameters

Name Description
dialog_context
Required

The dialog context for the current turn of the conversation.

reason
Required

Reason why the dialog resumed.

result

Optional, value returned from the dialog that was called.

Default value: None

Returns

Type Description

Signals the end of the turn

Remarks

Containers are typically leaf nodes on the stack but the dev is free to push other dialogs on top of the stack which will result in the container receiving an unexpected call to resume_dialog when the pushed on dialog ends. To avoid the container prematurely ending we need to implement this method and simply ask our inner dialog stack to re-prompt.

Attributes

persisted_dialog_state

persisted_dialog_state = 'dialogs'