Prompt<T> Class
- java.
lang. Object - com.
microsoft. bot. dialogs. Dialog - com.
microsoft. bot. dialogs. prompts. Prompt<T>
- com.
- com.
Type Parameters
- T
Type the prompt is created for.
public abstract class Prompt<T>
extends Dialog
Defines the core behavior of prompt dialogs. When the prompt ends, it should return a Object that represents the value that was prompted for. Use add(Dialog dialog) or addDialog(Dialog dialog) to add a prompt to a dialog set or component dialog, respectively. Use prompt(String dialogId, PromptOptions options) or beginDialog(String dialogId, Object options) to start the prompt. If you start a prompt from a WaterfallStep in a WaterfallDialog, then the prompt result will be available in the next step of the waterfall.
Field Summary
| Modifier and Type | Field and Description |
|---|---|
| static final java.lang.String | ATTEMPTCOUNTKEY |
Constructor Summary
| Constructor | Description |
|---|---|
| Prompt(String dialogId, PromptValidator<T> validator) |
Initializes a new instance of the {@link Prompt{T}} class. |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
| protected Activity |
appendChoices(Activity prompt, String channelId, List<Choice> choices, ListStyle style, ChoiceFactoryOptions options)
When overridden in a derived class, appends choices to the activity when the user is prompted for input. |
|
java.util.concurrent.CompletableFuture<Dialog |
beginDialog(DialogContext dc, Object options)
Called when a prompt dialog is pushed onto the dialog stack and is being activated. |
|
java.util.concurrent.CompletableFuture<Dialog |
continueDialog(DialogContext dc)
Called when a prompt dialog is the active dialog and the user replied with a new activity. |
| protected java.util.concurrent.CompletableFuture<java.lang.Boolean> |
onPreBubbleEvent(DialogContext dc, DialogEvent e)
Called before an event is bubbled to its parent. |
| protected abstract java.util.concurrent.CompletableFuture<java.lang.Void> |
onPrompt(TurnContext turnContext, Map<String,Object> state, PromptOptions options, Boolean isRetry)
When overridden in a derived class, prompts the user for input. |
|
protected abstract
java.util.concurrent.CompletableFuture<Prompt |
onRecognize(TurnContext turnContext, Map<String,Object> state, PromptOptions options)
When overridden in a derived class, attempts to recognize the user's input. |
| java.util.concurrent.CompletableFuture<java.lang.Void> |
repromptDialog(TurnContext turnContext, DialogInstance instance)
Called when a prompt dialog has been requested to re-prompt the user for input. |
|
java.util.concurrent.CompletableFuture<Dialog |
resumeDialog(DialogContext dc, DialogReason reason, Object result)
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. |
Methods inherited from Dialog
Methods inherited from java.lang.Object
Field Details
ATTEMPTCOUNTKEY
public static final String ATTEMPTCOUNTKEY
Constructor Details
Prompt
public Prompt(String dialogId, PromptValidator
Initializes a new instance of the {@link Prompt{T}} class. Called from constructors in derived classes to initialize the {@link Prompt{T}} class.
Parameters:
The value of dialogId must be unique within the
<xref uid="com.microsoft.bot.dialogs.DialogSet" data-throw-if-not-resolved="false" data-raw-source="com.microsoft.bot.dialogs.DialogSet"></xref> or
<xref uid="com.microsoft.bot.dialogs.ComponentDialog" data-throw-if-not-resolved="false" data-raw-source="com.microsoft.bot.dialogs.ComponentDialog"></xref> to which
the prompt is added.
Method Details
appendChoices
protected Activity appendChoices(Activity prompt, String channelId, List
When overridden in a derived class, appends choices to the activity when the user is prompted for input.
Parameters:
Returns:
If the task is successful, the result contains the updated activity.
beginDialog
public CompletableFuture
Called when a prompt dialog is pushed onto the dialog stack and is being activated.
Overrides:
Prompt<T>.beginDialog(DialogContext dc, Object options)Parameters:
Returns:
If the task is successful, the result indicates whether the prompt is
still active after the turn has been processed by the prompt.
continueDialog
public CompletableFuture
Called when a prompt dialog is the active dialog and the user replied with a new activity.
Overrides:
Prompt<T>.continueDialog(DialogContext dc)Parameters:
Returns:
If the task is successful, the result indicates whether the dialog is
still active after the turn has been processed by the dialog. The
prompt generally continues to receive the user's replies until it
accepts the user's reply as valid input for the prompt.
onPreBubbleEvent
protected CompletableFuture
Called before an event is bubbled to its parent. 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.
Overrides:
Prompt<T>.onPreBubbleEvent(DialogContext dc, DialogEvent e)Parameters:
Returns:
onPrompt
protected abstract CompletableFuture
When overridden in a derived class, prompts the user for input.
Parameters:
Returns:
onRecognize
protected abstract CompletableFuture
When overridden in a derived class, attempts to recognize the user's input.
Parameters:
Returns:
If the task is successful, the result describes the result of the
recognition attempt.
repromptDialog
public CompletableFuture
Called when a prompt dialog has been requested to re-prompt the user for input.
Overrides:
Prompt<T>.repromptDialog(TurnContext turnContext, DialogInstance instance)Parameters:
Returns:
resumeDialog
public CompletableFuture
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.
Overrides:
Prompt<T>.resumeDialog(DialogContext dc, DialogReason reason, Object result)Parameters:
Returns:
If the task is successful, the result indicates whether the dialog is
still active after the turn has been processed by the dialog.