Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BSTAlexa

deprecated



Programmatic interface for interacting with the Bespoken Alexa emulator.
We have moved this functionality to its own repo, Bespoken Virtual Alexa
Please use that for new development.
This class will be removed in future versions to be replaced by calls to that library

Overview on usage can be found here. NodeJS tutorial here

Hierarchy

  • BSTAlexa

Index

Constructors

constructor

  • new BSTAlexa(skillURL: string, intentSchemaFile?: string, sampleUtterancesFile?: string, applicationID?: string): BSTAlexa

Properties

Static DefaultIntentSchemaLocation

DefaultIntentSchemaLocation: string = "speechAssets/IntentSchema.json"

Static DefaultSampleUtterancesLocation

DefaultSampleUtterancesLocation: string = "speechAssets/SampleUtterances.txt"

Methods

context

intended

  • intended(intentName: string, slots?: object, callback?: function): BSTAlexa
  • Emulates the specified intent coming from the Alexa device.

    Parameters

    • intentName: string

      The name of the intent - must exactly match the IntentSchema

    • Optional slots: object

      A key-value dictionary of slots in the form { "slotName": "slotValue" }

      • [id: string]: string
    • Optional callback: function

      Returns any error, along the response and request JSON associated with this call

        • (error: any, response: any, request: any): void
        • Parameters

          • error: any
          • response: any
          • request: any

          Returns void

    Returns BSTAlexa

    Itself

launched

  • launched(callback?: function): BSTAlexa
  • Emulates the specified skill being launched

    Parameters

    • Optional callback: function

      Returns any error, along the response and request JSON associated with this call

        • (error: any, response: any, request: any): void
        • Parameters

          • error: any
          • response: any
          • request: any

          Returns void

    Returns BSTAlexa

    Itself

on

  • on(eventType: string, callback: function): BSTAlexa
  • Registers a callback for Skill events

    For AudioPlayer events, the payload is an AudioItem

    For event type BSTAlexaEvents.Response, the payload is the response body as JSON A second parameter with the body of the request as JSON is also passed

    Parameters

    • eventType: string
    • callback: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns BSTAlexa

    Itself

once

  • once(eventType: string, callback: function): BSTAlexa
  • Registers a one-time callback for Skill events

    For AudioPlayer events, the payload is an AudioItem

    For event type BSTAlexaEvents.Response, the payload is the response body as JSON A second parameter with the body of the request as JSON is also passed

    Parameters

    • eventType: string
    • callback: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns BSTAlexa

    Itself

playbackFinished

  • playbackFinished(callback?: function): BSTAlexa
  • Emulates the current track playing to completion.

    The Alexa Emulator will automatically play the next queued track as well as signal to your skill the current track has completed

    @param callback Returns any error, along the response and request JSON associated with this call @returns Itself

    Parameters

    • Optional callback: function
        • (error: any, response: any, request: any): void
        • Parameters

          • error: any
          • response: any
          • request: any

          Returns void

    Returns BSTAlexa

playbackNearlyFinished

  • playbackNearlyFinished(callback?: function): BSTAlexa
  • Triggers a AudioPlayer.PlaybackNearlyFinished request from Alexa

    Parameters

    • Optional callback: function

      Returns any error, along the response and request JSON associated with this call

        • (error: any, response: any, request: any): void
        • Parameters

          • error: any
          • response: any
          • request: any

          Returns void

    Returns BSTAlexa

    Itself

playbackOffset

  • playbackOffset(offsetInMilliseconds: number): BSTAlexa
  • Emulates the track being played back

    Updates the offset time on the track

    Parameters

    • offsetInMilliseconds: number

    Returns BSTAlexa

    Itself

playbackStopped

  • playbackStopped(callback?: function): BSTAlexa
  • Triggers a AudioPlayer.PlaybackStopped request from Alexa

    Parameters

    • Optional callback: function

      Returns any error, along the response and request JSON associated with this call

        • (error: any, response: any, request: any): void
        • Parameters

          • error: any
          • response: any
          • request: any

          Returns void

    Returns BSTAlexa

    Itself

sessionEnded

  • sessionEnded(sessionEndedReason: string, callback?: function): BSTAlexa
  • Ends the session - requires a reason

    Parameters

    • sessionEndedReason: string

      Can be ERROR, EXCEEDED_MAX_REPROMPTS or USER_INITIATED

    • Optional callback: function

      Returns any error, along the response and request JSON associated with this call

        • (error: any, response: any, request: any): void
        • Parameters

          • error: any
          • response: any
          • request: any

          Returns void

    Returns BSTAlexa

    Itself

spoken

  • spoken(phrase: string, callback?: function): BSTAlexa
  • Emulates the specified phrase being said to an Alexa device.

    To send an utterance that uses slots, surround the slot variables like so: {MySlotValue}

    For example, if the sample utterance was defined as:

    HelloWorld Hello world, my name is {Name}
    

    Then the call would be:

    alexa.spoken("Hello World, my name is {John}");
    

    Parameters

    • phrase: string
    • Optional callback: function

      Returns any error, along the response and request JSON associated with this call

        • (error: any, response: any, request: any): void
        • Parameters

          • error: any
          • response: any
          • request: any

          Returns void

    Returns BSTAlexa

    Itself

start

  • start(ready: function): void
  • Start the emulator

    Parameters

    • ready: function

      Passes back an error if there are any issues with initialization

        • (error?: string): void
        • Parameters

          • Optional error: string

          Returns void

    Returns void

stop

  • stop(onStop: function): void
  • Turns off the Alexa emulator. Useful for running inside of tests to ensure all cleanup has completed before next test starts.

    Parameters

    • onStop: function
        • (): void
        • Returns void

    Returns void

Generated using TypeDoc