Share via


DialogSet class

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

Remarks

The constructor for the dialog set should be passed a state property that will be used to persist the dialog stack for the set:

To interact with the sets dialogs you can call createcontext with the current TurnContext. That will create a DialogContext that can be used to start or continue execution of the sets dialogs:

Constructors

DialogSet(AgentStatePropertyAccessor<DialogState>)

Creates a new DialogSet instance.

Methods

add<T>(T)

Adds a new dialog or prompt to the set.

createContext(TurnContext)

Creates a dialog context which can be used to work with the dialogs in the set.

find(string)

Finds a dialog that was previously added to the set using add.

getDialogs()

Gets the Dialogs of the set.

getVersion()

Returns a 32-bit hash of the all the Dialog.version values in the set.

Constructor Details

DialogSet(AgentStatePropertyAccessor<DialogState>)

Creates a new DialogSet instance.

new DialogSet(dialogState?: AgentStatePropertyAccessor<DialogState>)

Parameters

dialogState

AgentStatePropertyAccessor<DialogState>

(Optional) state property used to persist the sets dialog stack.

Remarks

If the dialogState parameter is not passed in, calls to createContext will return an error. You will need to create a DialogContext for the set manually and pass in your own state object for persisting the sets dialog stack:

Method Details

add<T>(T)

Adds a new dialog or prompt to the set.

function add<T>(dialog: T): DialogSet

Parameters

dialog

T

The dialog or prompt to add. If a telemetryClient is present on the dialog set, it will be added to each dialog.

Returns

The dialog set after the operation is complete.

Remarks

If the id being added already exists in the set, the dialogs id will be updated to include a suffix which makes it unique. So adding 2 dialogs named "duplicate" to the set would result in the first one having an id of "duplicate" and the second one having an id of "duplicate2".

createContext(TurnContext)

Creates a dialog context which can be used to work with the dialogs in the set.

function createContext(context: TurnContext): Promise<DialogContext>

Parameters

context
TurnContext

Context for the current turn of conversation with the user.

Returns

Promise<DialogContext>

A promise representing the asynchronous operation.

find(string)

Finds a dialog that was previously added to the set using add.

function find(dialogId: string): undefined | Dialog<{}>

Parameters

dialogId

string

ID of the dialog or prompt to lookup.

Returns

undefined | Dialog<{}>

The dialog if found; otherwise undefined.

getDialogs()

Gets the Dialogs of the set.

function getDialogs(): Dialog<{}>[]

Returns

Dialog<{}>[]

An array of Dialog.

getVersion()

Returns a 32-bit hash of the all the Dialog.version values in the set.

function getVersion(): string

Returns

string

A version that will change when any of the child dialogs version changes.

Remarks

This hash is persisted to state storage and used to detect changes to a dialog set.