-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Stefan Gründel
committed
Mar 23, 2017
1 parent
a5d25e2
commit b1e228e
Showing
8 changed files
with
227 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,7 @@ jspm_packages | |
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Emacs stuff | ||
*~ | ||
.dir-locals.el |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"intents": [ | ||
{ | ||
"intent": "EmitQuotationIntent" | ||
}, | ||
{ | ||
"intent": "AMAZON.HelpIntent" | ||
}, | ||
{ | ||
"intent": "AMAZON.StopIntent" | ||
}, | ||
{ | ||
"intent": "AMAZON.CancelIntent" | ||
} | ||
] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
EmitQuotationIntent nach einem Zitat | ||
EmitQuotationIntent nach einem Spruch | ||
EmitQuotationIntent gib mir ein Zitat |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* eslint-disable func-names */ | ||
/* eslint quote-props: ["error", "consistent"]*/ | ||
/** | ||
* This sample demonstrates a simple skill built with the Amazon Alexa Skills | ||
* nodejs skill development kit. | ||
* This sample supports multiple lauguages. (en-US, en-GB, de-DE). | ||
* The Intent Schema, Custom Slots and Sample Utterances for this skill, as well | ||
* as testing instructions are located at https://github.com/alexa/skill-sample-nodejs-fact | ||
**/ | ||
|
||
'use strict'; | ||
|
||
const Alexa = require('alexa-sdk'); | ||
|
||
const APP_ID = 'amzn1.ask.skill.0b9d09d1-e37f-4753-8e50-e8adbfd6aeeb'; | ||
const languageStrings = { | ||
'en': { | ||
translation: { | ||
CARD_TITLE: 'Awesome Quotations', | ||
QUOTE_MESSAGE: 'Here\'s your quote: ', | ||
HELP_MESSAGE: 'You can say "Give me a quote", or you can say "Exit". How can I help you?', | ||
HELP_REPROMPT: 'How can I help you?', | ||
STOP_MESSAGE: 'Goodbye!', | ||
}, | ||
}, | ||
|
||
'de': { | ||
translation: { | ||
CARD_TITLE: 'Schöne Sprüche', | ||
QUOTE_MESSAGE: 'Hier ist dein Spruch: ', | ||
HELP_MESSAGE: 'Du kannst sagen „Gib mir ein Zitat“, oder du kannst „Beenden“ sagen. Was soll ich tun?', | ||
HELP_REPROMPT: 'Was soll ich tun?', | ||
STOP_MESSAGE: 'Bis bald!', | ||
}, | ||
}, | ||
}; | ||
|
||
const QUOTES = [ | ||
'Man muß das Unmögliche versuchen, um das Mögliche zu erreichen.', | ||
'Man braucht vor niemand Angst zu haben. Wenn man jemanden fürchtet, dann kommt es daher, daß man diesem Jemand Macht über sich eingeräumt hat. (aus "Demian")', | ||
'Leute mit Mut und Charakter sind den anderen Leuten immer sehr unheimlich.', | ||
'Wenn wir einen Menschen glücklicher und heiterer machen können, so sollten wir es in jedem Fall tun, mag er uns darum bitten oder nicht.', | ||
'Es wird immer gleich ein wenig anders, wenn man es ausspricht.', | ||
'Jeder Mensch ist liebenswert, wenn er wirklich zu Worte kommt.', | ||
'Solange du nach dem Glück jagst, bist du nicht reif zum Glücklichsein.', | ||
'Wahrlich, keiner ist weise, der nicht das Dunkel kennt.', | ||
'Ein Haus ohne Bücher ist arm, auch wenn schöne Teppiche seinen Böden und kostbare Tapeten und Bilder die Wände bedecken.', | ||
'Eigensinn macht Spaß.', | ||
'Das Amt des Dichters ist nicht das Zeigen der Wege, sondern vor allem das Wecken der Sehnsucht.', | ||
'Nur das Denken, das wir leben, hat einen Wert.', | ||
'Wer das Denken zur Hauptsache macht, der kann es darin zwar weit bringen, aber er hat doch eben den Boden mit dem Wasser vertauscht, und einmal wird er ersaufen.', | ||
'Wahrer Beruf für den Menschen ist nur, zu sich selbst zu kommen.', | ||
'Solang du um Verlorenes klagst und Ziele hast und rastlos bist, weisst du noch nicht, was Friede ist.', | ||
'In der ganzen Welt ist jeder Politiker sehr für Revolution, für Vernunft und Niederlegung der Waffen - nur beim Feind, ja nicht bei sich selbst.', | ||
'Ich weiß nicht, ob mein Leben nutzlos und bloß ein Mißverständnis war oder ob es einen Sinn hat. (aus "Das Glasperlenspiel")', | ||
'Von den vielen Welten, die der Mensch nicht von der Natur geschenkt bekam, sondern sich aus eigenem Geist erschaffen hat, ist die Welt der Bücher die größte.', | ||
'Gerade das ist es ja, das Leben, wenn es schön und glücklich ist ein Spiel! Natürlich kann man auch alles mögliche andere aus ihm machen, eine Pflicht oder einen Krieg oder ein Gefängnis, aber es wird dadurch nicht hübscher.', | ||
'Gegner bedürfen einander oft mehr als Freunde, denn ohne Wind gehen keine Mühlen.', | ||
'Die Praxis sollte das Ergebnis des Nachdenkens sein, nicht umgekehrt.', | ||
'Man hat nur Angst, wenn man mit sich selber nicht einig ist. (aus "Demian")', | ||
'Intellektuelle Erkenntnisse sind Papiere. Vertrauen hat immer nur der, der von Erfahrenem redet.', | ||
]; | ||
|
||
const handlers = { | ||
'LaunchRequest': function () { | ||
this.emit('EmitQuotation'); | ||
}, | ||
'EmitQuotationIntent': function () { | ||
this.emit('EmitQuotation'); | ||
}, | ||
'EmitQuotation': function () { | ||
const quoteIndex = Math.floor(Math.random() * QUOTES.length); | ||
const randomQuote = QUOTES[quoteIndex]; | ||
|
||
// Create speech output | ||
const speechOutput = this.t('QUOTE_MESSAGE') + randomQuote; | ||
this.emit(':tellWithCard', speechOutput, this.t('CARD_TITLE'), randomQuote); | ||
}, | ||
'AMAZON.HelpIntent': function () { | ||
const speechOutput = this.t('HELP_MESSAGE'); | ||
const reprompt = this.t('HELP_REPROMPT'); | ||
this.emit(':ask', speechOutput, reprompt); | ||
}, | ||
'AMAZON.CancelIntent': function () { | ||
this.emit(':tell', this.t('STOP_MESSAGE')); | ||
}, | ||
'AMAZON.StopIntent': function () { | ||
this.emit(':tell', this.t('STOP_MESSAGE')); | ||
}, | ||
'SessionEndedRequest': function () { | ||
this.emit(':tell', this.t('STOP_MESSAGE')); | ||
}, | ||
}; | ||
|
||
exports.handler = (event, context) => { | ||
const alexa = Alexa.handler(event, context); | ||
alexa.appId = APP_ID; | ||
// To enable string internationalization (i18n) features, set a resources object. | ||
alexa.resources = languageStrings; | ||
alexa.registerHandlers(handlers); | ||
alexa.execute(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "awesome-quotations", | ||
"version": "1.0.0", | ||
"description": "Alexa Skill for awesome quotations", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/sgruendel/alexa-schoene-sprueche.git" | ||
}, | ||
"main": "index.js", | ||
"scripts": { | ||
"invoke": "aws lambda invoke --function-name 'awesomeQuotations' --payload fileb://../tests/events/alexa-start-session.json ../tests/out.txt && cat ../tests/out.txt", | ||
"test": "mocha", | ||
"deploy": "npm prune --production && npm run zip && npm run upload", | ||
"upload": "aws lambda update-function-code --function-name 'awesomeQuotations' --zip-file fileb://../index.zip", | ||
"zip": "zip -r ../index.zip . -x 'package.json' 'test/*' '*.git*' '*~'" | ||
}, | ||
"author": "Stefan Gründel", | ||
"license": "GPL-3.0", | ||
"dependencies": { | ||
"alexa-sdk": "^1.0.7" | ||
}, | ||
"devDependencies": { | ||
"aws-lambda-mock-context": "^3.0.1", | ||
"chai": "^3.5.0", | ||
"mocha": "^3.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
'use strict'; | ||
|
||
var expect = require('chai').expect; | ||
var index = require('../index'); | ||
|
||
const context = require('aws-lambda-mock-context'); | ||
const ctx = context(); | ||
|
||
describe('Testing a session with the EmitQuotationIntent', () => { | ||
var speechResponse = null | ||
var speechError = null | ||
|
||
before(function(done) { | ||
index.handler( { | ||
"session": { | ||
"sessionId": "SessionId.154291c5-a13f-4e7a-ab5a-2342534adfeba", | ||
"application": { | ||
"applicationId": "amzn1.ask.skill.0b9d09d1-e37f-4753-8e50-e8adbfd6aeeb" | ||
}, | ||
"attributes": {}, | ||
"user": { | ||
"userId": "amzn1.ask.account.[unique-value-here]" | ||
}, | ||
"new": true | ||
}, | ||
"request": { | ||
"type": "IntentRequest", | ||
"requestId": "amzn1.echo-api.request.[unique-value-here]", | ||
"timestamp": "2016-07-05T22:02:01Z", | ||
"intent": { | ||
"name": "EmitQuotationIntent", | ||
"slots": {} | ||
}, | ||
"locale": "en-US" | ||
}, | ||
"version": "1.0" | ||
}, ctx) | ||
|
||
ctx.Promise | ||
.then(resp => { speechResponse = resp; done(); }) | ||
.catch(err => { speechError = err; done(); }) | ||
}) | ||
|
||
describe('The response is structurally correct for Alexa Speech Services', () => { | ||
it('should not have errored', () => { | ||
expect(speechError).to.be.null | ||
}) | ||
|
||
it('should have a version', () => { | ||
expect(speechResponse.version).to.exist | ||
}) | ||
|
||
it('should have a speechlet response', () => { | ||
expect(speechResponse.response).to.exist | ||
}) | ||
|
||
it('should have a spoken response', () => { | ||
expect(speechResponse.response.outputSpeech).to.exist | ||
}) | ||
|
||
it('should have a card response', () => { | ||
expect(speechResponse.response.card).to.exist | ||
}) | ||
|
||
/* | ||
it('should have session attributes', () => { | ||
expect(speechResponse.response.sessionAttributes).to.exist | ||
}) | ||
*/ | ||
|
||
it('should end the alexa session', () => { | ||
expect(speechResponse.response.shouldEndSession).to.be.true | ||
}) | ||
}) | ||
}) |