DialogAction class

Dialog actions offer static shortcuts to implementing common actions. They also implement support for named actions which can be bound to a dialog to handle global utterances from the user like "help" or "cancel". Actions get pushed onto and off of the dialog stack as part of dialogs so these listeners can come into and out of scope as the conversation progresses. You can also bind named to actions to buttons which let your bot respond to button clicks on cards that have maybe scrolled off the screen.

Methods

beginDialog<T>(string, T)

Returns a closure that will passes control of the conversation to a new dialog.

endDialog(any)

Returns a closure that will end the current dialog.

send(string, any[])

Returns a closure that will send a simple text message to the user.

validatedPrompt(PromptType, (response: any) => boolean)

Returns a closure that wraps a built-in prompt with validation logic. The closure should be used to define a new dialog for the prompt using bot.add('/myPrompt', builder.DialogAction.)

Method Details

beginDialog<T>(string, T)

Returns a closure that will passes control of the conversation to a new dialog.

static function beginDialog<T>(id: string, args?: T)

Parameters

id

string

Unique ID of the dialog to start.

args

T

(Optional) arguments to pass to the dialogs begin() method.

Returns

endDialog(any)

Returns a closure that will end the current dialog.

static function endDialog(result?: any)

Parameters

result

any

(Optional) results to pass to the parent dialog.

Returns

send(string, any[])

Returns a closure that will send a simple text message to the user.

static function send(msg: string, args: any[])

Parameters

msg

string

Text of the message to send. The message will be localized using the sessions configured localizer. If arguments are passed in the message will be formatted using sprintf-js (see the docs for details.)

args

any[]

(Optional) arguments used to format the final output string.

Returns

validatedPrompt(PromptType, (response: any) => boolean)

Returns a closure that wraps a built-in prompt with validation logic. The closure should be used to define a new dialog for the prompt using bot.add('/myPrompt', builder.DialogAction.)

static function validatedPrompt(promptType: PromptType, validator: (response: any) => boolean)

Parameters

promptType
PromptType

Type of built-in prompt to validate.

validator

(response: any) => boolean

Function used to validate the response. Should return true if the response is valid.

Returns