mirror of
https://github.com/r-ca/kidshift-skills.git
synced 2024-10-25 17:14:03 +00:00
replace
This commit is contained in:
parent
78eae6601b
commit
2d2ab38a07
57
src/index.ts
57
src/index.ts
|
@ -1,8 +1,6 @@
|
|||
import * as Alexa from 'ask-sdk-core';
|
||||
import { RequestHandler, ErrorHandler, SkillBuilders } from 'ask-sdk-core';
|
||||
import { Response } from 'ask-sdk-model';
|
||||
const Alexa = require('ask-sdk-core');
|
||||
|
||||
const LaunchRequestHandler: RequestHandler = {
|
||||
const LaunchRequestHandler = {
|
||||
canHandle(handlerInput) {
|
||||
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'LaunchRequest';
|
||||
},
|
||||
|
@ -16,7 +14,7 @@ const LaunchRequestHandler: RequestHandler = {
|
|||
}
|
||||
};
|
||||
|
||||
const HelloWorldIntentHandler: RequestHandler = {
|
||||
const HelloWorldIntentHandler = {
|
||||
canHandle(handlerInput) {
|
||||
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
|
||||
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'HelloWorldIntent';
|
||||
|
@ -31,7 +29,7 @@ const HelloWorldIntentHandler: RequestHandler = {
|
|||
}
|
||||
};
|
||||
|
||||
const HelpIntentHandler: RequestHandler = {
|
||||
const HelpIntentHandler = {
|
||||
canHandle(handlerInput) {
|
||||
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
|
||||
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.HelpIntent';
|
||||
|
@ -46,7 +44,7 @@ const HelpIntentHandler: RequestHandler = {
|
|||
}
|
||||
};
|
||||
|
||||
const CancelAndStopIntentHandler: RequestHandler = {
|
||||
const CancelAndStopIntentHandler = {
|
||||
canHandle(handlerInput) {
|
||||
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
|
||||
&& (Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.CancelIntent'
|
||||
|
@ -60,8 +58,12 @@ const CancelAndStopIntentHandler: RequestHandler = {
|
|||
.getResponse();
|
||||
}
|
||||
};
|
||||
|
||||
const FallbackIntentHandler: RequestHandler = {
|
||||
/* *
|
||||
* FallbackIntent triggers when a customer says something that doesn’t map to any intents in your skill
|
||||
* It must also be defined in the language model (if the locale supports it)
|
||||
* This handler can be safely added but will be ingnored in locales that do not support it yet
|
||||
* */
|
||||
const FallbackIntentHandler = {
|
||||
canHandle(handlerInput) {
|
||||
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
|
||||
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.FallbackIntent';
|
||||
|
@ -75,8 +77,12 @@ const FallbackIntentHandler: RequestHandler = {
|
|||
.getResponse();
|
||||
}
|
||||
};
|
||||
|
||||
const SessionEndedRequestHandler: RequestHandler = {
|
||||
/* *
|
||||
* SessionEndedRequest notifies that a session was ended. This handler will be triggered when a currently open
|
||||
* session is closed for one of the following reasons: 1) The user says "exit" or "quit". 2) The user does not
|
||||
* respond or says something that does not match an intent defined in your voice model. 3) An error occurs
|
||||
* */
|
||||
const SessionEndedRequestHandler = {
|
||||
canHandle(handlerInput) {
|
||||
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'SessionEndedRequest';
|
||||
},
|
||||
|
@ -86,8 +92,12 @@ const SessionEndedRequestHandler: RequestHandler = {
|
|||
return handlerInput.responseBuilder.getResponse(); // notice we send an empty response
|
||||
}
|
||||
};
|
||||
|
||||
const IntentReflectorHandler: RequestHandler = {
|
||||
/* *
|
||||
* The intent reflector is used for interaction model testing and debugging.
|
||||
* It will simply repeat the intent the user said. You can create custom handlers for your intents
|
||||
* by defining them above, then also adding them to the request handler chain below
|
||||
* */
|
||||
const IntentReflectorHandler = {
|
||||
canHandle(handlerInput) {
|
||||
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest';
|
||||
},
|
||||
|
@ -101,8 +111,12 @@ const IntentReflectorHandler: RequestHandler = {
|
|||
.getResponse();
|
||||
}
|
||||
};
|
||||
|
||||
const ErrorHandler: ErrorHandler = {
|
||||
/**
|
||||
* 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;
|
||||
},
|
||||
|
@ -117,7 +131,12 @@ const ErrorHandler: ErrorHandler = {
|
|||
}
|
||||
};
|
||||
|
||||
export const handler = SkillBuilders.custom()
|
||||
/**
|
||||
* 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,
|
||||
HelloWorldIntentHandler,
|
||||
|
@ -125,8 +144,8 @@ export const handler = SkillBuilders.custom()
|
|||
CancelAndStopIntentHandler,
|
||||
FallbackIntentHandler,
|
||||
SessionEndedRequestHandler,
|
||||
IntentReflectorHandler
|
||||
)
|
||||
.addErrorHandlers(ErrorHandler)
|
||||
IntentReflectorHandler)
|
||||
.addErrorHandlers(
|
||||
ErrorHandler)
|
||||
.withCustomUserAgent('sample/hello-world/v1.2')
|
||||
.lambda();
|
||||
|
|
Loading…
Reference in New Issue
Block a user