= Dialog Manager The dialog manager is a tool to create and execute dialogs with a human user. The basic dialog cycle as represented in DialogState and implemented in DemoApp is like this {{{ while (!state.isFinal()) { state = state.withRandomOption(); Stimulus stimulus = state.getOption().getStimulation() .substitute(state.getParameters()); present stimulus String answer = get answer fitting state.getOption.getAnswerType(); state = state.with(answer); }}} == Parameters * The user's answers, current dialog state label, and other parameters relevant for the dialog are stored in a set of parameters. This is just a map with keys and values both strings. The keys are called the "variable name" and the values the "variable value". * Distance between two parameters is the euclidean distance (sqrt of the sum of squares) of the difference between the two parameter values, on a per-key basis. Only values for which both parameters have the key are compared. For non-numeric values, the difference is usually 0 if the values are equal, or else 1. The dialog manager contains a number of key objects * Dialog specification. A kind of finite state machine. The nodes are "dialog phases" and each have a unique label. The START and END phase indicate the usual start and end of the dialog. * Dialog phase. Each dialog phase represents a situation where we want the user to answer some question. This question can be formulated in different ways depending on the situation and user's previous answers. Therefore the phase contains a number of DialogOptions * A DialogOption is a concrete sentence with a question for the user, plus the expected type of the answer (boolean (yes/no), number, text). * Dialog state. The current state of the dialog, comprising the situation and the user's answers so far. Stored as a set of Parameters. * Parameters. A set of key-value pairs where the keys are unique string labels and the values are a ParameterValue (a String, Double, or boolean). * All data structures can be (de)serialized to JSON. * Various datastructures available to store key elements for dialog management * a DialogState represent the entire dialog state plus the entire dialog specification in a single file. Useful to store/recover the entire user state in one single file * A DialogSpecification represents all possible dialog phases. Useful to storethe entire dialog tree but without the user's answers so far * Parameters that store the user's answers so far * The NextPhase mechanism determines the next phase, based on the current parameter settings. The GoToIf selects the phase that has parameters that are smallest distance to the current state ++. The GoTo unconditionally jumps to the given state. * A DialogPhase can have multiple options, from which the one with the smallest distance to the current state++ is chosen. * Parameters can be manipulated programmatically, eg to update fields or incorporate data external to the dialog system such as system time, network state, database fields, etc. * Parameters can be used directly in the sentences and the available answers * The sentences can contain HTML code. ++picks one at raodom from the list of nearest