-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
56 lines (50 loc) · 1.94 KB
/
index.js
File metadata and controls
56 lines (50 loc) · 1.94 KB
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
'use strict';
const Alexa = require('ask-sdk-core');
const LaunchRequestHandler = require('./handlers/launch-handler.js');
const ChallengeIntentHandler = require('./handlers/challenge-handler.js');
const HintIntentHandler = require('./handlers/hint-handler.js');
const SolutionIntentHandler = require('./handlers/solution-handler.js');
// Generic error handling to capture any syntax or routing errors. If you receive an error
// stating the request handler chain is not found, you have not implemented a handler for
// the intent being invoked or included it in the skill builder below.
const ErrorHandler = {
canHandle() {
return true;
},
handle(handlerInput, error) {
console.log(`~~~~ Error handled: ${error.message}`);
const speechText = `Sorry, I couldn't understand what you said. Please try again.`;
return handlerInput.responseBuilder
.speak(speechText)
.reprompt(speechText)
.getResponse();
},
};
const CancelAndStopIntentHandler = {
canHandle(handlerInput) {
return (
handlerInput.requestEnvelope.request.type === 'IntentRequest' &&
(handlerInput.requestEnvelope.request.intent.name ===
'AMAZON.CancelIntent' ||
handlerInput.requestEnvelope.request.intent.name ===
'AMAZON.StopIntent')
);
},
handle(handlerInput) {
const speechText = 'Goodbye! Best of luck on your interview!';
return handlerInput.responseBuilder.speak(speechText).getResponse();
},
};
// This handler acts as the entry point for your skill, routing all request and response
// payloads to the handlers above. Make sure any new handlers or interceptors you've
// defined are included below. The order matters - they're processed top to bottom.
exports.handler = Alexa.SkillBuilders.custom()
.addRequestHandlers(
LaunchRequestHandler,
ChallengeIntentHandler,
HintIntentHandler,
SolutionIntentHandler,
CancelAndStopIntentHandler,
)
.addErrorHandlers(ErrorHandler)
.lambda();