Share via


@microsoft/agents-hosting-dialogs package

Classes

ActivityPrompt

Waits for an activity to be received.

AgentComponent

Abstract base class for defining an AgentComponent.

AgentStateMemoryScope

Base class for memory scopes based on AgentState.

AliasPathResolver

A class that resolves paths by replacing an alias with a specified prefix and optional postfix. This is useful for transforming paths that use shorthand aliases into fully qualified paths.

AtAtPathResolver

A specialized path resolver that replaces the '@@' alias with the prefix 'turn.recognized.entities.'. This is used to resolve paths related to recognized entities in a conversational turn.

AtPathResolver

A path resolver that replaces the '@' alias with a specific prefix and transforms paths to access recognized entities in a conversational turn. It ensures that the resolved path includes the 'first()' function for entity properties.

AttachmentPrompt

Prompts a user to upload attachments like images.

ChoiceFactory

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

ChoicePrompt

Prompts a user to select from a list of choices.

ClassMemoryScope

A memory scope that provides access to the properties of the active dialog. This scope binds to the active dialog and clones its properties for use in memory.

ComponentDialog

Base class for a dialog that contains other child dialogs.

Configurable

Base class for all configurable classes.

ConfirmPrompt

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

ConversationMemoryScope

Memory that's scoped to the current conversation.

DateTimePrompt

Prompts a user to enter a datetime expression.

Dialog

Defines the core behavior for all dialogs.

DialogClassMemoryScope

A memory scope that provides access to the properties of the active dialog class. This scope resolves to the active dialog if it is a container, or to its parent dialog.

DialogContainer

A container for a set of Dialogs.

DialogContext

The context for the current dialog turn with respect to a specific DialogSet.

DialogContextError

An Error that includes extra dialog context, including the dialog stack.

DialogContextMemoryScope

A memory scope that provides access to the dialog context. This scope includes information about the active dialog, its parent, and the dialog stack.

DialogEvents

Represents the events related to the "lifecycle" of the dialog.

These events are used to signal various stages or actions within a dialog's lifecycle.

DialogManager

Class which runs the dialog system.

DialogMemoryScope

A memory scope that provides access to the active dialog's state. This scope binds to the active dialog if it is a container, or to its parent dialog if applicable.

DialogPath

Defines path for available dialogs.

DialogSet

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

DialogStateManager

Manages memory scopes and path resolvers.

DialogTurnStateConstants

Provides constants used to manage the state of a dialog turn.

DialogsAgentComponent

Agent component for agent Dialogs.

DollarPathResolver

A path resolver that resolves paths starting with a dollar sign ('$') to the 'dialog.' namespace.

HashPathResolver

A path resolver that resolves paths starting with a hash sign ('#') to the 'turn.recognized.intents.' namespace.

MemoryScope

Abstract base class for all memory scopes.

NumberPrompt

Prompts a user to enter a number.

PercentPathResolver

A path resolver that resolves paths starting with a percent sign ('%') to the 'class.' namespace.

Prompt

Base class for all prompts.

PromptCultureModels

Class container for currently-supported Culture Models in Confirm and Choice Prompt.

Recognizer

Base class for implementing custom recognizers to identify intents and entities from user input.

ScopePath

Defines paths for the available scopes.

ServiceCollection

ServiceCollection is an interface that describes a set of methods to register services. This, in a lighter way, mimics the .NET dependency injection service collection functionality, except for instances rather than types.

SettingsMemoryScope

Abstract base class for all memory scopes.

TextPrompt

Prompts a user to enter some text.

ThisMemoryScope

Abstract base class for all memory scopes.

TurnMemoryScope

A memory scope that provides access to the turn's state. This scope is used to store and retrieve information specific to the current turn.

TurnPath

Defines path for available turns.

UserMemoryScope

Memory that's scoped to the current user.

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

Choice

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

ChoiceDefaultsChoicePrompt

Represents a dictionary of default choice options for different locales.

ChoiceDefaultsConfirmPrompt

Defines locale-specific choice defaults for confirmation prompts.

ChoiceFactoryOptions

Additional options used to tweak the formatting of choice lists.

ComponentMemoryScopes

Interface for enumerating memory scopes.

ComponentPathResolvers

Interface for declaring path resolvers.

Configuration

Configuration is an interface that is used to obtain configurable values

Converter

The converter converts objects from one type to another.

DateTimeResolution

Result returned by the DateTimePrompt.

DialogConfiguration

Configuration options for dialog initialization and behavior. This interface defines the settings that can be applied when creating or configuring a dialog instance.

DialogDependencies

Interface for dialogs that have child dialog dependencies.

DialogEvent

Represents an event that occurs within a dialog, providing details such as its name, whether it should bubble to parent contexts, and any associated value.

DialogInstance

Contains state information for an instance of a dialog on the stack.

DialogManagerConfiguration

Configuration interface for DialogManager instances. Defines the required and optional settings needed to initialize and configure a dialog manager.

DialogManagerResult

Result returned by the DialogManager after processing a conversation turn. Contains the outcome of dialog execution and any state changes that occurred during the turn.

DialogState

Contains dialog state, information about the state of the dialog stack, for a specific DialogSet.

DialogStateManagerConfiguration

Configuration options for the DialogStateManager.

DialogTurnResult

Represents the result of a dialog context's attempt to begin, continue, or otherwise manipulate one or more dialogs.

FindChoicesOptions

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

FindValuesOptions

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

FoundChoice

Represents a choice that was found and matched within a user's utterance. This interface contains information about the matched choice, including its original value, position in the choices list, confidence score, and the specific text that triggered the match.

FoundValue

Represents a value that was successfully found and matched during a search operation.

IntentScore

Score plus any extra information about an intent.

ModelResult

Represents the result of a model recognition process.

PathResolver

Interface for resolving and transforming paths. Implementations of this interface define how specific path patterns should be transformed into other formats or namespaces.

PromptCultureModel

Represents a culture-specific model that defines localization settings for prompts. This interface provides language-specific formatting rules and translations for interactive prompts such as choice lists and confirmation dialogs.

PromptOptions

Basic configuration options supported by all prompts.

PromptRecognizerResult

Result returned by a prompts recognizer function.

PromptValidatorContext

Contextual information passed to a custom PromptValidator.

RecognizerConfiguration

Configuration options for a recognizer instance.

RecognizerResult

Value returned from a recognizer.

SortedValue

Represents a value with its original position that can be used in search operations.

TemplateInterface

Defines Template interface for binding data to T.

Token

Represents a token extracted from a text string.

WaterfallStepInfo

Values passed to the WaterfallStepContext constructor.

Type Aliases

ConverterFactory

A factory type for creating instances of a Converter.

DependencyFactory

DependencyFactory is a function signature that produces an instance that depends on a set of other services. The type is generic over a few parameters:

Factory

Factory describes a generic factory function signature. The type is generic over a few parameters:

PromptValidator

Function signature for providing a custom prompt validator.

TokenizerFunction

Signature for an alternate word breaker.

WaterfallStep

Function signature of an individual waterfall step.

Enums

DialogReason

Indicates why a dialog method is being called.

DialogTurnStatus

Represents the state of the dialog stack after a dialog context attempts to begin, continue, or otherwise manipulate one or more dialogs.

ListStyle

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

Functions

defaultTokenizer(string, string)

Simple tokenizer that breaks on spaces and punctuation.

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

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

getTopScoringIntent(RecognizerResult)

Example

const result: RecognizerResult = {
  text: "Book a flight to Seattle",
  intents: {
    "BookFlight": { score: 0.95 },
    "Cancel": { score: 0.02 },
    "Help": { score: 0.03 }
  }
};

const topIntent = getTopScoringIntent(result);
// Returns: { intent: "BookFlight", score: 0.95 }
isComponentMemoryScopes(unknown)

Check if a ComponentRegistration is ComponentMemoryScopes or not.

isComponentPathResolvers(unknown)

Check if a ComponentRegistration) is ComponentPathResolvers or not.

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

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

runDialog(Dialog<{}>, TurnContext, AgentStatePropertyAccessor<DialogState>)

Runs a dialog from a given context and accessor.

Function Details

defaultTokenizer(string, string)

Simple tokenizer that breaks on spaces and punctuation.

function defaultTokenizer(text: string, _locale?: string): Token[]

Parameters

text

string

The input text.

_locale

string

Optional, identifies the locale of the input text.

Returns

Token[]

A list of tokens.

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): ModelResult<FoundChoice>[]

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 | Choice)[]

List of choices to search over.

options
FindChoicesOptions

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

Returns

A list of found choices, sorted by most relevant first.

getTopScoringIntent(RecognizerResult)

Example

const result: RecognizerResult = {
  text: "Book a flight to Seattle",
  intents: {
    "BookFlight": { score: 0.95 },
    "Cancel": { score: 0.02 },
    "Help": { score: 0.03 }
  }
};

const topIntent = getTopScoringIntent(result);
// Returns: { intent: "BookFlight", score: 0.95 }
function getTopScoringIntent(result: RecognizerResult): { intent: string, score: number }

Parameters

result
RecognizerResult

The recognizer result containing intents and their scores

Returns

{ intent: string, score: number }

An object containing the top-scoring intent name and its confidence score

Remarks

This function iterates through all intents in the recognizer result and returns the intent name and score for the intent with the highest confidence score. If multiple intents have the same highest score, the last one encountered is returned.

isComponentMemoryScopes(unknown)

Check if a ComponentRegistration is ComponentMemoryScopes or not.

function isComponentMemoryScopes(component: unknown): component

Parameters

component

unknown

The component registration.

Returns

component

Type check result.

isComponentPathResolvers(unknown)

Check if a ComponentRegistration) is ComponentPathResolvers or not.

function isComponentPathResolvers(component: unknown): component

Parameters

component

unknown

The component registration.

Returns

component

Type check result.

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): ModelResult<FoundChoice>[]

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 | Choice)[]

List of choices to search over.

options
FindChoicesOptions

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

Returns

A list of found choices, sorted by most relevant first.

runDialog(Dialog<{}>, TurnContext, AgentStatePropertyAccessor<DialogState>)

Runs a dialog from a given context and accessor.

function runDialog(dialog: Dialog<{}>, context: TurnContext, accessor: AgentStatePropertyAccessor<DialogState>): Promise<void>

Parameters

dialog

Dialog<{}>

The Dialog to run.

context
TurnContext

TurnContext object for the current turn of conversation with the user.

accessor

AgentStatePropertyAccessor<DialogState>

Defined methods for accessing the state property created in a State object.

Returns

Promise<void>