ChoicePrompt class
Prompts a user to select from a list of choices.
- Extends
Remarks
By default the prompt will return to the calling dialog a FoundChoice
object containing the
choice that was selected.
Constructors
Choice |
Creates a new |
Properties
choice |
Additional options passed to the |
default |
The prompts default locale that should be recognized. |
id | Unique ID of the dialog. Sets the unique ID of the dialog. |
recognizer |
Additional options passed to the underlying |
style | Style of the "yes" and "no" choices rendered to the user when prompting. |
telemetry |
Gets the telemetry client for this dialog. Sets the telemetry client for this dialog. |
Inherited Properties
End |
Gets a default end-of-turn result. |
Inherited Methods
begin |
Called when a prompt dialog is pushed onto the dialog stack and is being activated. |
configure(Record<string, unknown>) | Fluent method for configuring the object. |
continue |
Called when a prompt dialog is the active dialog and the user replied with a new activity. |
end |
When overridden in a derived class, performs clean up for the dialog before it ends. |
get |
|
get |
An encoded string used to aid in the detection of bot changes on re-deployment. |
on |
Called when an event has been raised, using |
reprompt |
Called when a prompt dialog has been requested to re-prompt the user for input. |
resume |
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. |
Constructor Details
ChoicePrompt(string, PromptValidator<FoundChoice>, string, ChoiceDefaultsChoicePrompt)
Creates a new ChoicePrompt
instance.
new ChoicePrompt(dialogId: string, validator?: PromptValidator<FoundChoice>, defaultLocale?: string, choiceDefaults?: ChoiceDefaultsChoicePrompt)
Parameters
- dialogId
-
string
Unique ID of the dialog within its parent DialogSet
.
- validator
(Optional) validator that will be called each time the user responds to the prompt. If the validator replies with a message no additional retry prompt will be sent.
- defaultLocale
-
string
(Optional) locale to use if dc.context.activity.locale
not specified. Defaults to a value of en-us
.
- choiceDefaults
- ChoiceDefaultsChoicePrompt
(Optional) 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.
Property Details
choiceOptions
Additional options passed to the ChoiceFactory
and used to tweak the style of choices
rendered to the user.
choiceOptions: ChoiceFactoryOptions | undefined
Property Value
ChoiceFactoryOptions | undefined
defaultLocale
The prompts default locale that should be recognized.
defaultLocale: string | undefined
Property Value
string | undefined
id
Unique ID of the dialog. Sets the unique ID of the dialog.
string id
Property Value
string
The Id for the dialog.
Remarks
This will be automatically generated if not specified.
recognizerOptions
Additional options passed to the underlying recognizeChoices()
function.
recognizerOptions: FindChoicesOptions | undefined
Property Value
FindChoicesOptions | undefined
style
Style of the "yes" and "no" choices rendered to the user when prompting.
style: ListStyle
Property Value
Remarks
Defaults to ListStyle.auto
.
telemetryClient
Gets the telemetry client for this dialog. Sets the telemetry client for this dialog.
BotTelemetryClient telemetryClient
Property Value
BotTelemetryClient
The BotTelemetryClient to use for logging.
Inherited Property Details
EndOfTurn
Gets a default end-of-turn result.
static EndOfTurn: DialogTurnResult
Property Value
Remarks
This result indicates that a dialog (or a logical step within a dialog) has completed processing for the current turn, is still active, and is waiting for more input.
Inherited From Dialog.EndOfTurn
Inherited Method Details
beginDialog(DialogContext, PromptOptions)
Called when a prompt dialog is pushed onto the dialog stack and is being activated.
function beginDialog(dc: DialogContext, options: PromptOptions): Promise<DialogTurnResult>
Parameters
The DialogContext for the current turn of the conversation.
- options
- PromptOptions
Optional. PromptOptions, additional information to pass to the prompt being started.
Returns
Promise<DialogTurnResult>
A Promise
representing the asynchronous operation.
Remarks
If the task is successful, the result indicates whether the prompt is still active after the turn has been processed by the prompt.
Inherited From Prompt.beginDialog
configure(Record<string, unknown>)
Fluent method for configuring the object.
function configure(config: Record<string, unknown>): this
Parameters
- config
-
Record<string, unknown>
Configuration settings to apply.
Returns
this
The Configurable after the operation is complete.
Inherited From Configurable.configure
continueDialog(DialogContext)
Called when a prompt dialog is the active dialog and the user replied with a new activity.
function continueDialog(dc: DialogContext): Promise<DialogTurnResult>
Parameters
The DialogContext for the current turn of conversation.
Returns
Promise<DialogTurnResult>
A Promise
representing the asynchronous operation.
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 prompt generally continues to receive the user's replies until it accepts the user's reply as valid input for the prompt.
Inherited From Prompt.continueDialog
endDialog(TurnContext, DialogInstance, DialogReason)
When overridden in a derived class, performs clean up for the dialog before it ends.
function endDialog(_context: TurnContext, _instance: DialogInstance, _reason: DialogReason): Promise<void>
Parameters
- _context
-
TurnContext
The context object for the turn.
- _instance
- DialogInstance
Current state information for this dialog.
- _reason
- DialogReason
The reason the dialog is ending.
Returns
Promise<void>
Remarks
Derived dialogs that need to perform logging or cleanup before ending should override this method. By default, this method has no effect.
The DialogContext calls this method when the current dialog is ending.
See also
Inherited From Dialog.endDialog
getConverter(string)
function getConverter(_property: string): Converter | ConverterFactory
Parameters
- _property
-
string
The key of the conditional selector configuration.
Returns
The converter for the selector configuration.
Inherited From Configurable.getConverter
getVersion()
An encoded string used to aid in the detection of bot changes on re-deployment.
function getVersion(): string
Returns
string
Unique string which should only change when dialog has changed in a way that should restart the dialog.
Remarks
This defaults to returning the dialogs id but can be overridden to provide more
precise change detection logic. Any dialog on the stack that has its version change will
result in a versionChanged
event will be raised. If this event is not handled by the bot,
an error will be thrown resulting in the bots error handler logic being run.
Returning an empty string will disable version tracking for the component all together.
Inherited From Dialog.getVersion
onDialogEvent(DialogContext, DialogEvent)
Called when an event has been raised, using DialogContext.emitEvent()
, by either the current dialog or a dialog that the current dialog started.
function onDialogEvent(dc: DialogContext, e: DialogEvent): Promise<boolean>
Parameters
The dialog context for the current turn of conversation.
The event being raised.
Returns
Promise<boolean>
True if the event is handled by the current dialog and bubbling should stop.
Inherited From Dialog.onDialogEvent
repromptDialog(TurnContext, DialogInstance)
Called when a prompt dialog has been requested to re-prompt the user for input.
function repromptDialog(context: TurnContext, instance: DialogInstance): Promise<void>
Parameters
- context
-
TurnContext
(xref:botbuilder-core.TurnContext), context for the current turn of conversation with the user.
- instance
- DialogInstance
(xref:botbuilder-dialogs.DialogInstance), the instance of the dialog on the stack.
Returns
Promise<void>
A Promise
representing the asynchronous operation.
Inherited From Prompt.repromptDialog
resumeDialog(DialogContext, DialogReason, any)
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.
function resumeDialog(dc: DialogContext, _reason: DialogReason, _result?: any): Promise<DialogTurnResult>
Parameters
The DialogContext for the current turn of the conversation.
- _reason
- DialogReason
An enum indicating why the dialog resumed.
- _result
-
any
Optional, value returned from the previous dialog on the stack. The type of the value returned is dependent on the previous dialog.
Returns
Promise<DialogTurnResult>
A Promise representing the asynchronous operation.
Remarks
If the task is successful, the result indicates whether the dialog is still active after the turn has been processed by the dialog.
Inherited From Prompt.resumeDialog