Stories define dialog paths, which consist of one or more actions in a list that Diatheke should take.
A story groups together several related actions that help accomplish a particular goal. This is where the desired dialog flow is defined as sequences of actions, with a definitive start and end to the story.
Diatheke supports the following types of actions:
Action type | Description | ID |
---|---|---|
input | Waits for the user (via the client app) to send input to Diatheke. This is a branching action. | The name of the input action to use, as defined under input_actions in the story file. |
command | Requests the client app to perform a specific, named task. | Filename (without extension) in the commands folder |
reply | Sends a reply back to the user (via the client app). | Filename (without extension) in the replies folder |
conditional | Checks whether parameters in a session’s memory satisfy a particular condition. This is a branching action. | The name of the conditional action to use, as defined under conditional_actions in the story file. |
memory | Manipulates the session’s memory by clearing or setting parameters. | One of 4 memory actions as specified below under Memory Action |
story | Runs a different story from start to finish as though it were a single action in the story where it is used. This makes it easy to re-use common bits of functionality in the dialog. | Filename (without extension) in the stories folder |
named | Runs a story-specific set of actions that is defined in the same story file as where it is used. | Either the name of a named-actions list defined under named_actions in the story file, or the special names “start” or “end”, which will move the dialog to the start or end of the current story. |
Actions in a list are executed in the order specified. Unless the last action in the list has the type named, input, or conditional, the end of the story is implied with the end of the action list. If an input action is last, the dialog waits for input then branches according to its intents. If a conditional action is last, the dialog branches according to its conditions. If a named action is last, that set of actions is executed. There must be at least one path through the story that allows the story to end, otherwise Diatheke will return an error when the model is loaded.
Every story begins with the start_actions
list. The
actions in the list will be executed when the story
begins. Often this list will end with an input or
conditional action, but that is not a requirement. It
is possible to define simple stories (like the first zoom example in the tutorial) that only
execute the actions in the start list, then end the
story.
It is also possible to return back to the start of the story by using the “named” action type with an id of “start” in other action lists.
The end of the story is implied when the end of an action list is reached, provided the last action in the list does not lead to other actions (e.g., branching actions). To make the end explicit, the last action in a list may have the “named” type, with an id of “end”.
Named actions group together action lists so they can be used multiple times in the story (for example, in response to different conditions in a Conditional Action). The same thing could be achieved by creating a separate story for the action list, but Named Actions allow the definition to refer to other story-specific actions.
There are two types of actions that effectively cause the dialog flow to branch in different directions.
Stories may specify defaults that apply to the current story and the actions specified within it. Most of them apply to input actions. The precedence for using default behavior is as follows:
A Diatheke session keeps track of all the parameters defined during the dialog. A parameter is a simple name-value pair. Both the name and the value are always strings. Parameters are defined in one of four ways:
Unless specifically instructed to do so by a memory action in the model, Diatheke will not clear parameters from the session’s memory, so it is very important that modelers decide when and which parameters should be cleared from memory during dialog execution.
The memory action may specify one of the following for the action id:
ID | Description |
---|---|
reset_all | Clear all parameters from memory. |
reset_all_except | Clear all parameters from memory except for those named by the action. |
reset | Clear only the named parameters from memory. |
set | Set parameters to specific values. If not already defined in memory, this will define them. |
Examples of each are shown below:
actions:
# Clear all parameters from session memory.
- type: memory
id: reset_all
# Clear all parameters except those listed.
- type: memory
id: reset_all_except
param_list:
- fruit
# Clear only the parameters listed
- type: memory
id: reset
param_list:
- vegetable
# Set new parameters to specific values. This example
# defines and sets the parameter "foo" to the
# value "wonderful", and the parameter "bar" to the
# value "chocolate".
- type: memory
id: set
param_map:
foo: wonderful
bar: chocolate