24
24
25
25
class Prompt (Dialog ):
26
26
"""
27
+
27
28
Defines the core behavior of prompt dialogs. Extends the :class:`Dialog` base class.
28
29
29
30
.. remarks::
31
+
30
32
When the prompt ends, it returns an object that represents the value it was prompted for.
31
- Use :meth:`DialogSet.add()` or :meth:`ComponentDialog.add_dialog()` to add a prompt to a dialog set or
32
- component dialog, respectively.
33
+ Use :meth:`DialogSet.add()` or :meth:`ComponentDialog.add_dialog()` to add a prompt to
34
+ a dialog set or component dialog, respectively.
33
35
Use :meth:`DialogContext.prompt()` or :meth:`DialogContext.begin_dialog()` to start the prompt.
34
- If you start a prompt from a :class:`WaterfallStep` in a :class:`WaterfallDialog`, then the prompt result
35
- will be available in the next step of the waterfall.
36
+ If you start a prompt from a :class:`WaterfallStep` in a :class:`WaterfallDialog`, then the
37
+ prompt result will be available in the next step of the waterfall.
38
+
36
39
"""
37
40
38
41
ATTEMPT_COUNT_KEY
8000
span> = "AttemptCount"
@@ -63,13 +66,13 @@ async def begin_dialog(
63
66
:param dialog_context: The dialog context for the current turn of the conversation
64
67
:type dialog_context: :class:`DialogContext`
65
68
:param options: Optional, additional information to pass to the prompt being started
66
- :type options: Object
69
+ :type options: object
67
70
:return: The dialog turn result
68
71
:rtype: :class:`DialogTurnResult`
69
72
70
73
.. note::
71
- If the task is successful, the result indicates whether the prompt is still active
72
- after the turn has been processed.
74
+
75
+ If the task is successful, the result indicates whether the prompt is still active after the turn has been processed.
73
76
"""
74
77
if not dialog_context :
75
78
raise TypeError ("Prompt(): dc cannot be None." )
@@ -111,6 +114,7 @@ async def continue_dialog(self, dialog_context: DialogContext):
111
114
active after the turn has been processed by the dialog.
112
115
The prompt generally continues to receive the user's replies until it accepts the
113
116
user's reply as valid input for the prompt.
117
+
114
118
"""
115
119
if not dialog_context :
116
120
raise TypeError ("Prompt(): dc cannot be None." )
@@ -150,26 +154,29 @@ async def resume_dialog(
150
154
self , dialog_context : DialogContext , reason : DialogReason , result : object
151
155
) -> DialogTurnResult :
152
156
"""
153
- Resumes a dialog. C
157
+ Resumes a dialog.
158
+
154
159
:param dialog_context: The dialog context for the current turn of the conversation.
155
- :type dialog_context: :class:DialogContext
160
+ :type dialog_context: :class:` DialogContext`
156
161
:param reason: An enum indicating why the dialog resumed.
157
- :type reason: :class:DialogReason
162
+ :type reason: :class:` DialogReason`
158
163
:param result: Optional, value returned from the previous dialog on the stack.
159
164
The type of the value returned is dependent on the previous dialog.
160
165
:type result: object
161
166
:return: The dialog turn result
162
167
:rtype: :class:`DialogTurnResult`
163
168
164
169
.. remarks::
170
+
165
171
Called when a prompt dialog resumes being the active dialog on the dialog stack,
166
172
such as when the previous active dialog on the stack completes.
167
173
If the task is successful, the result indicates whether the dialog is still
168
174
active after the turn has been processed by the dialog.
169
175
Prompts are typically leaf nodes on the stack but the dev is free to push other dialogs
170
176
on top of the stack which will result in the prompt receiving an unexpected call to
171
177
:meth:resume_dialog() when the pushed on dialog ends.
172
- To avoid the prompt prematurely ending we need to simply re-prompt the user.
178
+ Simply re-prompt the user to avoid that the prompt ends prematurely.
179
+
173
180
"""
174
181
await self .reprompt_dialog (dialog_context .context , dialog_context .active_dialog )
175
182
return Dialog .end_of_turn
@@ -179,11 +186,11 @@ async def reprompt_dialog(self, context: TurnContext, instance: DialogInstance):
179
186
Reprompts user for input. Called when a prompt dialog has been requested to re-prompt the user for input.
180
187
181
188
:param context: Context for the current turn of conversation with the user
182
- :type context: :class:TurnContext
189
+ :type context: :class:`botbuilder.core. TurnContext`
183
190
:param instance: The instance of the dialog on the stack
184
- :type instance: :class:DialogInstance
185
- :return: A :class:Task representing the asynchronous operation
186
- :rtype: :class:Task
191
+ :type instance: :class:` DialogInstance`
192
+ :return: A task representing the asynchronous operation
193
+
187
194
"""
188
195
state = instance .state [self .persisted_state ]
189
196
options = instance .state [self .persisted_options ]
@@ -203,16 +210,16 @@ async def on_prompt(
203
210
:param turn_context: Context for the current turn of conversation with the user
204
211
:type turn_context: :class:`botbuilder.core.TurnContext`
205
212
:param state: Contains state for the current instance of the prompt on the dialog stack
206
- :type state: :class:Dict
213
+ :type state: :class:` Dict`
207
214
:param options: A prompt options object constructed from the options initially provided
208
- in the call :meth:`DialogContext.prompt(self, dialog_id: str, options )`
215
+ in the call :meth:`DialogContext.prompt()`
209
216
:type options: :class:`PromptOptions`
210
217
:param is_retry: true if this is the first time this prompt dialog instance on the stack is prompting
211
218
the user for input; otherwise, false
212
219
:type is_retry: bool
213
220
214
- :return: A :class:Task representing the asynchronous operation.
215
- :rtype: :class:Task
221
+ :return: A task representing the asynchronous operation.
222
+
216
223
"""
217
224
218
225
@abstractmethod
@@ -228,13 +235,13 @@ async def on_recognize(
228
235
:param turn_context: Context for the current turn of conversation with the user
229
236
:type turn_context: :class:`botbuilder.core.TurnContext`
230
237
:param state: Contains state for the current instance of the prompt on the dialog stack
231
- :type state: :class:Dict
238
+ :type state: :class:` Dict`
232
239
:param options: A prompt options object constructed from the options initially provided
233
- in the call :meth:`DialogContext.prompt(self, dialog_id: str, options )`
234
- :type options: :class:PromptOptions
240
+ in the call to :meth:`DialogContext.prompt()`
241
+ :type options: :class:` PromptOptions`
235
242
236
243
:return: A task representing the asynchronous operation.
237
- :rtype: :class:Task
244
+
238
245
"""
239
246
240
247
def append_choices (
@@ -258,14 +265,15 @@ def append_choices(
258
265
:type style: :class:`ListStyle`
259
266
:param: options: Optional formatting options to use when presenting the choices
260
267
:type style: :class:`ChoiceFactoryOptions`
261
- :return: A :class:Task representing the asynchronous operation
262
- :rtype: :class:Task
268
+
269
+ :return: A task representing the asynchronous operation
263
270
264
271
.. remarks::
265
272
If the task is successful, the result contains the updated activity.
266
273
When overridden in a derived class, appends choices to the activity when the user
267
274
is prompted for input. This is an helper function to compose an output activity
268
275
containing a set of choices.
276
+
269
277
"""
270
278
# Get base prompt text (if any)
271
279
text = prompt .text if prompt is not None and prompt .text else ""
0 commit comments