Easily create Alexa Skills to run on AWS Lambda using ES6 classes and ES7 decorators.
Try it in the online playground or create your own Alexa skill with the Yeoman generator.
import { Skill, Intent, Launch } from 'alexa-annotations';
import { ask, say, card } from 'alexa-response';
import fetch from 'isomorphic-fetch';
@Skill
export default class Echo {
@Launch
launch() {
return ask('Welcome to the example Echo skill! What would you like me to repeat?');
}
@Intent('echo')
echo({ sentence }) {
return say(sentence).card({ title: 'Echo', content: sentence });
}
@Intent('AMAZON.HelpIntent')
help() {
return ask('I repeat whatever you say to me! What would you like me to repeat?');
}
@Intent('AMAZON.CancelIntent', 'AMAZON.StopIntent')
stop() {
return say('Goodbye');
}
@Intent('Credits')
credits() {
const url = 'https://raw.githubusercontent.com/cameronhunter/alexa-annotations/master/package.json';
return fetch(url).then(response => response.json()).then(({ name, author }) => {
return say(`${name} was created by ${author.name}`).card({ title: name, content: `Credits: ${author.name} <${author.email}> (${author.url})`});
});
}
}