Share via


NumberPrompt class

Prompts a user to enter a number.

Extends

Prompt<number>

Remarks

By default the prompt will return to the calling dialog a number representing the users input.

Constructors

NumberPrompt(string, PromptValidator<number>, string)

Creates a new NumberPrompt instance.

Properties

defaultLocale

The prompts default locale that should be recognized.

id

Unique ID of the dialog.

Inherited Properties

EndOfTurn

Gets a default end-of-turn result.

Inherited Methods

beginDialog(DialogContext, PromptOptions)

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.

continueDialog(DialogContext)

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

endDialog(TurnContext, DialogInstance<any>, DialogReason)

When overridden in a derived class, performs clean up for the dialog before it ends.

getConverter(string)

Gets the converter for the selector configuration. *

getVersion()

An encoded string used to aid in the detection of agent changes on re-deployment.

onDialogEvent(DialogContext, DialogEvent)

Called when an event has been raised, using DialogContext.emitEvent method, by either the current dialog or a dialog that the current dialog started.

repromptDialog(TurnContext, DialogInstance<any>)

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

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.

Constructor Details

NumberPrompt(string, PromptValidator<number>, string)

Creates a new NumberPrompt instance.

new NumberPrompt(dialogId: string, validator?: PromptValidator<number>, defaultLocale?: string)

Parameters

dialogId

string

Unique ID of the dialog within its parent DialogSet or ComponentDialog.

validator

PromptValidator<number>

(Optional) validator that will be called each time the user responds to the prompt.

defaultLocale

string

(Optional) locale to use if the TurnContext.activity.locale is not specified. Defaults to a value of en-us.

Property Details

defaultLocale

The prompts default locale that should be recognized.

defaultLocale?: string

Property Value

string

id

Unique ID of the dialog.

string id

Property Value

string

The Id for the dialog.

Inherited Property Details

EndOfTurn

Gets a default end-of-turn result.

static EndOfTurn: DialogTurnResult<any>

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 Prompt.EndOfTurn

Inherited Method Details

beginDialog(DialogContext, PromptOptions)

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

function beginDialog(dialogContext: DialogContext, options: PromptOptions): Promise<DialogTurnResult<any>>

Parameters

dialogContext
DialogContext

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

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>): NumberPrompt

Parameters

config

Record<string, unknown>

Configuration settings to apply.

Returns

The Configurable after the operation is complete.

Inherited From Prompt.configure

continueDialog(DialogContext)

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

function continueDialog(dialogContext: DialogContext): Promise<DialogTurnResult<any>>

Parameters

dialogContext
DialogContext

The DialogContext for the current turn of conversation.

Returns

Promise<DialogTurnResult<any>>

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<any>, DialogReason)

When overridden in a derived class, performs clean up for the dialog before it ends.

function endDialog(_context: TurnContext, _instance: DialogInstance<any>, _reason: DialogReason): Promise<void>

Parameters

_context

TurnContext

The context object for the turn.

_instance

DialogInstance<any>

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.

Inherited From Prompt.endDialog

getConverter(string)

Gets the converter for the selector configuration. *

function getConverter(_property: string): Converter<unknown, unknown> | ConverterFactory<unknown, unknown>

Parameters

_property

string

The key of the conditional selector configuration. *

Returns

Converter<unknown, unknown> | ConverterFactory<unknown, unknown>

The converter for the selector configuration.

Inherited From Prompt.getConverter

getVersion()

An encoded string used to aid in the detection of agent 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 dialog's 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 agent, an error will be thrown resulting in the agent error handler logic being run.

Returning an empty string will disable version tracking for the component all together.

Inherited From Prompt.getVersion

onDialogEvent(DialogContext, DialogEvent)

Called when an event has been raised, using DialogContext.emitEvent method, by either the current dialog or a dialog that the current dialog started.

function onDialogEvent(dialogContext: DialogContext, event: DialogEvent): Promise<boolean>

Parameters

dialogContext
DialogContext

The dialog context for the current turn of conversation.

event
DialogEvent

The event being raised.

Returns

Promise<boolean>

True if the event is handled by the current dialog and bubbling should stop.

Inherited From Prompt.onDialogEvent

repromptDialog(TurnContext, DialogInstance<any>)

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

function repromptDialog(context: TurnContext, instance: DialogInstance<any>): Promise<void>

Parameters

context

TurnContext

TurnContext, context for the current turn of conversation with the user.

instance

DialogInstance<any>

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(dialogContext: DialogContext, _reason: DialogReason, _result?: any): Promise<DialogTurnResult<any>>

Parameters

dialogContext
DialogContext

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

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