import { Skill, Intent, Launch } from 'alexa-lambda-skill';
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-lambda-skill/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})`});
});
}
}