ActivityPrompt Class

public class ActivityPrompt
extends Dialog

Defines the core behavior of a prompt dialog that waits for an activity to be received. 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 activities until the expected activity type is received.

Constructor Summary

Constructor Description
ActivityPrompt(String dialogId, PromptValidator<Activity> validator)

Initializes a new instance of the ActivityPrompt class.

Method Summary

Modifier and Type Method and Description
java.util.concurrent.CompletableFuture<DialogTurnResult> beginDialog(DialogContext dc, Object options)

Called when a prompt dialog is pushed onto the dialog stack and is being activated.

java.util.concurrent.CompletableFuture<DialogTurnResult> 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.Void> onPrompt(TurnContext turnContext, Map<String,Object> state, PromptOptions options)

When overridden in a derived class, prompts the user for input.

protected 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 java.util.concurrent.CompletableFuture<PromptRecognizerResult<Activity>> onRecognize(TurnContext turnContext, Map<String,Object> state, PromptOptions options)

When overridden in a derived class, attempts to recognize the incoming activity.

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<DialogTurnResult> 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

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Constructor Details

ActivityPrompt

public ActivityPrompt(String dialogId, PromptValidator validator)

Initializes a new instance of the ActivityPrompt class. Called from constructors in derived classes to initialize the ActivityPrompt class.

Parameters:

dialogId - The ID to assign to this prompt.
validator - A PromptValidator<T> that contains validation for this prompt.
              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="DialogSet"></xref> or <xref uid="com.microsoft.bot.dialogs.ComponentDialog" data-throw-if-not-resolved="false" data-raw-source="ComponentDialog"></xref> to which the
              prompt is added.

Method Details

beginDialog

public CompletableFuture beginDialog(DialogContext dc, Object options)

Called when a prompt dialog is pushed onto the dialog stack and is being activated.

Overrides:

ActivityPrompt.beginDialog(DialogContext dc, Object options)

Parameters:

dc - The dialog context for the current turn of the conversation.
options - Optional, additional information to pass to the prompt being started.

Returns:

A CompletableFuture representing the asynchronous operation.
     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 continueDialog(DialogContext dc)

Called when a prompt dialog is the active dialog and the user replied with a new activity.

Overrides:

ActivityPrompt.continueDialog(DialogContext dc)

Parameters:

dc - The dialog context for the current turn of conversation.

Returns:

A CompletableFuture 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. The
     prompt generally continues to receive the user's replies until it
     accepts the user's reply as valid input for the prompt.

onPrompt

protected CompletableFuture onPrompt(TurnContext turnContext, Map state, PromptOptions options)

When overridden in a derived class, prompts the user for input.

Parameters:

turnContext - Context for the current turn of conversation with the user.
state - Contains state for the current instance of the prompt on the dialog stack.
options - A prompt options Object constructed from the options initially provided in the call to prompt(String dialogId, PromptOptions options) .

Returns:

A CompletableFuture representing the asynchronous operation.

onPrompt

protected CompletableFuture onPrompt(TurnContext turnContext, Map state, PromptOptions options, Boolean isRetry)

When overridden in a derived class, prompts the user for input.

Parameters:

turnContext - Context for the current turn of conversation with the user.
state - Contains state for the current instance of the prompt on the dialog stack.
options - A prompt options Object constructed from the options initially provided in the call to prompt(String dialogId, PromptOptions options) .
isRetry - A Boolean representing if the prompt is a retry.

Returns:

A CompletableFuture representing the result of the asynchronous operation.

onRecognize

protected CompletableFuture> onRecognize(TurnContext turnContext, Map state, PromptOptions options)

When overridden in a derived class, attempts to recognize the incoming activity.

Parameters:

turnContext - Context for the current turn of conversation with the user.
state - Contains state for the current instance of the prompt on the dialog stack.
options - A prompt options Object constructed from the options initially provided in the call to prompt(String dialogId, PromptOptions options) .

Returns:

A CompletableFuture representing the asynchronous operation.
     If the task is successful, the result describes the result of the
     recognition attempt.

repromptDialog

public CompletableFuture repromptDialog(TurnContext turnContext, DialogInstance instance)

Called when a prompt dialog has been requested to re-prompt the user for input.

Overrides:

ActivityPrompt.repromptDialog(TurnContext turnContext, DialogInstance instance)

Parameters:

turnContext - Context for the current turn of conversation with the user.
instance - The instance of the dialog on the stack.

Returns:

A CompletableFuture representing the asynchronous operation.

resumeDialog

public CompletableFuture 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.

Overrides:

ActivityPrompt.resumeDialog(DialogContext dc, DialogReason reason, Object result)

Parameters:

dc - The dialog context for the current turn of the conversation.
reason - An enum indicating why the dialog resumed.
result - Optional, value returned from the previous dialog on the stack. The type of the value returned is dependent on the previous dialog.

Returns:

A CompletableFuture 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.

Applies to