botbuilder-dialogs package

Classes

ChoiceFactory

A set of utility functions to assist with the formatting a 'message' activity containing a list of choices.

ComponentDialog

Base class for a dialog that contains other child dialogs.

Dialog

Base class for all dialogs.

DialogContext

A context object used to manipulate a dialog stack.

DialogSet

A related set of dialogs that can all call each other.

ActivityPrompt

Waits for an activity to be received.

AttachmentPrompt

Prompts a user to upload attachments like images.

ChoicePrompt

Prompts a user to select from a list of choices.

ConfirmPrompt

Prompts a user to confirm something with a "yes" or "no" response.

DateTimePrompt

Prompts a user to enter a datetime expression.

NumberPrompt

Prompts a user to enter a number.

OAuthPrompt

Creates a new prompt that asks the user to sign in using the Bot Frameworks Single Sign On (SSO) service.

Prompt

Base class for all prompts.

TextPrompt

Prompts a user to enter some text.

WaterfallDialog

A waterfall is a dialog that's optimized for prompting a user with a series of questions.

WaterfallStepContext

Context object passed in to a WaterfallStep.

Interfaces

ChoiceFactoryOptions

Additional options used to tweak the formatting of choice lists.

Choice

An instance of a choice that can be used to render a choice to a user or recognize something a user picked.

FindChoicesOptions

Options to control the recognition performed by findChoices().

FoundChoice

Result returned by findChoices().

FindValuesOptions

Basic search options used to control how choices are recognized in a users utterance.

FoundValue

INTERNAL: Raw search result returned by findValues().

SortedValue

INTERNAL: A value that can be sorted and still refer to its original position within a source array. The findChoices() function expands the passed in choices to individual SortedValue instances and passes them to findValues(). Each individual Choice can result in multiple synonyms that should be searched for so this data structure lets us pass each synonym as a value to search while maintaining the index of the choice that value came from.

ModelResult

Outer result returned by an entity recognizer like recognizeChoices().

Token

Individual token returned by a TokenizerFunction.

DialogInstance

Tracking information persisted for an instance of a dialog on the stack.

DialogTurnResult

Returned by Dialog.continueDialog() and DialogContext.beginDialog() to indicate whether a dialog is still active after the turn has been processed by the dialog.

DialogState

State information persisted by a DialogSet.

DateTimeResolution

Result returned by the DateTimePrompt.

OAuthPromptSettings

Settings used to configure an OAuthPrompt instance.

PromptOptions

Basic configuration options supported by all prompts.

PromptRecognizerResult

Result returned by a prompts recognizer function.

PromptValidatorContext

Contextual information passed to a custom PromptValidator.

WaterfallStepInfo

Values passed to the WaterfallStepContext constructor.

Type Aliases

TokenizerFunction

Signature for an alternate word breaker that can be passed to recognizeChoices(), findChoices(), or findValues().

type TokenizerFunction = (text: string, locale?: string) => Token[];
PromptValidator

Function signature for providing a custom prompt validator.

type PromptValidator<T> = (prompt: PromptValidatorContext<T>) => Promise<boolean>;
WaterfallStep

Function signature of an individual waterfall step.

type WaterfallStep<O extends object = {}> = (step: WaterfallStepContext<O>) => Promise<DialogTurnResult>;

Enums

DialogReason

Codes indicating why a waterfall step is being called.

DialogTurnStatus

Codes indicating the state of the dialog stack after a call to DialogContext.continueDialog() or DialogContext.beginDialog().

ListStyle

Controls the way that choices for a ChoicePrompt or yes/no options for a ConfirmPrompt are presented to a user.

Functions

findChoices(string, string | Choice[], FindChoicesOptions)

Mid-level search function for recognizing a choice in an utterance.

findValues(string, SortedValue[], FindValuesOptions)

INTERNAL: Low-level function that searches for a set of values within an utterance. Higher level functions like findChoices() and recognizeChoices() are layered above this function. In most cases its easier to just call one of the higher level functions instead but this function contains the fuzzy search algorithm that drives choice recognition.

recognizeChoices(string, string | Choice[], FindChoicesOptions)

High level function for recognizing a choice in a users utterance.

defaultTokenizer(string, string)

Simple tokenizer that breaks on spaces and punctuation.

Function Details

findChoices(string, string | Choice[], FindChoicesOptions)

Mid-level search function for recognizing a choice in an utterance.

function findChoices(utterance: string, choices: string | Choice[], options?: FindChoicesOptions)

Parameters

utterance
string

The text or user utterance to search over. For an incoming 'message' activity you can simply use context.activity.text.

choices
string | botbuilder-dialogs.Choice[]

List of choices to search over.

options
FindChoicesOptions

(Optional) options used to tweak the search that's performed.

Returns

botbuilder-dialogs.ModelResult<botbuilder-dialogs.FoundChoice>[]

findValues(string, SortedValue[], FindValuesOptions)

INTERNAL: Low-level function that searches for a set of values within an utterance. Higher level functions like findChoices() and recognizeChoices() are layered above this function. In most cases its easier to just call one of the higher level functions instead but this function contains the fuzzy search algorithm that drives choice recognition.

function findValues(utterance: string, values: SortedValue[], options?: FindValuesOptions)

Parameters

utterance
string

The text or user utterance to search over.

values
SortedValue[]

List of values to search over.

options
FindValuesOptions

(Optional) options used to tweak the search that's performed.

Returns

botbuilder-dialogs.ModelResult<botbuilder-dialogs.FoundValue>[]

recognizeChoices(string, string | Choice[], FindChoicesOptions)

High level function for recognizing a choice in a users utterance.

function recognizeChoices(utterance: string, choices: string | Choice[], options?: FindChoicesOptions)

Parameters

utterance
string

The text or user utterance to search over. For an incoming 'message' activity you can simply use context.activity.text.

choices
string | botbuilder-dialogs.Choice[]

List of choices to search over.

options
FindChoicesOptions

(Optional) options used to tweak the search that's performed.

Returns

botbuilder-dialogs.ModelResult<botbuilder-dialogs.FoundChoice>[]

defaultTokenizer(string, string)

Simple tokenizer that breaks on spaces and punctuation.

function defaultTokenizer(text: string, locale?: string)

Parameters

text
string
locale
string

Returns

Token[]