Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ControlResponseBuilder

A specialized ResponseBuilder for use with Controls framework

This differs from the the regular @see ResponseBuilder in a couple of ways:

  1. The prompt and reprompt can be built up incrementally via addPromptFragment() and addRepromptFragment()
  2. .withShouldEndSession() is disabled as the information should be provided via see ControlResultBuilder during Control.handle() and Control.takeInitiative()

Hierarchy

  • ControlResponseBuilder

Implements

  • ResponseBuilder

Constructors

constructor

  • Parameters

    • responseBuilder: ResponseBuilder

    Returns ControlResponseBuilder

Properties

aplDocumentDataSources

aplDocumentDataSources: object

Type declaration

  • [key: string]: any

aplDocumentLayouts

aplDocumentLayouts: object

Type declaration

  • [key: string]: any

aplDocumentStyles

aplDocumentStyles: object

Type declaration

  • [key: string]: any

aplMode

aplMode: APLMode

coreBuilder

coreBuilder: ResponseBuilder

shouldEndSession

shouldEndSession: boolean

Methods

addAPLDocumentDataSource

  • addAPLDocumentDataSource(key: string, data: object): void
  • Parameters

    • key: string
    • data: object
      • [key: string]: any

    Returns void

addAPLDocumentLayout

  • addAPLDocumentLayout(key: string, data: object): void
  • Parameters

    • key: string
    • data: object
      • [key: string]: any

    Returns void

addAPLDocumentStyle

  • addAPLDocumentStyle(key: string, data: object): void
  • Parameters

    • key: string
    • data: object
      • [key: string]: any

    Returns void

addAPLRenderDocumentDirective

  • addAPLRenderDocumentDirective(token?: undefined | string, document?: undefined | object, datasources?: undefined | object, packages?: any[]): void
  • Parameters

    • Optional token: undefined | string
    • Optional document: undefined | object
    • Optional datasources: undefined | object
    • Optional packages: any[]

    Returns void

addAudioPlayerClearQueueDirective

  • addAudioPlayerClearQueueDirective(clearBehavior: interfaces.audioplayer.ClearBehavior): this
  • Parameters

    • clearBehavior: interfaces.audioplayer.ClearBehavior

    Returns this

addAudioPlayerPlayDirective

  • addAudioPlayerPlayDirective(playBehavior: ui.PlayBehavior, url: string, token: string, offsetInMilliseconds: number, expectedPreviousToken?: string | undefined, audioItemMetadata?: AudioItemMetadata | undefined): this
  • Parameters

    • playBehavior: ui.PlayBehavior
    • url: string
    • token: string
    • offsetInMilliseconds: number
    • Optional expectedPreviousToken: string | undefined
    • Optional audioItemMetadata: AudioItemMetadata | undefined

    Returns this

addAudioPlayerStopDirective

  • addAudioPlayerStopDirective(): this
  • Returns this

addConfirmIntentDirective

  • addConfirmIntentDirective(updatedIntent?: Intent | undefined): this
  • Parameters

    • Optional updatedIntent: Intent | undefined

    Returns this

addConfirmSlotDirective

  • addConfirmSlotDirective(slotToConfirm: string, updatedIntent?: Intent | undefined): this
  • Parameters

    • slotToConfirm: string
    • Optional updatedIntent: Intent | undefined

    Returns this

addDelegateDirective

  • addDelegateDirective(updatedIntent?: Intent | undefined): this
  • Parameters

    • Optional updatedIntent: Intent | undefined

    Returns this

addDirective

  • addDirective(directive: Directive): this
  • Parameters

    • directive: Directive

    Returns this

addDynamicEntitiesDirective

  • addDynamicEntitiesDirective(dynamicEntitiesDirective: DynamicEntitiesDirective): void
  • Parameters

    • dynamicEntitiesDirective: DynamicEntitiesDirective

    Returns void

addElicitSlotDirective

  • addElicitSlotDirective(slotToElicit: string, updatedIntent?: Intent | undefined): this
  • Parameters

    • slotToElicit: string
    • Optional updatedIntent: Intent | undefined

    Returns this

addHintDirective

  • addHintDirective(text: string): this
  • Parameters

    • text: string

    Returns this

addPromptFragment

  • addPromptFragment(promptFragment: string): this
  • Add a fragment to the prompt.

    Parameters

    • promptFragment: string

      Prompt fragment

    Returns this

addRenderTemplateDirective

  • addRenderTemplateDirective(template: interfaces.display.Template): this
  • Parameters

    • template: interfaces.display.Template

    Returns this

addRepromptFragment

  • addRepromptFragment(repromptFragment: string): this
  • Add a fragment to the reprompt.

    Parameters

    • repromptFragment: string

      Reprompt fragment

    Returns this

addVideoAppLaunchDirective

  • addVideoAppLaunchDirective(source: string, title?: string | undefined, subtitle?: string | undefined): this
  • Parameters

    • source: string
    • Optional title: string | undefined
    • Optional subtitle: string | undefined

    Returns this

build

  • build(): Response
  • Build the response.

    Returns Response

getPrompt

  • getPrompt(): string
  • Get the complete prompt.

    Concatenates the fragments with a single space between each.

    Returns string

getReprompt

  • getReprompt(): string
  • Get the complete reprompt.

    Concatenates the fragments with a single space between each.

    Returns string

getResponse

  • getResponse(): Response
  • Builds and returns the complete response.

    Returns Response

isDisplayUsed

  • isDisplayUsed(): boolean
  • Determines if a 'display or APL' directive has been added to the response.

    Returns boolean

reprompt

  • reprompt(repromptSpeechOutput: string, playBehavior?: "ENQUEUE" | "REPLACE_ALL" | "REPLACE_ENQUEUED" | undefined): this
  • Disabled. Use addRepromptFragment and withRepromptPlayBehavior.

    Parameters

    • repromptSpeechOutput: string
    • Optional playBehavior: "ENQUEUE" | "REPLACE_ALL" | "REPLACE_ENQUEUED" | undefined

    Returns this

setDisplayUsed

  • setDisplayUsed(used?: boolean): void
  • Sets the displayUsed flag to indicate if the Response includes content for the device display.

    Note: calling .withSimpleCard(), .withStandardCard(), .addAPLRenderDocumentDirective() or .addDirective(type=Alexa.Presentation) sets this to true automatically.

    Usage:

    • If you wish to keep existing APL active on device without resending, call this to communicate that the screen remains 'in use'.
    • Use this if the auto-detection does not work for some directive.

    Parameters

    • Default value used: boolean = true

    Returns void

speak

  • speak(speechOutput: string, playBehavior?: "ENQUEUE" | "REPLACE_ALL" | "REPLACE_ENQUEUED" | undefined): this
  • Disabled. Use addPromptFragment and withPromptPlayBehavior.

    Parameters

    • speechOutput: string
    • Optional playBehavior: "ENQUEUE" | "REPLACE_ALL" | "REPLACE_ENQUEUED" | undefined

    Returns this

withApiResponse

  • withApiResponse(apiResponse: any): this
  • Parameters

    • apiResponse: any

    Returns this

withAskForPermissionsConsentCard

  • withAskForPermissionsConsentCard(permissionArray: string[]): this
  • Parameters

    • permissionArray: string[]

    Returns this

withCanFulfillIntent

  • withCanFulfillIntent(canFulfillIntent: CanFulfillIntent): this
  • Parameters

    • canFulfillIntent: CanFulfillIntent

    Returns this

withLinkAccountCard

  • withLinkAccountCard(): this
  • Returns this

withPromptPlayBehavior

  • withPromptPlayBehavior(playBehavior?: ui.PlayBehavior): this
  • Set the prompt play behavior to associate with the complete prompt.

    Parameters

    • Optional playBehavior: ui.PlayBehavior

    Returns this

withRepromptPlayBehavior

  • withRepromptPlayBehavior(playBehavior?: ui.PlayBehavior): this
  • Set the reprompt play behavior to associate with the complete prompt.

    Parameters

    • Optional playBehavior: ui.PlayBehavior

    Returns this

withShouldEndSession

  • withShouldEndSession(val: boolean): this

withSimpleCard

  • withSimpleCard(cardTitle: string, cardContent: string): this
  • Parameters

    • cardTitle: string
    • cardContent: string

    Returns this

withStandardCard

  • withStandardCard(cardTitle: string, cardContent: string, smallImageUrl?: string | undefined, largeImageUrl?: string | undefined): this
  • Parameters

    • cardTitle: string
    • cardContent: string
    • Optional smallImageUrl: string | undefined
    • Optional largeImageUrl: string | undefined

    Returns this