Creates an instance of a Control Manager.
props
The complete props used during construction.
The custom props provided during construction
Default key name used to store control state data between turns.
Builds interaction model content required by the Control tree.
Usage:
The imDataMap has 'en-US' modelData registered by default
The developer may configure and register additional imDataMap
instances to support additional locales
If imDataMap doesn't have data for the requested locale a
LocaleNotSupportedError
will be thrown
Interaction Model Generator
Creates a tree of controls to handle state management and dialog decisions for the skill.
Usage:
Each control in the tree can and should be created with empty state.
In advanced scenarios the tree shape may change as the skill session
progresses. Dynamic controls should be rebuilt during
ControlManager.reestablishControlStates()
.
A Control
, typically a ContainerControl
, that is the root of a tree.
Handles an internal error.
This is intended for logging, reporting and perhaps mentioning the situation to the user. The user session will be automatically closed.
Default: The error object is converted into an object with enumerable properties and logged at logLevel=error
Input
Error
Response builder
Load the control state map from durable storage.
Default: loads from Session Attributes.
Reestablish the state of all controls.
Purpose:
createControlTree
)Notes:
Transforms the information in ControlResult into user-facing content (prompts and APL).
Default: The default rendering strategy renders each SystemAct
in turn
by calling act.control.render(act)
. This strategy leads to
prompts that are a concatenation of the prompt-fragment for each
SystemAct
.
Usage:
[ValueSetAct(ageCtrl, 5), RequestValueAct(nameCtrl)]
may be rendered sequentially to produce:
-> 'OK, 5. What is your name?"
ControlManager.renderActsOneByOne()
.Saves the control state map for use in subsequent turns of this session.
Default: saves to the Session Attributes.
Merges the user-provided props with the default props.
Any property defined by the user-provided data overrides the defaults.
Defines the high-level functionality for a skill built with Controls.
Each skill that uses controls should define a concrete sub-class that implements
createControlTree
and optionally overrides other methods.Summary:
createControlTree() creates a hierarchy of controls that cooperatively manage the skill behavior.
render() is the entry-point for the render-phase.
controlManager.render()
. The default is to render each act one-by-one by callingcontrol.renderAct(act)
. This builds up a result by concatenation of response fragments which is sufficient in many cases.The
ControlResult
contains a list of SystemActs that describe what should be communicated to the user but generally should not describe how to present it.handleInternalError
provides an entry-point for custom handling of internal errors.buildInteractionModel
provides an entry-point for building the Control-specific aspects of skill's Interaction Model.Internationalization and Localization
Controls themselves are location-agnostic. They consume abstract inputs (Intents, etc) and produce abstract outputs (SystemActs)
Mapping localized input to abstract inputs is the role of NLU and the necessary information is stored in the Interaction Model.
Mapping abstract output to physical output (prompts, APL strings) etc is the role of the rendering phase. This information is part of the skill definition but can be located in various places: either in a monolithic render() function, or scattered around the various Controls and Acts.