Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 16 additions & 21 deletions libraries/botbuilder-dialogs/botbuilder/dialogs/component_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async def continue_dialog(self, dialog_context: DialogContext) -> DialogTurnResu
Called when the dialog is continued, where it is the active dialog and the
user replies with a new activity.

.. note::
.. 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.
Expand Down Expand Up @@ -119,23 +119,13 @@ async def resume_dialog(
Called when a child dialog on the parent's dialog stack completed this turn, returning
control to this dialog component.

.. note::
.. 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
:meth:resume_dialog() when the pushed on dialog ends.
:meth:`ComponentDialog.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.

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 :meth:`def async begin_dialog()`
in the parent's context. However, if the :meth:`DialogContext.replace_dialog()` method is
is called, the logical child dialog may be different than the original.

If this method is *not* overridden, the dialog automatically calls its
:meth:`asyn def reprompt_dialog()` when the user replies.

:param dialog_context: The :class:`DialogContext` for the current turn of the conversation.
:type dialog_context: :class:`DialogContext`
:param reason: Reason why the dialog resumed.
Expand All @@ -157,7 +147,7 @@ async def reprompt_dialog(
Called when the dialog should re-prompt the user for input.

:param context: The context object for this turn.
:type context: :class:`TurnContext`
:type context: :class:`botbuilder.core.TurnContext`
:param instance: State information for this dialog.
:type instance: :class:`DialogInstance`
"""
Expand All @@ -176,7 +166,7 @@ async def end_dialog(
Called when the dialog is ending.

:param context: The context object for this turn.
:type context: :class:`TurnContext`
:type context: :class:`botbuilder.core.TurnContext`
:param instance: State information associated with the instance of this component dialog
on its parent's dialog stack.
:type instance: :class:`DialogInstance`
Expand All @@ -193,7 +183,6 @@ async def end_dialog(
def add_dialog(self, dialog: Dialog) -> object:
"""
Adds a :class:`Dialog` to the component dialog and returns the updated component.
Adding a new dialog will inherit the :class:`BotTelemetryClient` of the :class:`ComponentDialog`.

:param dialog: The dialog to add.
:return: The updated :class:`ComponentDialog`
Expand All @@ -220,7 +209,7 @@ async def on_begin_dialog(
"""
Called when the dialog is started and pushed onto the parent's dialog stack.

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

Expand All @@ -237,6 +226,12 @@ async def on_begin_dialog(
return await inner_dc.begin_dialog(self.initial_dialog_id, options)

async def on_continue_dialog(self, inner_dc: DialogContext) -> DialogTurnResult:
"""
Called when the dialog is continued, where it is the active dialog and the user replies with a new activity.

:param inner_dc: The inner :class:`DialogContext` for the current turn of conversation.
:type inner_dc: :class:`DialogContext`
"""
return await inner_dc.continue_dialog()

async def on_end_dialog( # pylint: disable=unused-argument
Expand All @@ -245,8 +240,8 @@ async def on_end_dialog( # pylint: disable=unused-argument
"""
Ends the component dialog in its parent's context.

:param turn_context: The :class:`TurnContext` for the current turn of the conversation.
:type turn_context: :class:`TurnContext`
:param turn_context: The :class:`botbuilder.core.TurnContext` for the current turn of the conversation.
:type turn_context: :class:`botbuilder.core.TurnContext`
:param instance: State information associated with the instance of this component dialog on
its parent's dialog stack.
:type instance: :class:`DialogInstance`
Expand All @@ -259,7 +254,7 @@ async def on_reprompt_dialog( # pylint: disable=unused-argument
self, turn_context: TurnContext, instance: DialogInstance
) -> None:
"""
:param turn_context: The :class:`TurnContext` for the current turn of the conversation.
:param turn_context: The :class:`botbuilder.core.TurnContext` for the current turn of the conversation.
:type turn_context: :class:`DialogInstance`
:param instance: State information associated with the instance of this component dialog
on its parent's dialog stack.
Expand All @@ -273,7 +268,7 @@ async def end_component(
"""
Ends the component dialog in its parent's context.

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class DialogReason(Enum):

:var BeginCalled: A dialog is being started through a call to `DialogContext.begin()`.
:vartype BeginCalled: int
:var ContinuCalled: A dialog is being continued through a call to `DialogContext.continue_dialog()`.
:var ContinueCalled: A dialog is being continued through a call to `DialogContext.continue_dialog()`.
:vartype ContinueCalled: int
:var EndCalled: A dialog ended normally through a call to `DialogContext.end_dialog()
:vartype EndCalled: int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ def __init__(self, stack: List[DialogInstance] = None):
@property
def dialog_stack(self):
"""
Initializes a new instance of the :class:`DialogState` class.
Initializes a new instance of the :class:`DialogState` class.

:return: The state information to initialize the stack with.
:rtype: list
:return: The state information to initialize the stack with.
:rtype: list
"""
return self._dialog_stack

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class DialogTurnResult:
"""
Result returned to the caller of one of the various stack manipulation methods.

Use :meth:`DialogContext.end_dialogAsync()` to end a :class:`Dialog` and
Use :meth:`DialogContext.end_dialog()` to end a :class:`Dialog` and
return a result to the calling context.
"""

Expand All @@ -27,7 +27,7 @@ def status(self):
"""
Gets or sets the current status of the stack.

:return self._status:
:return self._status: The status of the stack.
:rtype self._status: :class:`DialogTurnStatus`
"""
return self._status
Expand All @@ -37,10 +37,12 @@ def result(self):
"""
Final result returned by a dialog that just completed.

.. note::
.. remarks::
This will only be populated in certain cases:
* The bot calls :meth:`DialogContext.begin_dialog()` to start a new dialog and the dialog ends immediately.
* The bot calls :meth:`DialogContext.continue_dialog()` and a dialog that was active ends.
* The bot calls :meth:`DialogContext.begin_dialog()` to start a new
dialog and the dialog ends immediately.
* The bot calls :meth:`DialogContext.continue_dialog()` and a dialog
that was active ends.

:return self._result: Final result returned by a dialog that just completed.
:rtype self._result: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ActivityPrompt(Dialog, ABC):
"""
Waits for an activity to be received.

.. remarks:
.. remarks::
This prompt requires a validator be passed in and is useful when waiting for non-message
activities like an event to be received. The validator can ignore received events until the
expected activity is received.
Expand Down Expand Up @@ -156,10 +156,10 @@ async def resume_dialog( # pylint: disable=unused-argument
Called when a prompt dialog resumes being the active dialog on the dialog stack, such
as when the previous active dialog on the stack completes.

.. note:
.. remarks::
Prompts 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 prompt receiving an unexpected call to
:meth:resume_dialog() when the pushed on dialog ends.
:meth:`ActivityPrompt.resume_dialog()` when the pushed on dialog ends.
To avoid the prompt prematurely ending, we need to implement this method and
simply re-prompt the user.

Expand Down Expand Up @@ -212,7 +212,7 @@ async def on_recognize( # pylint: disable=unused-argument
When overridden in a derived class, attempts to recognize the incoming activity.

:param context: Context for the current turn of conversation with the user.
:type context: :class:`TurnContext`
:type context: :class:`botbuilder.core.TurnContext`
:param state: Contains state for the current instance of the prompt on the dialog stack.
:type state: :class:`typing.Dict[str, dict]`
:param options: A prompt options object
Expand Down