Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ListControl

A Control that obtains a single value from the user by presenting a list of available options using voice and/or APL.

The type of value to obtain is defined by this.slotType.

Capabilities:

  • Request a value
  • Change a value
  • Validate the value
  • Confirm the value
  • Speak the first few options
  • Show all the options on APL enabled devices
  • Selection of a value using a spoken ordinal, e.g. "The first one".
  • Selection of a value using touch screen.

Intents that can be handled:

  • GeneralControlIntent: E.g. "yes, update my name"
  • {ValueType}_ValueControlIntent: E.g. "no change it to Elvis".
  • AMAZON_ORDINAL_ValueControlIntent: E.g. "no change it to Elvis".
  • AMAZON.YesIntent, AMAZON.NoIntent

APL events that can be handled:

  • touch events indicating selection of an item on screen.

Limitations:

  • This control is not compatible with the AMAZON.SearchQuery slot type.

Hierarchy

Implements

Constructors

constructor

Properties

Readonly id

id: string

standardInputHandlers

standardInputHandlers: ControlInputHandler[] = [{name: 'SetWithValue (built-in)',canHandle: this.isSetWithValue,handle: this.handleSetWithValue,},{name: 'ChangeWithValue (built-in)',canHandle: this.isChangeWithValue,handle: this.handleChangeWithValue,},{name: 'SetWithoutValue (built-in)',canHandle: this.isSetWithoutValue,handle: this.handleSetWithoutValue,},{name: 'ChangeWithoutValue (built-in)',canHandle: this.isChangeWithoutValue,handle: this.handleChangeWithoutValue,},{name: 'BareValue (built-in)',canHandle: this.isBareValue,handle: this.handleBareValue,},{name: 'MappedBareValueDuringElicitation (built-in)',canHandle: this.isMappedBareValueDuringElicitation,handle: this.handleMappedBareValue,},{name: 'ConfirmationAffirmed (built-in)',canHandle: this.isConfirmationAffirmed,handle: this.handleConfirmationAffirmed,},{name: 'ConfirmationDisaffirmed (built-in)',canHandle: this.isConfirmationDisaffirmed,handle: this.handleConfirmationDisaffirmed,},{name: 'OrdinalScreenEvent (built-in)',canHandle: this.isOrdinalScreenEvent,handle: this.handleOrdinalScreenEvent,},{name: 'OrdinalSelection (built-in)',canHandle: this.isOrdinalSelection,handle: this.handleOrdinalSelection,},]

state

state: ListControlState = new ListControlState()

Methods

addInitiativeAct

canHandle

  • Parameters

    Returns Promise<boolean>

canTakeInitiative

clear

  • clear(): void
  • Clear the state of this control.

    Returns void

evaluateAPLProp

  • Evaluate an APL document/data source prop.

    Parameters

    • act: SystemAct

      act

    • input: ControlInput

      The input object

    • propValue: object | function

      Constant or function producing a map of key:value pairs

    Returns object

    • [key: string]: any

evaluateBooleanProp

  • evaluateBooleanProp(propValue: boolean | function, input: ControlInput): boolean
  • Evaluate a boolean prop.

    Parameters

    • propValue: boolean | function

      Constant or function producing boolean

    • input: ControlInput

      The input object

    Returns boolean

evaluateFunctionProp

  • evaluateFunctionProp<T>(prop: T | function, input: ControlInput): T

evaluatePromptProp

getChoicesList

  • Parameters

    Returns string[]

getListItemIDs

  • Parameters

    Returns string[]

getSerializableState

  • getSerializableState(): any
  • Gets the Control's state as an object that is serializable.

    Only durable state should be included and the object should be serializable with a straightforward application of JSON.stringify(object).

    Default: {return this.state;}

    Usage:

    • This method must be idempotent (multiple calls must not change the result).
    • The default is sufficient for Controls that use the .state variable and only store simple data.
      • Non-simple data includes functions, and objects with functions, as these will not survive the round trip.
      • Other non-simple data include types with non-enumerable properties.
    • It is safe to pass the actual state object as the framework guarantees to not mutate it.
    • Functions that operate on the Control's state should be defined as member function of the Control type, or as props.

    Framework behavior:

    • During the shutdown phase the state of the control tree is collected by calling this function for each control.
    • The framework serializes the data use a simple application of JSON.stringify.
    • On the subsequent turn the control tree is rebuilt and the state objects are re-attached to each Control via control.setSerializableState(serializedState).

    Returns any

    Serializable object defining the state of the Control

handle

isReady

  • Determines if the Control's value is ready for use by other parts of the skill.

    Note:

    • A basic invariant is isReady === !canTakeInitiative because isReady implies that no further discussion is required and thus there is no need to take the initiative.

    Parameters

    Returns Promise<boolean>

    true if the control has no further questions to ask the user such as elicitation, clarification or confirmation.

reestablishState

  • reestablishState(state: any, controlStateMap: object): void
  • Reestablishes the state of the control.

    Default implementations:

    • Control: reestablishes the state via this.setSerializableState(state).
    • ContainerControl: reestablishes the state and recursively reestablishes state for all children.
    • DynamicContainerControl: reestablishes the state, rebuilds any dynamic child controls, and recursively reestablishes state for all children.

    Parameters

    • state: any
    • controlStateMap: object
      • [index: string]: any

    Returns void

renderAPLComponent

renderAct

setSerializableState

  • setSerializableState(serializedState: any): void
  • Sets the state from a serialized state object.

    Default: {this.state = serializedState;}

    Usage:

    • This method must be idempotent (multiple calls must not change the result).
    • It is safe to use serializedState without copying as the framework guarantees to not mutate it.

    Framework behavior:

    • During the initialization phase the control tree is rebuilt and state objects are re-attached to controls by calling this method for each control.

    Parameters

    • serializedState: any

      Serializable object defining the state of the Control

    Returns void

setValue

  • setValue(value: string, erMatch?: boolean): void
  • Directly set the value.

    Parameters

    • value: string

      Value

    • Default value erMatch: boolean = true

      Whether the value is an ID defined for this.slotType in the interaction model

    Returns void

stringifyStateForDiagram

  • stringifyStateForDiagram(): string
  • Returns string

takeInitiative

throwUnhandledActError

  • throwUnhandledActError(act: SystemAct): never

updateInteractionModel

validateAndAddActs

  • Parameters

    Returns Promise<void>

Static defaultValueRenderer

  • defaultValueRenderer(): function

Static mergeWithDefaultProps

  • Merges the user-provided props with the default props.

    Any property defined by the user-provided data overrides the defaults.

    Parameters

    Returns DeepRequired<ListControlProps>