ChoicePrompt Class

public class ChoicePrompt
extends Prompt<FoundChoice>

Prompts a user to select from a list of choices.

Constructor Summary

Constructor Description
ChoicePrompt(String dialogId)

Initializes a new instance of the ChoicePrompt class.

ChoicePrompt(String dialogId, PromptValidator<FoundChoice> validator, String defaultLocale)

Initializes a new instance of the ChoicePrompt class.

ChoicePrompt(String dialogId, Map<String,ChoiceFactoryOptions> choiceDefaults, PromptValidator<FoundChoice> validator, String defaultLocale)

Initializes a new instance of the ChoicePrompt class.

Method Summary

Modifier and Type Method and Description
ChoiceFactoryOptions getChoiceOptions()

Gets additional options passed to the ChoiceFactory and used to tweak the style of choices rendered to the user.

java.lang.String getDefaultLocale()

Sets or sets the default locale used to determine language-specific behavior of the prompt.

FindChoicesOptions getRecognizerOptions()

Gets or sets additional options passed to the underlying {@link ChoiceRecognizers#recognizeChoices(String, IList{Choice}, FindChoicesOptions)} method.

ListStyle getStyle()

Gets the style to use when presenting the prompt to the user.

protected java.util.concurrent.CompletableFuture<java.lang.Void> onPrompt(TurnContext turnContext, Map<String,Object> state, PromptOptions options, Boolean isRetry)

Prompts the user for input.

protected java.util.concurrent.CompletableFuture<PromptRecognizerResult<FoundChoice>> onRecognize(TurnContext turnContext, Map<String,Object> state, PromptOptions options)

Attempts to recognize the user's input.

void setChoiceOptions(ChoiceFactoryOptions choiceOptions)

Sets additional options passed to the ChoiceFactory and used to tweak the style of choices rendered to the user.

void setDefaultLocale(String defaultLocale)

Sets the default locale used to determine language-specific behavior of the prompt.

void setRecognizerOptions(FindChoicesOptions recognizerOptions)

Gets or sets additional options passed to the underlying {@link ChoiceRecognizers#recognizeChoices(String, IList{Choice}, FindChoicesOptions)} method.

void setStyle(ListStyle style)

Sets the style to use when presenting the prompt to the user.

Methods inherited from Dialog

Methods inherited from Prompt

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

ChoicePrompt

public ChoicePrompt(String dialogId)

Initializes a new instance of the ChoicePrompt class.

Parameters:

dialogId - The ID to assign to this prompt.

ChoicePrompt

public ChoicePrompt(String dialogId, PromptValidator validator, String defaultLocale)

Initializes a new instance of the ChoicePrompt class.

Parameters:

dialogId - The ID to assign to this prompt.
validator - Optional, a {@link PromptValidator{FoundChoice}} that contains additional, custom validation for this prompt.
defaultLocale - Optional, the default locale used to determine language-specific behavior of the prompt. The locale is a 2, 3, or 4 character ISO 639 code that represents a language or language family.
                  The value of <xref uid="" data-throw-if-not-resolved="false" data-raw-source="dialogId"></xref> 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. If the <xref uid="com.microsoft.bot.schema.Activity.locale" data-throw-if-not-resolved="false" data-raw-source="Activity#locale"></xref> of
                  the <xref uid="com.microsoft.bot.dialogs.DialogContext" data-throw-if-not-resolved="false" data-raw-source="DialogContext"></xref> .<xref uid="com.microsoft.bot.dialogs.DialogContext.context" data-throw-if-not-resolved="false" data-raw-source="DialogContext#context"></xref>
                  .<xref uid="" data-throw-if-not-resolved="false" data-raw-source="ITurnContext#activity"></xref> is specified, then that
                  local is used to determine language specific behavior;
                  otherwise the <xref uid="" data-throw-if-not-resolved="false" data-raw-source="defaultLocale"></xref> is used. US-English
                  is the used if no language or default locale is
                  available, or if the language or locale is not otherwise
                  supported.

ChoicePrompt

public ChoicePrompt(String dialogId, Map choiceDefaults, PromptValidator validator, String defaultLocale)

Initializes a new instance of the ChoicePrompt class.

Parameters:

dialogId - The ID to assign to this prompt.
choiceDefaults - Overrides the dictionary of Bot Framework SDK-supported _choiceDefaults (for prompt localization). Must be passed in to each ConfirmPrompt that needs the custom choice defaults. The value of dialogId must be unique within the DialogSet or ComponentDialog to which the prompt is added. If the Activity#locale of the DialogContext .DialogContext#context .ITurnContext#activity is specified, then that local is used to determine language specific behavior; otherwise the defaultLocale is used. US-English is the used if no language or default locale is available, or if the language or locale is not otherwise supported.
validator - Optional, a {@link PromptValidator{FoundChoice}} that contains additional, custom validation for this prompt.
defaultLocale - Optional, the default locale used to determine language-specific behavior of the prompt. The locale is a 2, 3, or 4 character ISO 639 code that represents a language or language family.

Method Details

getChoiceOptions

public ChoiceFactoryOptions getChoiceOptions()

Gets additional options passed to the ChoiceFactory and used to tweak the style of choices rendered to the user.

Returns:

Additional options for presenting the set of choices.

getDefaultLocale

public String getDefaultLocale()

Sets or sets the default locale used to determine language-specific behavior of the prompt.

Returns:

The default locale used to determine language-specific behavior of the prompt.

getRecognizerOptions

public FindChoicesOptions getRecognizerOptions()

Gets or sets additional options passed to the underlying {@link ChoiceRecognizers#recognizeChoices(String, IList{Choice}, FindChoicesOptions)} method.

Returns:

Options to control the recognition strategy.

getStyle

public ListStyle getStyle()

Gets the style to use when presenting the prompt to the user.

Returns:

The style to use when presenting the prompt to the user.

onPrompt

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

Prompts the user for input.

Overrides:

ChoicePrompt.onPrompt(TurnContext turnContext, Map<String,Object> state, PromptOptions options, Boolean isRetry)

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 - true if this is the first time this prompt dialog instance on the stack is prompting the user for input; otherwise, false.

Returns:

A CompletableFuture representing the asynchronous operation.

onRecognize

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

Attempts to recognize the user's input.

Overrides:

ChoicePrompt.onRecognize(TurnContext turnContext, Map<String,Object> state, PromptOptions options)

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.

setChoiceOptions

public void setChoiceOptions(ChoiceFactoryOptions choiceOptions)

Sets additional options passed to the ChoiceFactory and used to tweak the style of choices rendered to the user.

Parameters:

choiceOptions - Additional options for presenting the set of choices.

setDefaultLocale

public void setDefaultLocale(String defaultLocale)

Sets the default locale used to determine language-specific behavior of the prompt.

Parameters:

defaultLocale - The default locale used to determine language-specific behavior of the prompt.

setRecognizerOptions

public void setRecognizerOptions(FindChoicesOptions recognizerOptions)

Gets or sets additional options passed to the underlying {@link ChoiceRecognizers#recognizeChoices(String, IList{Choice}, FindChoicesOptions)} method.

Parameters:

recognizerOptions - Options to control the recognition strategy.

setStyle

public void setStyle(ListStyle style)

Sets the style to use when presenting the prompt to the user.

Parameters:

style - The style to use when presenting the prompt to the user.

Applies to