Skip to content

Commit

Permalink
Updated with Skill Builder
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffblankenburg committed May 3, 2017
1 parent d3ef574 commit 07fbf9d
Show file tree
Hide file tree
Showing 10 changed files with 625 additions and 471 deletions.
375 changes: 28 additions & 347 deletions README.md

Large diffs are not rendered by default.

22 changes: 6 additions & 16 deletions speechAssets/IntentSchema.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
{
"intents": [
{
"intent": "GetNewFactIntent"
},
{
"intent": "AMAZON.HelpIntent"
},
{
"intent": "AMAZON.StopIntent"
},
{
"intent": "AMAZON.CancelIntent"
}
]
}
{ "intents": [
{ "intent": "GetNewFactIntent" },
{ "intent": "AMAZON.HelpIntent" },
{ "intent": "AMAZON.StopIntent" },
{ "intent": "AMAZON.CancelIntent" }
]}
36 changes: 36 additions & 0 deletions speechAssets/interaction-model.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"intents": [
{
"name": "AMAZON.CancelIntent",
"samples": []
},
{
"name": "AMAZON.HelpIntent",
"samples": []
},
{
"name": "AMAZON.StopIntent",
"samples": []
},
{
"name": "GetNewFactIntent",
"samples": [
"a fact",
"a space fact",
"tell me a fact",
"tell me a space fact",
"give me a fact",
"give me a space fact",
"tell me trivia",
"tell me a space trivia",
"give me trivia",
"give me a space trivia",
"give me some information",
"give me some space information",
"tell me something",
"give me something"
],
"slots": []
}
]
}
151 changes: 43 additions & 108 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,134 +1,69 @@
'use strict';
var Alexa = require('alexa-sdk');
var APP_ID = undefined; // TODO replace with your app ID (OPTIONAL).

var languageStrings = {
"en": {
"translation": {
"FACTS": [
"A year on Mercury is just 88 days long.",
"Despite being farther from the Sun, Venus experiences higher temperatures than Mercury.",
"Venus rotates counter-clockwise, possibly because of a collision in the past with an asteroid.",
"On Mars, the Sun appears about half the size as it does on Earth.",
"Earth is the only planet not named after a god.",
"Jupiter has the shortest day of all the planets.",
"The Milky Way galaxy will collide with the Andromeda Galaxy in about 5 billion years.",
"The Sun contains 99.86% of the mass in the Solar System.",
"The Sun is an almost perfect sphere.",
"A total solar eclipse can happen once every 1 to 2 years. This makes them a rare event.",
"Saturn radiates two and a half times more energy into space than it receives from the sun.",
"The temperature inside the Sun can reach 15 million degrees Celsius.",
"The Moon is moving approximately 3.8 cm away from our planet every year."
],
"SKILL_NAME" : "Space Facts",
"GET_FACT_MESSAGE" : "Here's your fact: ",
"HELP_MESSAGE" : "You can say tell me a space fact, or, you can say exit... What can I help you with?",
"HELP_REPROMPT" : "What can I help you with?",
"STOP_MESSAGE" : "Goodbye!"
}
},
"en-US": {
"translation": {
"FACTS": [
"A year on Mercury is just 88 days long.",
"Despite being farther from the Sun, Venus experiences higher temperatures than Mercury.",
"Venus rotates counter-clockwise, possibly because of a collision in the past with an asteroid.",
"On Mars, the Sun appears about half the size as it does on Earth.",
"Earth is the only planet not named after a god.",
"Jupiter has the shortest day of all the planets.",
"The Milky Way galaxy will collide with the Andromeda Galaxy in about 5 billion years.",
"The Sun contains 99.86% of the mass in the Solar System.",
"The Sun is an almost perfect sphere.",
"A total solar eclipse can happen once every 1 to 2 years. This makes them a rare event.",
"Saturn radiates two and a half times more energy into space than it receives from the sun.",
"The temperature inside the Sun can reach 15 million degrees Celsius.",
"The Moon is moving approximately 3.8 cm away from our planet every year."
],
"SKILL_NAME" : "American Space Facts"
}
},
"en-GB": {
"translation": {
"FACTS": [
"A year on Mercury is just 88 days long.",
"Despite being farther from the Sun, Venus experiences higher temperatures than Mercury.",
"Venus rotates anti-clockwise, possibly because of a collision in the past with an asteroid.",
"On Mars, the Sun appears about half the size as it does on Earth.",
"Earth is the only planet not named after a god.",
"Jupiter has the shortest day of all the planets.",
"The Milky Way galaxy will collide with the Andromeda Galaxy in about 5 billion years.",
"The Sun contains 99.86% of the mass in the Solar System.",
"The Sun is an almost perfect sphere.",
"A total solar eclipse can happen once every 1 to 2 years. This makes them a rare event.",
"Saturn radiates two and a half times more energy into space than it receives from the sun.",
"The temperature inside the Sun can reach 15 million degrees Celsius.",
"The Moon is moving approximately 3.8 cm away from our planet every year."
],
"SKILL_NAME" : "British Space Facts"
}
},
"de": {
"translation": {
"FACTS": [
"Ein Jahr dauert auf dem Merkur nur 88 Tage.",
"Die Venus ist zwar weiter von der Sonne entfernt, hat aber höhere Temperaturen als Merkur.",
"Venus dreht sich entgegen dem Uhrzeigersinn, möglicherweise aufgrund eines früheren Zusammenstoßes mit einem Asteroiden.",
"Auf dem Mars erscheint die Sonne nur halb so groß wie auf der Erde.",
"Die Erde ist der einzige Planet, der nicht nach einem Gott benannt ist.",
"Jupiter hat den kürzesten Tag aller Planeten.",
"Die Milchstraßengalaxis wird in etwa 5 Milliarden Jahren mit der Andromeda-Galaxis zusammenstoßen.",
"Die Sonne macht rund 99,86 % der Masse im Sonnensystem aus.",
"Die Sonne ist eine fast perfekte Kugel.",
"Eine Sonnenfinsternis kann alle ein bis zwei Jahre eintreten. Sie ist daher ein seltenes Ereignis.",
"Der Saturn strahlt zweieinhalb mal mehr Energie in den Weltraum aus als er von der Sonne erhält.",
"Die Temperatur in der Sonne kann 15 Millionen Grad Celsius erreichen.",
"Der Mond entfernt sich von unserem Planeten etwa 3,8 cm pro Jahr."
],
"SKILL_NAME" : "Weltraumwissen auf Deutsch",
"GET_FACT_MESSAGE" : "Hier sind deine Fakten: ",
"HELP_MESSAGE" : "Du kannst sagen, „Nenne mir einen Fakt über den Weltraum“, oder du kannst „Beenden“ sagen... Wie kann ich dir helfen?",
"HELP_REPROMPT" : "Wie kann ich dir helfen?",
"STOP_MESSAGE" : "Auf Wiedersehen!"
}
}
};
//=========================================================================================================================================
//TODO: The items below this comment need your attention.
//=========================================================================================================================================

//Replace with your app ID (OPTIONAL). You can find this value at the top of your skill's page on http:https://developer.amazon.com.
//Make sure to enclose your value in quotes, like this: var APP_ID = "amzn1.ask.skill.bb4045e6-b3e8-4133-b650-72923c5980f1";
var APP_ID = undefined;

var SKILL_NAME = "Space Facts";
var GET_FACT_MESSAGE = "Here's your fact: ";
var HELP_MESSAGE = "You can say tell me a space fact, or, you can say exit... What can I help you with?";
var HELP_REPROMPT = "What can I help you with?";
var STOP_MESSAGE = "Goodbye!";

//=========================================================================================================================================
//TODO: Replace this data with your own. You can find translations of this data at http:https://github.com/alexa/skill-sample-node-js-fact/data
//=========================================================================================================================================
var data = [
"A year on Mercury is just 88 days long.",
"Despite being farther from the Sun, Venus experiences higher temperatures than Mercury.",
"Venus rotates counter-clockwise, possibly because of a collision in the past with an asteroid.",
"On Mars, the Sun appears about half the size as it does on Earth.",
"Earth is the only planet not named after a god.",
"Jupiter has the shortest day of all the planets.",
"The Milky Way galaxy will collide with the Andromeda Galaxy in about 5 billion years.",
"The Sun contains 99.86% of the mass in the Solar System.",
"The Sun is an almost perfect sphere.",
"A total solar eclipse can happen once every 1 to 2 years. This makes them a rare event.",
"Saturn radiates two and a half times more energy into space than it receives from the sun.",
"The temperature inside the Sun can reach 15 million degrees Celsius.",
"The Moon is moving approximately 3.8 cm away from our planet every year."
];

//=========================================================================================================================================
//Editing anything below this line might break your skill.
//=========================================================================================================================================
exports.handler = function(event, context, callback) {
var alexa = Alexa.handler(event, context);
alexa.APP_ID = APP_ID;
// To enable string internationalization (i18n) features, set a resources object.
alexa.resources = languageStrings;
alexa.registerHandlers(handlers);
alexa.execute();
};

var handlers = {
'LaunchRequest': function () {
this.emit('GetFact');
this.emit('GetNewFactIntent');
},
'GetNewFactIntent': function () {
this.emit('GetFact');
},
'GetFact': function () {
// Get a random space fact from the space facts list
// Use this.t() to get corresponding language data
var factArr = this.t('FACTS');
var factArr = data;
var factIndex = Math.floor(Math.random() * factArr.length);
var randomFact = factArr[factIndex];

// Create speech output
var speechOutput = this.t("GET_FACT_MESSAGE") + randomFact;
this.emit(':tellWithCard', speechOutput, this.t("SKILL_NAME"), randomFact)
var speechOutput = GET_FACT_MESSAGE + randomFact;
this.emit(':tellWithCard', speechOutput, SKILL_NAME, randomFact)
},
'AMAZON.HelpIntent': function () {
var speechOutput = this.t("HELP_MESSAGE");
var reprompt = this.t("HELP_MESSAGE");
var speechOutput = HELP_MESSAGE;
var reprompt = HELP_REPROMPT;
this.emit(':ask', speechOutput, reprompt);
},
'AMAZON.CancelIntent': function () {
this.emit(':tell', this.t("STOP_MESSAGE"));
this.emit(':tell', STOP_MESSAGE);
},
'AMAZON.StopIntent': function () {
this.emit(':tell', this.t("STOP_MESSAGE"));
this.emit(':tell', STOP_MESSAGE);
}
};
Loading

0 comments on commit 07fbf9d

Please sign in to comment.