alexa-ability ![Build Status](https://travis-ci.org/nickclaw/alexa-ability.svg?branch=master)
Create skills for the Alexa Skills Kit
Example
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);
API
Ability
new Ability(options) -> ability
Ability.prototype.use(handler) -> ability
Ability.prototype.on(event, handler) -> ability
Ability.prototype.handle(object, callback) -> request
Request
new Request(event) -> request
Request.prototype.say(text|ssml) -> request
Request.prototype.show(title, content) -> request
Request.prototype.reprompt(text|ssml) -> request
Request.prototype.end() -> undefined
Request.prototype.send() -> undefined
Request.prototype.toJSON() -> Object
events
Default Events
events.unhandledEvent
: No event handler foundevents.unknownEvent
: Handle unknown request typesevents.error
: Handle all errorsevents.launch
: Corresponds to LaunchRequest
events.end
: Corresponds to SessionEndedRequest
Amazon Intents
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"