Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MultiValueListControl

A Control that obtains multiple values 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 or list of values
  • Remove a value or list of values
  • Validate the value/values
  • Confirm the values
  • 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. "no, clear all names"
  • {ValueType}_ValueControlIntent: E.g. "add Elvis, May and Max".
  • 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

standardInitiativeHandlers

standardInitiativeHandlers: ControlInitiativeHandler[] = [{name: 'std::confirmValue',canTakeInitiative: this.wantsToConfirmValue,takeInitiative: this.confirmValue,},{name: 'std:elicitValue',canTakeInitiative: this.wantsToElicitValue,takeInitiative: this.elicitValue,},]

standardInputHandlers

standardInputHandlers: ControlInputHandler[] = [{name: 'AddWithValue (builtin)',canHandle: this.isAddWithValue,handle: this.handleAddWithValue,},{name: 'RemoveWithValue (builtin)',canHandle: this.isRemoveWithValue,handle: this.handleRemoveWithValue,},{name: 'ClearValue (builtin)',canHandle: this.isClearValue,handle: this.handleClearValue,},{name: 'ConfirmationAffirmed (builtin)',canHandle: this.isConfirmationAffirmed,handle: this.handleConfirmationAffirmed,},{name: 'ConfirmationDisaffirmed (builtin)',canHandle: this.isConfirmationDisaffirmed,handle: this.handleConfirmationDisaffirmed,},{name: 'SelectChoiceByTouch (built-in)',canHandle: this.isSelectChoiceByTouch,handle: this.handleSelectChoiceByTouch,},{name: 'DeleteChoiceByTouch (built-in)',canHandle: this.isRemoveChoiceByTouch,handle: this.handleRemoveChoiceByTouch,},{name: 'SelectDoneByTouch (built-in)',canHandle: this.isSelectDoneByTouch,handle: this.handleSelectDoneByTouch,},]

state

state: MultiValueListControlState = new MultiValueListControlState()

Methods

addValue

  • Add the value to state of this control.

    Parameters

    Returns void

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[]

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

getSlotIds

  • getSlotIds(): string[]
  • Returns string[]

getTargetIds

  • getTargetIds(): string[]
  • Returns string[]

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

stringifyStateForDiagram

  • stringifyStateForDiagram(): string
  • Returns string

takeInitiative

throwUnhandledActError

  • throwUnhandledActError(act: SystemAct): never

updateInteractionModel

Static mergeWithDefaultProps