SimpleDialog class
Allows for the creation of custom dialogs that are based on a simple closure. This is useful for cases where you want a dynamic conversation flow or you have a situation that just doesn’t map very well to using a waterfall. The things to keep in mind:
- Your dialogs closure is can get called in two different contexts that you potentially need to
test for. It will get called as expected when the user send your dialog a message but if you
call another prompt or dialog from your closure it will get called a second time with the
results from the prompt/dialog. You can typically test for this second case by checking for the
existant of an
args.resumedproperty. It's important to avoid getting yourself into an infinite loop which can be easy to do. - Unlike a waterfall your dialog will not automatically end. It will remain the active dialog until you call session.endDialog().
- Extends
Constructors
| Simple |
Creates a new custom dialog based on a simple closure. |
Methods
| begin<T>(Call |
Called when a new dialog session is being started. |
| dialog |
A child dialog has ended and the current one is being resumed. |
| reply |
Processes messages received from the user. Called by the dialog system. |
Constructor Details
SimpleDialog((session: CallSession, args?: any | IDialogResult<any>) => void)
Creates a new custom dialog based on a simple closure.
new SimpleDialog(handler: (session: CallSession, args?: any | IDialogResult<any>) => void)
Parameters
- handler
-
(session: CallSession, args?: any | IDialogResult<any>) => void
The function closure for your dialog.
Method Details
begin<T>(CallSession, T)
Called when a new dialog session is being started.
function begin<T>(session: CallSession, args?: T)
Parameters
- session
- CallSession
Session object for the current conversation.
- args
-
T
(Optional) arguments passed to the dialog by its parent.
dialogResumed<T>(CallSession, IDialogResult<T>)
A child dialog has ended and the current one is being resumed.
function dialogResumed<T>(session: CallSession, result: IDialogResult<T>)
Parameters
- session
- CallSession
Session object for the current conversation.
- result
Result returned by the child dialog.
replyReceived(CallSession)
Processes messages received from the user. Called by the dialog system.
function replyReceived(session: CallSession)
Parameters
- session
- CallSession
Session object for the current conversation.