-
Notifications
You must be signed in to change notification settings - Fork 1
/
handler.js
57 lines (48 loc) · 1.33 KB
/
handler.js
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
const Alexa = require('ask-sdk-core');
// const i18n = require('i18next');
const { BEM_VINDO, FATOS, ERRO } = require('./falas');
const L = console.log;
const LaunchRequestHandler = {
canHandle(handlerInput) {
return handlerInput.requestEnvelope.request.type === 'LaunchRequest';
},
handle(handlerInput) {
console.log(BEM_VINDO);
return handlerInput.responseBuilder
.speak(BEM_VINDO)
.reprompt(BEM_VINDO)
.withSimpleCard('Titulo', BEM_VINDO)
.getResponse();
}
}
const FatosSobreAguaIntentHandler = {
canHandle(handlerInput) {
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
&& handlerInput.requestEnvelope.request.intent.name === 'FatosSobreAgua';
},
handle(handlerInput) {
return handlerInput.responseBuilder
.speak(FATOS)
.withSimpleCard('FATOS', FATOS)
.getResponse();
}
};
const ErrorHandler = {
canHandle() {
return true;
},
handle(handlerInput, error) {
console.log(`Error handled: ${error.message}`);
return handlerInput.responseBuilder
.speak(ERRO)
.reprompt(ERRO)
.getResponse();
},
};
// const Internacionalizacao = () =>
module.exports.hello = Alexa.SkillBuilders.custom()
.addRequestHandlers(
LaunchRequestHandler,
FatosSobreAguaIntentHandler)
.addErrorHandlers(ErrorHandler)
.lambda();