Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
alexa-ability
Advanced tools
Create skills for the Alexa Skills Kit
/** @jsx ssml */
import { Ability, events } from 'alexa-ability';
import { handleAbility } from 'alexa-ability-lambda-handler';
import { ssml } from 'alexa-ssml';
const app = new Ability();
app.use(function(req, next) {
logRequest(req);
next();
});
ability.on(events.LAUNCH, function(req) {
const speech = (
<speak>
Hello <pause time={100} /> world
</speak>
);
req.say(speech).show('Hello, world!');
});
ability.on('MeaningOfLifeIntent', function(req, next) {
asyncRequest(function(err) {
if (err) return next(err);
req.say('42').end();
});
});
ability.on('error', function(err, req, next) {
req.say('Uhoh, something went wrong');
});
export const handler = handle(app);
new Ability(options) -> ability
Ability.prototype.use(handler) -> ability
Add middleware to the ability. Middleware will be called in the order added. Each middleware function will be called with a request instance as the first argument and a "next" function that must be called when the middleware is finished.
If the middleware
function exampleMiddleware(req, next) {
isAllowed(function(err, isAllowed) {
if (err) return next(err); // pass along error
if (isAllowed) return next(); // do next middleware
req.say("I'm sorry, Dave. I'm afraid I can't do that.").end();
});
}
Ability.prototype.on(event, handler) -> ability
Add an event handler to the ability. The handler function will be called with a request instance as the first argument and a "next" function that can be used to pass errors down.
Ability.prototype.handle(event, callback) -> request
Handle an event, this function expects the JSON object from the Alexa request and a node style callback.
new Request(event) -> request
request.raw
The original event object passed to the ability.
request.sent
A boolean indicating whether this request has been sent.
request.isNew
A boolean value indicating whether this is a new session. Returns true for a new session or false for an existing session.
request.version
The version specifier for the request with the value defined as: “1.0”
request.session
A map of key-value pairs. The attributes map is empty for requests where a new session has started with the attribute new set to true.
Any changes to the session object will be persisted.
request.user
An object that describes the user making the request. A user is composed of:
request.params
or request.slots
An object of key value pairs. Where the keys are the slot names.
For an intent like this:
{
"name": "GetZodiacHoroscopeIntent",
"slots": {
"ZodiacSign": {
"name": "ZodiacSign",
"value": "virgo"
}
}
}
The object will look like:
{
"ZodiacSign": "virgo"
}
request.say(text|ssml) -> request
Indicate the speech to return to the user.
request.show(title, content) -> request
Indicate the title and content to display as a card on the Alexa app.
request.reprompt(text|ssml) -> request
Indicate the reprompt speech to say to the user. This will only be used if the your service keeps the session open after sending the response, but the user does not respond with anything that maps to an intent.
If this is not set, the user is not re-prompted.
request.end() -> undefined
Indicate that the session should be ended by the response. This function will also send the response.
request.send() -> undefined
Send the response.
request.toJSON() -> Object
Get a properly formatted response JSON object.
events.unhandledEvent
: No event handler foundevents.unknownEvent
: Handle unknown request typesevents.error
: Handle all errorsevents.launch
: Corresponds to LaunchRequest
events.end
: Corresponds to SessionEndedRequest
events.cancel = "AMAZON.CancelIntent"
events.help = "AMAZON.HelpIntent"
events.no = "AMAZON.NoIntent"
events.yes = "AMAZON.YesIntent"
events.repeat = "AMAZON.RepeatIntent"
events.restart = "AMAZON.StartOverIntent"
events.stop = "AMAZON.StopIntent"
FAQs
An Alexa skills framework for node
The npm package alexa-ability receives a total of 31 weekly downloads. As such, alexa-ability popularity was classified as not popular.
We found that alexa-ability 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.