Options
All
  • Public
  • Public/Protected
  • All
Menu

ASK SDK for Node.js

Index

Modules

Classes

Interfaces

Type aliases

Variables

Functions

Object literals

Type aliases

Cause

Describes the type of the Cause.

interface

DialogState

DialogState: "STARTED" | "IN_PROGRESS" | "COMPLETED"

Enumeration indicating the status of the multi-turn dialog. This property is included if the skill meets the requirements to use the Dialog directives. Note that COMPLETED is only possible when you use the Dialog.Delegate directive. If you use intent confirmation, dialogState is considered COMPLETED if the user denies the entire intent (for instance, by answering “no” when asked the confirmation prompt). Be sure to also check the confirmationStatus property on the Intent object before fulfilling the user’s request.

enum

Directive

interface

IntentConfirmationStatus

IntentConfirmationStatus: "NONE" | "DENIED" | "CONFIRMED"

Indication of whether an intent or slot has been explicitly confirmed or denied by the user, or neither.

enum

LambdaHandler

LambdaHandler: function

Type definition of LambdaHandler which contains inputs received in lambda function. https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html.

Type declaration

    • (requestEnvelope: RequestEnvelope, context: any, callback: function): void
    • Parameters

      • requestEnvelope: RequestEnvelope
      • context: any
      • callback: function
          • (err: Error, result?: any): void
          • Parameters

            • err: Error
            • Optional result: any

            Returns void

      Returns void

ObjectKeyGenerator

ObjectKeyGenerator: function

Type definition of function used by S3PersistenceAdapter to extract attributes id from RequestEnvelope.

Type declaration

    • (requestEnvelope: RequestEnvelope): string
    • Parameters

      • requestEnvelope: RequestEnvelope

      Returns string

PartitionKeyGenerator

PartitionKeyGenerator: function

Type definition of function used by DynamoDbPersistenceAdapter to extract attributes id from RequestEnvelope.

Type declaration

    • (requestEnvelope: RequestEnvelope): string
    • Parameters

      • requestEnvelope: RequestEnvelope

      Returns string

PermissionStatus

PermissionStatus: "GRANTED" | "DENIED"

This denotes the status of the permission scope.

enum

Request

A request object that provides the details of the user’s request. The request body contains the parameters necessary for the service to perform its logic and generate a response.

interface

SessionEndedErrorType

SessionEndedErrorType: "INVALID_RESPONSE" | "DEVICE_COMMUNICATION_ERROR" | "INTERNAL_SERVICE_ERROR" | "ENDPOINT_TIMEOUT"

A string indicating the type of error that occurred.

enum

SessionEndedReason

SessionEndedReason: "USER_INITIATED" | "ERROR" | "EXCEEDED_MAX_REPROMPTS"

The reason why session ended when not initiated from the Skill itself.

enum

SlotConfirmationStatus

SlotConfirmationStatus: "NONE" | "DENIED" | "CONFIRMED"

An enumeration indicating whether the user has explicitly confirmed or denied the value of this slot.

enum

SlotValue

Object representing the value captured in the slot.

interface

ViewportDpiGroup

ViewportDpiGroup: "XLOW" | "LOW" | "MEDIUM" | "HIGH" | "XHIGH" | "XXHIGH"

ViewportOrientation

ViewportOrientation: "EQUAL" | "LANDSCAPE" | "PORTRAIT"

ViewportProfile

ViewportProfile: "HUB-ROUND-SMALL" | "HUB-LANDSCAPE-SMALL" | "HUB-LANDSCAPE-MEDIUM" | "HUB-LANDSCAPE-LARGE" | "MOBILE-LANDSCAPE-SMALL" | "MOBILE-PORTRAIT-SMALL" | "MOBILE-LANDSCAPE-MEDIUM" | "MOBILE-PORTRAIT-MEDIUM" | "TV-LANDSCAPE-XLARGE" | "TV-PORTRAIT-MEDIUM" | "TV-LANDSCAPE-MEDIUM" | "UNKNOWN-VIEWPORT-PROFILE"

ViewportSizeGroup

ViewportSizeGroup: "XSMALL" | "SMALL" | "MEDIUM" | "LARGE" | "XLARGE"

Variables

Const ALEXA_SKILL_EVENT_LIST

ALEXA_SKILL_EVENT_LIST: Set<string> = new Set(['AlexaSkillEvent.SkillEnabled','AlexaSkillEvent.SkillDisabled','AlexaSkillEvent.SkillPermissionChanged','AlexaSkillEvent.SkillPermissionAccepted','AlexaSkillEvent.SkillAccountLinked'])

Const CERT_CHAIN_DOMAIN

CERT_CHAIN_DOMAIN: "echo-api.amazon.com" = "echo-api.amazon.com"

Const CERT_CHAIN_URL_PORT

CERT_CHAIN_URL_PORT: number = 443

Const CERT_END_KEY

CERT_END_KEY: "-----END CERTIFICATE-----" = "-----END CERTIFICATE-----"

Const CERT_START_KEY

CERT_START_KEY: "-----BEGIN CERTIFICATE-----" = "-----BEGIN CERTIFICATE-----"

Function used to convert certificate chain string into Certificate Object Array

param

certificate chain in pem format

returns

Const CHARACTER_ENCODING

CHARACTER_ENCODING: crypto.Utf8AsciiLatin1Encoding = "utf8"

Const MAXIMUM_NORMAL_REQUEST_TOLERANCE_IN_MILLIS

MAXIMUM_NORMAL_REQUEST_TOLERANCE_IN_MILLIS: number = 150000

Const MAXIMUM_SKILL_EVENT_TOLERANCE_IN_MILLIS

MAXIMUM_SKILL_EVENT_TOLERANCE_IN_MILLIS: number = 3600000

Const SIGNATURE_CERT_CHAIN_URL_HEADER

SIGNATURE_CERT_CHAIN_URL_HEADER: string = "SignatureCertChainUrl"

Const SIGNATURE_FORMAT

SIGNATURE_FORMAT: crypto.HexBase64Latin1Encoding = "base64"

Const SIGNATURE_HEADER

SIGNATURE_HEADER: string = "Signature"

Const StateString

StateString: unique symbol = Symbol('StateString')

Const VALID_SIGNING_CERT_CHAIN_PROTOCOL

VALID_SIGNING_CERT_CHAIN_PROTOCOL: string = "https:"

Const VALID_SIGNING_CERT_CHAIN_URL_HOST_NAME

VALID_SIGNING_CERT_CHAIN_URL_HOST_NAME: string = "s3.amazonaws.com"

Const VALID_SIGNING_CERT_CHAIN_URL_PATH_PREFIX

VALID_SIGNING_CERT_CHAIN_URL_PATH_PREFIX: string = "/echo.api/"

Const ViewportDpiGroupOrder

ViewportDpiGroupOrder: ViewportDpiGroup[] = [ 'XLOW', 'LOW', 'MEDIUM', 'HIGH', 'XHIGH', 'XXHIGH']

Const ViewportSizeGroupOrder

ViewportSizeGroupOrder: ViewportSizeGroup[] = [ 'XSMALL', 'SMALL', 'MEDIUM', 'LARGE', 'XLARGE']

Let dynamoDbPersistenceAdapter

dynamoDbPersistenceAdapter: DynamoDbPersistenceAdapter

Functions

CreateStateHandler

EmitEvent

  • EmitEvent(): void

EmitWithState

  • EmitWithState(): void

Const EventParser

  • EventParser(event: RequestEnvelope): string

IsObject

  • IsObject(obj: any): boolean

IsOverridden

  • IsOverridden(name: string): boolean

ValidateRequest

  • ValidateRequest(): void

Private arrayToObjectHeader

  • arrayToObjectHeader(header: Array<object>): object

asyncVerifyRequestAndDispatch

  • asyncVerifyRequestAndDispatch(httpRequestHeader: IncomingHttpHeaders, httpRequestBody: string, skill: Skill, verifiers: Verifier[]): Promise<ResponseEnvelope>
  • Verify request and dispatch

    This method first validate request with all provided verifiers Then, invoke the skill to handle request envelope to get response

    Parameters

    • httpRequestHeader: IncomingHttpHeaders

      Http request header

    • httpRequestBody: string

      Http request body in string format

    • skill: Skill

      ask-sdk-core custom skill instance

    • verifiers: Verifier[]

      Array of user customized Verifier instances

    Returns Promise<ResponseEnvelope>

createAskSdkError

  • createAskSdkError(errorScope: string, errorMessage: string): Error

createAskSdkUserAgent

  • createAskSdkUserAgent(packageVersion: string, customUserAgent?: string): string

createUserAgent

  • createUserAgent(packageVersion: string, customUserAgent: string): string
  • function creating an AskSdk user agent.

    Parameters

    • packageVersion: string
    • customUserAgent: string

    Returns string

escapeXmlCharacters

  • escapeXmlCharacters(input: string): string

generateCAStore

  • generateCAStore(certs: string[]): CAStore

generateCertificatesArray

  • generateCertificatesArray(certChain: string): Certificate[]

getAccountLinkingAccessToken

  • getAccountLinkingAccessToken(requestEnvelope: RequestEnvelope): string

getApiAccessToken

  • getApiAccessToken(requestEnvelope: RequestEnvelope): string

getDeviceId

  • getDeviceId(requestEnvelope: RequestEnvelope): string

getDialogState

  • getDialogState(requestEnvelope: RequestEnvelope): string

getIntentName

  • getIntentName(requestEnvelope: RequestEnvelope): string

getLocale

  • getLocale(requestEnvelope: RequestEnvelope): string

getRequest

  • getRequest<T>(requestEnvelope: RequestEnvelope): T
  • Get request object.

    We can set a specific type to the response by using the generics

    example
    const intentRequest = getRequest<IntentRequest>(requestEnvelope)
    console.log(intentRequest.intent.name)

    Type parameters

    Parameters

    • requestEnvelope: RequestEnvelope

    Returns T

getRequestType

  • getRequestType(requestEnvelope: RequestEnvelope): string

getSimpleSlotValues

  • getSimpleSlotValues(slotValue: SlotValue): SimpleSlotValue[]

getSlot

  • getSlot(requestEnvelope: RequestEnvelope, slotName: string): Slot
  • Returns the Slot for the given slot name from the request.

    This method attempts to retrieve the requested Slot from the incoming request. If the slot does not exist in the request, a null value will be returned.

    Parameters

    • requestEnvelope: RequestEnvelope
    • slotName: string

    Returns Slot

getSlotValue

  • getSlotValue(requestEnvelope: RequestEnvelope, slotName: string): string
  • Returns the value from the given Slot in the request.

    This method attempts to retrieve the requested Slot's value from the incoming request. If the slot does not exist in the request, a null will be returned.

    Parameters

    • requestEnvelope: RequestEnvelope
    • slotName: string

    Returns string

getSlotValueV2

  • getSlotValueV2(requestEnvelope: RequestEnvelope, slotName: string): SlotValue
  • Returns the SlotValue from the given Slot in the request.

    SlotValue will exist for slots using multiple slot value feature. And this method attempts to retrieve the requested Slot's SlotValue from the incoming request. If the slot or slot.slotValue does not exist in the request, null will be returned.

    Parameters

    • requestEnvelope: RequestEnvelope
    • slotName: string

    Returns SlotValue

getSupportedInterfaces

  • getSupportedInterfaces(requestEnvelope: RequestEnvelope): SupportedInterfaces
  • Retrieves the SupportedInterfaces from the request.

    This method returns an object listing each interface that the device supports. For example, if supportedInterfaces includes AudioPlayer, then you know that the device supports streaming audio using the AudioPlayer interface.

    Parameters

    • requestEnvelope: RequestEnvelope

    Returns SupportedInterfaces

getUserId

  • getUserId(requestEnvelope: RequestEnvelope): string

getViewportDpiGroup

getViewportOrientation

getViewportProfile

getViewportSizeGroup

handler

  • handler(event: RequestEnvelope, context: any, callback?: function): Adapter
  • Parameters

    • event: RequestEnvelope
    • context: any
    • Optional callback: function
        • (err: Error, result?: any): void
        • Parameters

          • err: Error
          • Optional result: any

          Returns void

    Returns Adapter

isBetween

  • isBetween(target: number, min: number, max: number): boolean

isNewSession

  • isNewSession(requestEnvelope: RequestEnvelope): boolean

Private objectToArrayHeader

  • objectToArrayHeader(header: object): Array<object>
  • Converts JSON header object to header array required for {services.ApiClientResponse}

    Parameters

    • header: object

      JSON header object returned by HTTP client

      • [key: string]: string | string[]

    Returns Array<object>

    []}

Object literals

Const ObjectKeyGenerators

ObjectKeyGenerators: object

Object containing implementations of ObjectKeyGenerator.

deviceId

  • deviceId(requestEnvelope: RequestEnvelope): string

userId

  • userId(requestEnvelope: RequestEnvelope): string

Const PartitionKeyGenerators

PartitionKeyGenerators: object

Object containing implementations of PartitionKeyGenerator.

deviceId

  • deviceId(requestEnvelope: RequestEnvelope): string

personId

  • personId(requestEnvelope: RequestEnvelope): string

userId

  • userId(requestEnvelope: RequestEnvelope): string

Const ResponseHandlers

ResponseHandlers: object

:ask

  • :ask(speechOutput: string, repromptSpeech: string): void

:askWithCard

  • :askWithCard(speechOutput: string, repromptSpeech: string, cardTitle: string, cardContent: string, imageObj: object): void

:askWithLinkAccountCard

  • :askWithLinkAccountCard(speechOutput: string, repromptSpeech: string): void

:askWithPermissionCard

  • :askWithPermissionCard(speechOutput: string, repromptSpeech: string, permissions: string[]): void

:confirmIntent

  • :confirmIntent(speechOutput: string, repromptSpeech: string, updatedIntent: Intent): void

:confirmIntentWithCard

  • :confirmIntentWithCard(speechOutput: string, repromptSpeech: string, cardTitle: string, cardContent: string, updatedIntent: Intent, imageObj: object): void
  • Parameters

    • speechOutput: string
    • repromptSpeech: string
    • cardTitle: string
    • cardContent: string
    • updatedIntent: Intent
    • imageObj: object
      • [key: string]: string

    Returns void

:confirmSlot

  • :confirmSlot(slotName: string, speechOutput: string, repromptSpeech: string, updatedIntent: Intent): void

:confirmSlotWithCard

  • :confirmSlotWithCard(slotName: string, speechOutput: string, repromptSpeech: string, cardTitle: string, cardContent: string, updatedIntent: Intent, imageObj: object): void
  • Parameters

    • slotName: string
    • speechOutput: string
    • repromptSpeech: string
    • cardTitle: string
    • cardContent: string
    • updatedIntent: Intent
    • imageObj: object
      • [key: string]: string

    Returns void

:delegate

  • :delegate(updatedIntent: Intent): void

:elicitSlot

  • :elicitSlot(slotName: string, speechOutput: string, repromptSpeech: string, updatedIntent: Intent): void

:elicitSlotWithCard

  • :elicitSlotWithCard(slotName: string, speechOutput: string, repromptSpeech: string, cardTitle: string, cardContent: string, updatedIntent: Intent, imageObj: object): void
  • Parameters

    • slotName: string
    • speechOutput: string
    • repromptSpeech: string
    • cardTitle: string
    • cardContent: string
    • updatedIntent: Intent
    • imageObj: object
      • [key: string]: string

    Returns void

:responseReady

  • :responseReady(): void

:saveState

  • :saveState(forceSave: boolean): void

:saveStateError

  • :saveStateError(error: Error): void

:tell

  • :tell(speechOutput: string): void

:tellWithCard

  • :tellWithCard(speechOutput: string, cardTitle: string, cardContent: string, imageObj: object): void

:tellWithLinkAccountCard

  • :tellWithLinkAccountCard(speechOutput: string): void

:tellWithPermissionCard

  • :tellWithPermissionCard(speechOutput: string, permissions: string[]): void

Const SkillBuilders

SkillBuilders: object

Provider for skill builder. Provider for skill builders.

custom

standard

Const SkillEventHandlers

SkillEventHandlers: object

AlexaSkillEvent.SkillAccountLinked

  • AlexaSkillEvent.SkillAccountLinked(): void

AlexaSkillEvent.SkillDisabled

  • AlexaSkillEvent.SkillDisabled(): void

AlexaSkillEvent.SkillEnabled

  • AlexaSkillEvent.SkillEnabled(): void

AlexaSkillEvent.SkillPermissionAccepted

  • AlexaSkillEvent.SkillPermissionAccepted(): void

AlexaSkillEvent.SkillPermissionChanged

  • AlexaSkillEvent.SkillPermissionChanged(): void

Const directives

directives: object

VoicePlayerSpeakDirective

VoicePlayerSpeakDirective: VoicePlayerSpeakDirective

Const templateBuilders

templateBuilders: object

BodyTemplate1Builder

BodyTemplate1Builder: BodyTemplate1Builder

BodyTemplate2Builder

BodyTemplate2Builder: BodyTemplate2Builder

BodyTemplate3Builder

BodyTemplate3Builder: BodyTemplate3Builder

BodyTemplate6Builder

BodyTemplate6Builder: BodyTemplate6Builder

BodyTemplate7Builder

BodyTemplate7Builder: BodyTemplate7Builder

ListItemBuilder

ListItemBuilder: ListItemBuilder

ListTemplate1Builder

ListTemplate1Builder: ListTemplate1Builder

ListTemplate2Builder

ListTemplate2Builder: ListTemplate2Builder

Const utils

utils: object

ImageUtils

ImageUtils: ImageUtils

TextUtils

TextUtils: TextUtils