UNPKG

botbuilder-dialogs-adaptive

Version:

Rule system for the Microsoft BotBuilder dialog system.

171 lines 8.7 kB
import { Activity } from 'botbuilder'; import { BoolProperty, IntProperty, StringProperty, TemplateInterfaceProperty, UnknownProperty } from '../properties'; import { BoolExpression, IntExpression, StringExpression, ValueExpression } from 'adaptive-expressions'; import { Choice, ChoiceFactoryOptions, Converter, ConverterFactory, Dialog, DialogConfiguration, DialogContext, DialogEvent, DialogReason, DialogStateManager, DialogTurnResult, ListStyle, TemplateInterface } from 'botbuilder-dialogs'; export declare enum InputState { missing = "missing", unrecognized = "unrecognized", invalid = "invalid", valid = "valid" } export interface InputDialogConfiguration extends DialogConfiguration { alwaysPrompt?: BoolProperty; allowInterruptions?: BoolProperty; property?: StringProperty; value?: UnknownProperty; prompt?: TemplateInterfaceProperty<Partial<Activity>, DialogStateManager>; unrecognizedPrompt?: TemplateInterfaceProperty<Partial<Activity>, DialogStateManager>; invalidPrompt?: TemplateInterfaceProperty<Partial<Activity>, DialogStateManager>; defaultValueResponse?: TemplateInterfaceProperty<Partial<Activity>, DialogStateManager>; validations?: string[]; maxTurnCount?: IntProperty; defaultValue?: UnknownProperty; disabled?: BoolProperty; } /** * Defines input dialogs. */ export declare abstract class InputDialog extends Dialog implements InputDialogConfiguration { static OPTIONS_PROPERTY: string; static VALUE_PROPERTY: string; static TURN_COUNT_PROPERTY: string; /** * A value indicating whether the input should always prompt the user regardless of there being a value or not. */ alwaysPrompt: BoolExpression; /** * Interruption policy. */ allowInterruptions: BoolExpression; /** * The value expression which the input will be bound to. */ property: StringExpression; /** * A value expression which can be used to initialize the input prompt. */ value: ValueExpression; /** * The activity to send to the user. */ prompt: TemplateInterface<Partial<Activity>, DialogStateManager>; /** * The activity template for retrying prompt. */ unrecognizedPrompt: TemplateInterface<Partial<Activity>, DialogStateManager>; /** * The activity template to send to the user whenever the value provided is invalid or not. */ invalidPrompt: TemplateInterface<Partial<Activity>, DialogStateManager>; /** * The activity template to send when maxTurnCount has be reached and the default value is used. */ defaultValueResponse: TemplateInterface<Partial<Activity>, DialogStateManager>; /** * The expressions to run to validate the input. */ validations: string[]; /** * Maximum number of times to ask the user for this value before the dialog gives up. */ maxTurnCount?: IntExpression; /** * The default value for the input dialog when maxTurnCount is exceeded. */ defaultValue?: ValueExpression; /** * An optional expression which if is true will disable this action. */ disabled?: BoolExpression; /** * @param property The key of the conditional selector configuration. * @returns The converter for the selector configuration. */ getConverter(property: keyof InputDialogConfiguration): Converter | ConverterFactory; /** * Initializes a new instance of the [InputDialog](xref:botbuilder-dialogs-adaptive.InputDialog) class * * @param property Optional. The value expression which the input will be bound to. * @param prompt Optional. The [Activity](xref:botframework-schema.Activity) to send to the user, * if a string is specified it will instantiates an [ActivityTemplate](xref:botbuilder-dialogs-adaptive.ActivityTemplate). */ constructor(property?: string, prompt?: Partial<Activity> | string); /** * Called when the [Dialog](xref:botbuilder-dialogs.Dialog) is started and pushed onto the dialog stack. * * @param dc The [DialogContext](xref:botbuilder-dialogs.DialogContext) for the current turn of conversation. * @param options Optional. Initial information to pass to the [Dialog](xref:botbuilder-dialogs.Dialog). * @returns A [DialogTurnResult](xref:botbuilder-dialogs.DialogTurnResult) `Promise` representing the asynchronous operation. */ beginDialog(dc: DialogContext, options?: any): Promise<DialogTurnResult>; /** * Called when the [Dialog](xref:botbuilder-dialogs.Dialog) is _continued_, where it is the active dialog and the user replies with a new activity. * * @param dc The [DialogContext](xref:botbuilder-dialogs.DialogContext) for the current turn of conversation. * @returns A [DialogTurnResult](xref:botbuilder-dialogs.DialogTurnResult) `Promise` representing the asynchronous operation. */ continueDialog(dc: DialogContext): Promise<DialogTurnResult>; /** * Called when a child [Dialog](xref:botbuilder-dialogs.Dialog) completes its turn, returning control to this dialog. * * @param dc The [DialogContext](xref:botbuilder-dialogs.DialogContext) for the current turn of conversation. * @param _reason [DialogReason](xref:botbuilder-dialogs.DialogReason), reason why the dialog resumed. * @param _result Optional. Value returned from the [Dialog](xref:botbuilder-dialogs.Dialog) that was called. * The type of the value returned is dependent on the child dialog. * @returns A [DialogTurnResult](xref:botbuilder-dialogs.DialogTurnResult) `Promise` representing the asynchronous operation. */ resumeDialog(dc: DialogContext, _reason: DialogReason, _result?: any): Promise<DialogTurnResult>; /** * @protected * Called before an event is bubbled to its parent. * @param dc The [DialogContext](xref:botbuilder-dialogs.DialogContext) for the current turn of conversation. * @param event [DialogEvent](xref:botbuilder-dialogs.DialogEvent), the event being raised. * @returns Whether the event is handled by the current [Dialog](xref:botbuilder-dialogs.Dialog) and further processing should stop. */ protected onPreBubbleEvent(dc: DialogContext, event: DialogEvent): Promise<boolean>; protected abstract onRecognizeInput(dc: DialogContext): Promise<InputState>; /** * @protected * Method which processes options. * @param _dc The [DialogContext](xref:botbuilder-dialogs.DialogContext) for the current turn of conversation. * @param options Initial information to pass to the dialog. * @returns A promise representing the asynchronous operation. */ protected onInitializeOptions(_dc: DialogContext, options: any): Promise<any>; /** * @protected * Method which renders the prompt to the user given the current input state. * @param dc The [DialogContext](xref:botbuilder-dialogs.DialogContext) for the current turn of conversation. * @param state Dialog [InputState](xref:botbuilder-dialogs-adaptive.InputState). * @returns An [Activity](xref:botframework-schema.Activity) `Promise` representing the asynchronous operation. */ protected onRenderPrompt(dc: DialogContext, state: InputState): Promise<Partial<Activity>>; /** * @protected * Track GeneratorResultEvent telemetry event with InputDialogResultEvent context. * @param dc The [DialogContext](xref:botbuilder-dialogs.DialogContext) for the current turn of conversation. * @param activityTemplate used to create the Activity. * @param msg The Partial [Activity](xref:botframework-schema.Activity) which will be sent. */ protected trackGeneratorResultEvent(dc: DialogContext, activityTemplate: TemplateInterface<Partial<Activity>, DialogStateManager>, msg: Partial<Activity>): void; /** * Helper function to compose an output activity containing a set of choices. * * @param prompt The prompt to append the users choices to. * @param channelId ID of the channel the prompt is being sent to. * @param choices List of choices to append. * @param style Configured style for the list of choices. * @param options (Optional) options to configure the underlying ChoiceFactory call. * @returns A bound activity ready to send to the user. */ protected appendChoices(prompt: Partial<Activity>, channelId: string, choices: Choice[], style: ListStyle, options?: ChoiceFactoryOptions): Partial<Activity>; /** * @private */ private recognizeInput; /** * @private */ private promptUser; } //# sourceMappingURL=inputDialog.d.ts.map