DialogContext Class
- java.
lang. Object - com.
microsoft. bot. dialogs. DialogContext
- com.
public class DialogContext
Provides context for the current state of the dialog stack.
Constructor Summary
| Constructor | Description |
|---|---|
| DialogContext(DialogSet withDialogs, TurnContext withTurnContext, DialogState withState) |
Initializes a new instance of the Dialog |
| DialogContext(DialogSet withDialogs, DialogContext withParentDialogContext, DialogState withState) |
Initializes a new instance of the Dialog |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
|
java.util.concurrent.CompletableFuture<Dialog |
beginDialog(String dialogId)
Starts a new dialog and pushes it onto the dialog stack. |
|
java.util.concurrent.CompletableFuture<Dialog |
beginDialog(String dialogId, Object options)
Starts a new dialog and pushes it onto the dialog stack. |
|
java.util.concurrent.CompletableFuture<Dialog |
cancelAllDialogs()
Helper method for cancelAllDialogs(boolean cancelParents, String eventName, Object eventValue) that does not cancel parent dialogs or pass and event. |
|
java.util.concurrent.CompletableFuture<Dialog |
cancelAllDialogs(boolean cancelParents, String eventName, Object eventValue)
Deletes any existing dialog stack thus canceling all dialogs on the stack. |
|
java.util.concurrent.CompletableFuture<Dialog |
continueDialog()
Continues execution of the active dialog, if there is one, by passing the current Dialog |
| java.util.concurrent.CompletableFuture<java.lang.Boolean> | emitEvent(String name) |
| java.util.concurrent.CompletableFuture<java.lang.Boolean> | emitEvent(String name, Object value, boolean bubble, boolean fromLeaf) |
|
java.util.concurrent.CompletableFuture<Dialog |
endDialog()
Helper method that supplies a null result to endDialog(Object result). |
|
java.util.concurrent.CompletableFuture<Dialog |
endDialog(Object result)
Ends a dialog by popping it off the stack and returns an optional result to the dialog's parent. |
| Dialog |
findDialog(String dialogId)
Find the dialog id for the given context. |
|
Dialog |
getActiveDialog()
Gets the cached instance of the active dialog on the top of the stack or null if the stack is empty. |
|
Dialog |
getChild()
Gets dialog context for child if there is an active child. |
|
Turn |
getContext()
Gets the context for the current turn of conversation. |
|
Dialog |
getDialogs()
Gets the set of dialogs which are active for the current dialog container. |
| java.lang.String |
getLocale()
Obtain the locale in Dialog |
|
Dialog |
getParent()
Gets the parent Dialog |
|
Turn |
getServices()
Gets the services collection which is contextual to this dialog context. |
|
java.util.List<Dialog |
getStack()
Gets the current dialog stack. |
|
Dialog |
getState()
Gets or sets the Dialog |
|
java.util.concurrent.CompletableFuture<Dialog |
prompt(String dialogId, PromptOptions options)
Helper function to simplify formatting the options for calling a prompt dialog. |
|
java.util.concurrent.CompletableFuture<Dialog |
replaceDialog(String dialogId)
Helper method for replaceDialog(String dialogId, Object options) that passes null for options. |
|
java.util.concurrent.CompletableFuture<Dialog |
replaceDialog(String dialogId, Object options)
Starts a new dialog and replaces on the stack the currently active dialog with the new one. |
| java.util.concurrent.CompletableFuture<java.lang.Void> |
repromptDialog()
Calls the currently active dialog's repromptDialog(TurnContext turnContext, DialogInstance instance) method. |
| void |
setParent(DialogContext withDialogContext)
Set the parent Dialog |
Methods inherited from java.lang.Object
Constructor Details
DialogContext
public DialogContext(DialogSet withDialogs, TurnContext withTurnContext, DialogState withState)
Initializes a new instance of the DialogContext class from the turn context.
Parameters:
DialogContext
public DialogContext(DialogSet withDialogs, DialogContext withParentDialogContext, DialogState withState)
Initializes a new instance of the DialogContext class from the turn context.
Parameters:
Method Details
beginDialog
public CompletableFuture
Starts a new dialog and pushes it onto the dialog stack.
Parameters:
Returns:
beginDialog
public CompletableFuture
Starts a new dialog and pushes it onto the dialog stack.
Parameters:
Returns:
cancelAllDialogs
public CompletableFuture
Helper method for cancelAllDialogs(boolean cancelParents, String eventName, Object eventValue) that does not cancel parent dialogs or pass and event.
Returns:
cancelAllDialogs
public CompletableFuture
Deletes any existing dialog stack thus canceling all dialogs on the stack.
In general, the parent context is the dialog or bot turn handler that started the dialog. If the parent is a dialog, the stack calls the parent's resumeDialog(DialogContext dc, DialogReason reason, Object result) method to return a result to the parent dialog. If the parent dialog does not implement Dialog#resumeDialog, then the parent will end, too, and the result is passed to the next parent context.
Parameters:
Returns:
continueDialog
public CompletableFuture
Continues execution of the active dialog, if there is one, by passing the current DialogContext to the active dialog's continueDialog(DialogContext dc) method.
Returns:
emitEvent
public CompletableFuture
Parameters:
Returns:
emitEvent
public CompletableFuture
Parameters:
true.
Returns:
endDialog
public CompletableFuture
Helper method that supplies a null result to endDialog(Object result).
Returns:
endDialog
public CompletableFuture
Ends a dialog by popping it off the stack and returns an optional result to the dialog's parent. The parent dialog is the dialog the started the on being ended via a call to either beginDialog(String dialogId, Object options) or prompt(String dialogId, PromptOptions options). The parent dialog will have its resumeDialog(DialogContext dc, DialogReason reason, Object result) method invoked with any returned result. If the parent dialog hasn't implemented a resumeDialog(DialogContext dc, DialogReason reason) method, then it will be automatically ended as well and the result passed to its parent. If there are no more parent dialogs on the stack then processing of the turn will end.
Parameters:
Returns:
findDialog
public Dialog findDialog(String dialogId)
Find the dialog id for the given context.
Parameters:
Returns:
getActiveDialog
public DialogInstance getActiveDialog()
Gets the cached instance of the active dialog on the top of the stack or null if the stack is empty.
Returns:
getChild
public DialogContext getChild()
Gets dialog context for child if there is an active child.
Returns:
getContext
public TurnContext getContext()
Gets the context for the current turn of conversation.
Returns:
getDialogs
public DialogSet getDialogs()
Gets the set of dialogs which are active for the current dialog container.
Returns:
getLocale
public String getLocale()
Obtain the locale in DialogContext.
Returns:
getParent
public DialogContext getParent()
Gets the parent DialogContext, if any. Used when searching for the ID of a dialog to start.
Returns:
getServices
public TurnContextStateCollection getServices()
Gets the services collection which is contextual to this dialog context.
Returns:
getStack
public List
Gets the current dialog stack.
Returns:
getState
public DialogStateManager getState()
Gets or sets the DialogStateManager which manages view of all memory scopes.
Returns:
prompt
public CompletableFuture
Helper function to simplify formatting the options for calling a prompt dialog. This helper will take an PromptOptions argument and then call beginDialog(String dialogId, Object options)
Parameters:
Returns:
replaceDialog
public CompletableFuture
Helper method for replaceDialog(String dialogId, Object options) that passes null for options.
Parameters:
Returns:
replaceDialog
public CompletableFuture
Starts a new dialog and replaces on the stack the currently active dialog with the new one. This is particularly useful for creating loops or redirecting to another dialog.
Parameters:
Returns:
repromptDialog
public CompletableFuture
Calls the currently active dialog's repromptDialog(TurnContext turnContext, DialogInstance instance) method. Used with dialogs that implement a re-prompt behavior.
Returns:
setParent
public void setParent(DialogContext withDialogContext)
Set the parent DialogContext.
Parameters: