
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
ask-toolkit
Advanced tools
Helper methods to be used in conjunction with Amazon's ask-sdk. (https://ask-sdk-for-nodejs.readthedocs.io/en/latest/)
npm install --save ask-toolkit
Creates display templates, sends tracking events (if configured), links accounts with LWA (if configured) and sends response to Alexa.
index.js
alexa.registerHandlers( responseHandlers, ... )responseBuilder = require( "ask-toolkit" ).response.buildermodule.exports = [ handler1, handler2, etc ];return handlerInput.responseBuilder.getResponse() with return responseBuilder.ask( handlerInput, responseObj );Replace
return handlerInput.responseBuilder.speak( output ).reprompt( reprompt ).withSimpleCard( cardTitle, card ).getResponse()
with
return responseBuilder.ask( handlerInput, { speech: { output: output, reprompt: reprompt }, card: { title: cardTitle, output: card } } )
responseBuilder.ask( handlerInput, askData, options )responseBuilder.tell( handlerInput, tellData, options )responseBuilder.askForPermissions( handlerInput, data, options, permissions )responseBuilder.sendDirective( handlerInput, type, name, payload, token )responseBuilder.sendLinkAccountCard( handlerInput, data, options )askData = {
card: (Card),
speech: {
output: (String),
reprompt: (String)
},
display: (Display)
}
tellData = {
card: (Card),
speech: {
output: (String)
},
display: (Display)
}
options = {
outgoingIntent: {
name: (String),
slots: {
(String): {
name: (String),
value: (String)
}
},
repeatSpeech: { // Can also be passed as data.repeatSpeech
output: (String),
reprompt: (String)
},
saveRepeat: (Boolean) true,
shouldEndSession: true | false | null,
track: (Boolean) true
}
Card = {
image: {
smallImageUrl: (URL),
largeImageUrl: (URL)
},
output: (String),
title: (String)
}
Display = {
actionLinks: (Unknown),
backButton: (Enum) HIDDEN | VISIBLE (default),
backgroundImage: (ImageObj),
hint: (String),
image: (ImageObj),
list: [List],
template: (Enum) BodyTemplate1 | BodyTemplate2 | BodyTemplate3 | BodyTemplate6 | BodyTemplate7 | ListTemplate1 | ListTemplate2,
text: {
primary: (TextObj),
secondary: (TextObj),
tertiary: (TextObj),
},
title: (String),
token: (String)
}
ImageObj = {
url: (URL),
description: (String)(optional)
height: (Int)(optional),
width: (Int)(optional),
size: (Enum)(optional) X_SMALL | SMALL | MEDIUM | LARGE | X_LARGE
}
List = {
image: (ImageObj)
text: {
primary: (TextObj),
secondary: (TextObj),
tertiary: (TextObj),
},
token: (String)
}
TextObj = {
type: (Enum) PlainText | RichText,
text: (String)
}
Size Recommendations:
ask-tools.response.utils.replaceInSpeechAndCard( responseData, replaceObj ) ask-tools.response.utils.replaceInSpeechAndCard(
{
speech: {
output: "replace {foo}"
}
},
{
"{foo}": "bar"
}
);
returns:
{
speech: {
output: "replace bar"
}
}
ask-tools.response.utils.replaceInDisplay( responseData, replaceObj ) ask-tools.response.utils.replaceInDisplay(
{
display: {
"template": "BodyTemplate2",
"text": {
"primary": {
"type": "RichText",
"text": "replace {foo}"
},
"secondary": {
"type": "RichText",
"text": "replace {foo}"
},
"tertiary": {
"type": "PlainText",
"text": "replace {foo}"
}
}
}
},
{
"{foo}": "bar"
}
);
returns:
{
display: {
"template": "BodyTemplate2",
"text": {
"primary": {
"type": "RichText",
"text": "replace bar"
},
"secondary": {
"type": "RichText",
"text": "replace bar"
},
"tertiary": {
"type": "PlainText",
"text": "replace bar"
}
}
}
}
ask-tools.response.utils.replaceInAll( responseData, replaceObj )replaceInSpeechAndCard and replaceInDisplayANALYTICS_PROVIDER env var (default: DASHBOT)ask-tools.analytics.enums.analyticsProvider = {
DASHBOT: "dashbot"
}
ANALYTICS_TOKEN env varindex.js
analytics = require( "ask-tools" ).analyticsAlexa.SkillBuilders.custom().addRequestInterceptors( analytics.sendRequestTracking )index.js
Alexa.SkillBuilders.custom().withApiClient( new Alexa.DefaultApiClient() )index.js
Alexa.SkillBuilders.custom().withApiClient( new Alexa.DefaultApiClient() )index.js
const localization = require( "ask-toolkit" ).localization( strings );Alexa.SkillBuilders.custom().addRequestInterceptors( localization.requestInterceptor )handlerInput.attributesManager.getRequestAttributes().t( stringKey )index.js
persistence = require( "ask-toolkit" ).persistenceAlexa.SkillBuilders.custom().withPersistenceAdapter( persistence.dynamoAdapter( process.env.DYNAMODB_TABLE ) )All methods are additive. They do not overwrite other object properties.
async setPersistentAttributes( handlerInput, attributeObject )setRequestAttributes( handlerInput, attributeObject )setSessionAttributes( handlerInput, attributeObject )async updatePersistentAttribute( handlerInput, attributeKey, val )updateRequestAttribute( handlerInput, attributeKey, val )updateSessionAttribute( handlerInput, attributeKey, val )kmsService = require( "ask-toolkit" ).kmsServiceawait kmsService.decrypt( { apiKey: process.env[ "API_KEY" ] } );FAQs
Toolkit to be used with ask-sdk to simplify Alexa development.
We found that ask-toolkit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.