Addon package for the Alexa Skills Kit SDK
Installation
npm install ask-sdk-addon
Features
Handlers
NamedIntentRequestHandler
When creating RequestHandlers you can extend the NamedIntentRequestHandler
and specify the
intent name instead of implementing the canHandle
method.
The following RequestHandler will handle requests for the intents SomeIntent
and FoobarIntent
.
;
The following RequestHandler will handle LaunchRequests.
;
StatefulNamedIntentRequestHandler
If you want different handlers depending on the current state of your skill, you can extend the StatefulNamedIntentRequestHandler
and specify the
state and the intent name instead of implementing the canHandle
method.
The following RequestHandler will handle requests for the intent SomeIntent
if the session attribute _STATE
is myState
.
;
AudioPlayerRequestHandler
You can extend the AudioPlayerRequestHandler
and implement the methods to facilitate the processing of AudioPlayer events.
;
Helper
SlotHelper
Use the SlotHelper to get slot values or entity resolutions from slots.
Create an instance of the SlotHelper with new SlotHelper(requestEnvelope)
.
You can now call getValue
or resolveFirstValue
to get appropriate slot values.
; async handle
Using the isConfirmed
method you can get the confirmation status of the intent and slots.
StateHelper
Use the StateHelper to manage a state machine for your Skill's intents. Depending on the current state different handlers will be invoked for the same intent.
Create an instance of the StateHelper with new SlotHelper(handlerInput)
.
You can now call getCurrentState
to get the current state or setState(state)
or clearState()
to set the state for the next invocation.
; async handlehandlerInput
ResponseHelper
Use the ResponseHelper to add additional features to skill responses.
Create an instance of the ResponseHelper with new ResponseHelper(responseBuilder)
.
You can now call the additional methods for enhanced features.
; async handle
DisplayTemplateBuilder
Use the DisplayTemplateBuilder to ease the creation of RenderTemplates for display devices like Echo Show and Echo Spot.
Create an instance of the Builder with new DisplayTemplateBuilder({type: 'BodyTemplate2'})
.
; if DisplayTemplateBuilder.isDisplaySupportedhandlerInput.requestEnvelope
InterfaceHelper
The InterfaceHelper helps you determine which interfaces are supported by the calling device.
; InterfaceHelper.isAudioPlayerSupportedrequestEnvelope;InterfaceHelper.isVideoPlayerSupportedrequestEnvelope;InterfaceHelper.isDisplaySupportedrequestEnvelope;
Interceptor
LogRequestInterceptor
This interceptor logs all incoming requests to the console
;; SkillBuilders.custom.addRequestInterceptorsnew LogRequestInterceptor;
PersistAttributesInterceptor
This interceptor saves the persistent attributes to the data store
;; SkillBuilders.custom.addResponseInterceptorsnew PersistAttributesInterceptor;
ProfileInterceptor
These interceptors call the user profile service and populate request attributes
;; SkillBuilders.custom.addRequestInterceptorsnew TimeZoneInterceptor;SkillBuilders.custom.addRequestInterceptorsnew DistanceUnitsInterceptor;SkillBuilders.custom.addRequestInterceptorsnew TemperatureUnitInterceptor; handlerInput.attributesManager.getRequestAttributes.timeZone;handlerInput.attributesManager.getRequestAttributes.temperatureUnit;handlerInput.attributesManager.getRequestAttributes.distanceUnits;