-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlambda code
131 lines (122 loc) · 6.56 KB
/
lambda code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
'use strict';
var Alexa = require('alexa-sdk');
var APP_ID = undefined; // TODO replace with your app ID (OPTIONAL).
var recipes = require('./recipescrossfit');
var shouldEndSession = true;
var goodbyeMessage = "OK, have a nice time getting to know crossfit";
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 = {
//Use LaunchRequest, instead of NewSession if you want to use the one-shot model
// Alexa, ask [my-skill-invocation-name] to (do something)...
'NewSession': function () {
this.attributes['speechOutput'] = this.t("WELCOME_MESSAGE", this.t("SKILL_NAME"));
// If the user either does not reply to the welcome message or says something that is not
// understood, they will be prompted again with this text.
this.attributes['repromptSpeech'] = this.t("WELCOME_REPROMT");
this.emit(':ask', this.attributes['speechOutput'], this.attributes['repromptSpeech'])
},
'RecipeIntent': function () {
var itemSlot = this.event.request.intent.slots.Item;
var itemName;
if (itemSlot && itemSlot.value) {
itemName = itemSlot.value.toLowerCase();
}
var cardTitle = this.t("DISPLAY_CARD_TITLE", this.t("SKILL_NAME"), itemName);
var recipes = this.t("RECIPES");
var recipe = recipes[itemName];
if (recipe) {
this.attributes['speechOutput'] = recipe;
this.attributes['repromptSpeech'] = this.t("RECIPE_REPEAT_MESSAGE");
this.emit(':askWithCard', recipe, this.attributes['repromptSpeech'], cardTitle, recipe);
} else {
var speechOutput = this.t("RECIPE_NOT_FOUND_MESSAGE");
var repromptSpeech = this.t("RECIPE_NOT_FOUND_REPROMPT");
if (itemName) {
speechOutput += this.t("RECIPE_NOT_FOUND_WITH_ITEM_NAME", itemName);
} else {
speechOutput += this.t("RECIPE_NOT_FOUND_WITHOUT_ITEM_NAME");
}
speechOutput += repromptSpeech;
this.attributes['speechOutput'] = speechOutput;
this.attributes['repromptSpeech'] = repromptSpeech;
this.emit(':ask', speechOutput, repromptSpeech);
}
},
'AMAZON.HelpIntent': function () {
this.attributes['speechOutput'] = this.t("HELP_MESSAGE");
this.attributes['repromptSpeech'] = this.t("HELP_REPROMT");
this.emit(':ask', this.attributes['speechOutput'], this.attributes['repromptSpeech'])
},
'AMAZON.RepeatIntent': function () {
this.emit(':ask', this.attributes['speechOutput'], this.attributes['repromptSpeech'])
},
'AMAZON.StopIntent': function () {
this.emit(':tell', goodbyeMessage);
},
'AMAZON.CancelIntent': function () {
this.emit('SessionEndedRequest');
},
'SessionEndedRequest':function () {
this.emit('AMAZON.StopIntent');
}
};
var languageStrings = {
"en-GB": {
"translation": {
"RECIPES": recipes.RECIPE_EN_GB,
"SKILL_NAME": "British Minecraft Helper",
"WELCOME_MESSAGE": "Welcome to %s. You can ask a question like, what\'s the recipe for a chest? ... Now, what can I help you with.",
"WELCOME_REPROMT": "For instructions on what you can say, please say help me.",
"DISPLAY_CARD_TITLE": "%s - Recipe for %s.",
"HELP_MESSAGE": "You can ask questions such as, what\'s the recipe, or, you can say exit...Now, what can I help you with?",
"HELP_REPROMT": "You can say things like, what\'s the recipe, or you can say exit...Now, what can I help you with?",
"STOP_MESSAGE": "Goodbye!",
"RECIPE_REPEAT_MESSAGE": "Try saying repeat.",
"RECIPE_NOT_FOUND_MESSAGE": "I\'m excited, I currently do not know ",
"RECIPE_NOT_FOUND_WITH_ITEM_NAME": "the recipe for %s. ",
"RECIPE_NOT_FOUND_WITHOUT_ITEM_NAME": "that recipe. ",
"RECIPE_NOT_FOUND_REPROMPT": "What else can I help with?"
}
},
"en-US": {
"translation": {
"RECIPES" : recipes.RECIPE_EN_US,
"SKILL_NAME" : "Crossfit Me ",
"WELCOME_MESSAGE": "Welcome to %s. You can ask a question like, what is crossfit? , where can I choose crossfit box, tell me one fun fact about crossfit ... Now, what can I help you with.",
"WELCOME_REPROMT": "For instructions on what you can say, please say help me.",
"DISPLAY_CARD_TITLE": "%s - Recipe for %s.",
"HELP_MESSAGE": "You can ask questions such as, what\'s the recipe, or, you can say exit...Now, what can I help you with?",
"HELP_REPROMT": "You can say things like, what\'s the recipe, or you can say exit...Now, what can I help you with?",
"STOP_MESSAGE": "Goodbye!",
"RECIPE_REPEAT_MESSAGE": "Try saying repeat.",
"RECIPE_NOT_FOUND_MESSAGE": "I\'m sorry, I currently do not know ",
"RECIPE_NOT_FOUND_WITH_ITEM_NAME": "the recipe for %s. ",
"RECIPE_NOT_FOUND_WITHOUT_ITEM_NAME": "that recipe. ",
"RECIPE_NOT_FOUND_REPROMPT": "What else can I help with?"
}
},
"de-DE": {
"translation": {
"RECIPES" : recipes.RECIPE_DE_DE,
"SKILL_NAME" : "Assistent für Minecraft in Deutsch",
"WELCOME_MESSAGE": "Willkommen bei %s. Du kannst beispielsweise die Frage stellen: Welche Rezepte gibt es für eine Truhe? ... Nun, womit kann ich dir helfen?",
"WELCOME_REPROMT": "Wenn du wissen möchtest, was du sagen kannst, sag einfach „Hilf mir“.",
"DISPLAY_CARD_TITLE": "%s - Rezept für %s.",
"HELP_MESSAGE": "Du kannst beispielsweise Fragen stellen wie „Wie geht das Rezept für“ oder du kannst „Beenden“ sagen ... Wie kann ich dir helfen?",
"HELP_REPROMT": "Du kannst beispielsweise Sachen sagen wie „Wie geht das Rezept für“ oder du kannst „Beenden“ sagen ... Wie kann ich dir helfen?",
"STOP_MESSAGE": "Auf Wiedersehen!",
"RECIPE_REPEAT_MESSAGE": "Sage einfach „Wiederholen“.",
"RECIPE_NOT_FOUND_MESSAGE": "Tut mir leid, ich kenne derzeit ",
"RECIPE_NOT_FOUND_WITH_ITEM_NAME": "das Rezept für %s nicht. ",
"RECIPE_NOT_FOUND_WITHOUT_ITEM_NAME": "dieses Rezept nicht. ",
"RECIPE_NOT_FOUND_REPROMPT": "Womit kann ich dir sonst helfen?"
}
}
};