2024-07-15 21:05:08 +00:00
|
|
|
"use strict";
|
|
|
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
|
|
if (k2 === undefined) k2 = k;
|
|
|
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
|
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
|
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
|
|
}
|
|
|
|
Object.defineProperty(o, k2, desc);
|
|
|
|
}) : (function(o, m, k, k2) {
|
|
|
|
if (k2 === undefined) k2 = k;
|
|
|
|
o[k2] = m[k];
|
|
|
|
}));
|
|
|
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
|
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
|
|
}) : function(o, v) {
|
|
|
|
o["default"] = v;
|
|
|
|
});
|
|
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
|
if (mod && mod.__esModule) return mod;
|
|
|
|
var result = {};
|
|
|
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
|
|
__setModuleDefault(result, mod);
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
const Alexa = __importStar(require("ask-sdk-core"));
|
2024-07-16 00:55:50 +00:00
|
|
|
const AWS = __importStar(require("aws-sdk"));
|
|
|
|
const DynamoDBPersistantAttributesAdapter = __importStar(require("ask-sdk-dynamodb-persistence-adapter"));
|
2024-07-15 18:48:13 +00:00
|
|
|
const LaunchRequestHandler = {
|
|
|
|
canHandle(handlerInput) {
|
2024-07-15 20:41:47 +00:00
|
|
|
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'LaunchRequest';
|
2024-07-15 18:48:13 +00:00
|
|
|
},
|
|
|
|
handle(handlerInput) {
|
2024-07-15 20:49:04 +00:00
|
|
|
const speakOutput = 'Welcome, you can say Hello or Help. Which would you like to try?';
|
2024-07-15 18:48:13 +00:00
|
|
|
return handlerInput.responseBuilder
|
|
|
|
.speak(speakOutput)
|
|
|
|
.reprompt(speakOutput)
|
|
|
|
.getResponse();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const HelloWorldIntentHandler = {
|
|
|
|
canHandle(handlerInput) {
|
2024-07-15 20:41:47 +00:00
|
|
|
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
|
2024-07-16 04:48:04 +00:00
|
|
|
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'HelloWorldIntent';
|
2024-07-15 18:48:13 +00:00
|
|
|
},
|
2024-07-16 00:47:51 +00:00
|
|
|
async handle(handlerInput) {
|
2024-07-16 04:48:04 +00:00
|
|
|
const speakOutput = 'Hello World!';
|
2024-07-16 00:44:20 +00:00
|
|
|
return handlerInput.responseBuilder
|
2024-07-16 00:55:50 +00:00
|
|
|
.speak(speakOutput)
|
2024-07-16 00:44:20 +00:00
|
|
|
.getResponse();
|
|
|
|
}
|
|
|
|
};
|
2024-07-16 01:29:54 +00:00
|
|
|
const KidShiftAuthIntentHandler = {
|
|
|
|
canHandle(handlerInput) {
|
2024-07-16 03:48:24 +00:00
|
|
|
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
|
|
|
|
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'KidShiftAuthIntent';
|
2024-07-16 01:29:54 +00:00
|
|
|
},
|
|
|
|
handle(handlerInput) {
|
2024-07-16 05:43:30 +00:00
|
|
|
// if (Alexa.getSlot(handlerInput.requestEnvelope, 'loginCode').value === undefined) {
|
|
|
|
// return handlerInput.responseBuilder
|
|
|
|
// .speak('Please provide a valid login code')
|
|
|
|
// .reprompt('Please provide a valid login code')
|
|
|
|
// .getResponse();
|
|
|
|
// }
|
|
|
|
// return handlerInput.responseBuilder
|
|
|
|
// .speak('your auth code is ' + Alexa.getSlotValue(handlerInput.requestEnvelope, 'loginCode'))
|
|
|
|
// .getResponse();
|
2024-07-16 04:48:04 +00:00
|
|
|
return handlerInput.responseBuilder
|
2024-07-16 05:43:30 +00:00
|
|
|
.speak('hoge')
|
2024-07-16 04:48:04 +00:00
|
|
|
.getResponse();
|
2024-07-16 01:29:54 +00:00
|
|
|
}
|
|
|
|
};
|
2024-07-15 18:48:13 +00:00
|
|
|
const HelpIntentHandler = {
|
|
|
|
canHandle(handlerInput) {
|
2024-07-15 20:41:47 +00:00
|
|
|
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
|
|
|
|
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.HelpIntent';
|
2024-07-15 18:48:13 +00:00
|
|
|
},
|
|
|
|
handle(handlerInput) {
|
2024-07-15 20:49:04 +00:00
|
|
|
const speakOutput = 'You can say hello to me! How can I help?';
|
2024-07-15 18:48:13 +00:00
|
|
|
return handlerInput.responseBuilder
|
|
|
|
.speak(speakOutput)
|
|
|
|
.reprompt(speakOutput)
|
|
|
|
.getResponse();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const CancelAndStopIntentHandler = {
|
|
|
|
canHandle(handlerInput) {
|
2024-07-15 20:41:47 +00:00
|
|
|
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
|
|
|
|
&& (Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.CancelIntent'
|
|
|
|
|| Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.StopIntent');
|
2024-07-15 18:48:13 +00:00
|
|
|
},
|
|
|
|
handle(handlerInput) {
|
2024-07-15 20:49:04 +00:00
|
|
|
const speakOutput = 'Goodbye!';
|
2024-07-15 18:48:13 +00:00
|
|
|
return handlerInput.responseBuilder
|
|
|
|
.speak(speakOutput)
|
|
|
|
.getResponse();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const FallbackIntentHandler = {
|
|
|
|
canHandle(handlerInput) {
|
2024-07-15 20:41:47 +00:00
|
|
|
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
|
|
|
|
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.FallbackIntent';
|
2024-07-15 18:48:13 +00:00
|
|
|
},
|
|
|
|
handle(handlerInput) {
|
2024-07-15 20:49:04 +00:00
|
|
|
const speakOutput = 'Sorry, I don\'t know about that. Please try again.';
|
2024-07-15 18:48:13 +00:00
|
|
|
return handlerInput.responseBuilder
|
|
|
|
.speak(speakOutput)
|
|
|
|
.reprompt(speakOutput)
|
|
|
|
.getResponse();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const SessionEndedRequestHandler = {
|
|
|
|
canHandle(handlerInput) {
|
2024-07-15 20:41:47 +00:00
|
|
|
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'SessionEndedRequest';
|
2024-07-15 18:48:13 +00:00
|
|
|
},
|
|
|
|
handle(handlerInput) {
|
|
|
|
console.log(`~~~~ Session ended: ${JSON.stringify(handlerInput.requestEnvelope)}`);
|
2024-07-15 21:05:08 +00:00
|
|
|
return handlerInput.responseBuilder.getResponse();
|
2024-07-15 18:48:13 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
const IntentReflectorHandler = {
|
|
|
|
canHandle(handlerInput) {
|
2024-07-15 20:41:47 +00:00
|
|
|
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest';
|
2024-07-15 18:48:13 +00:00
|
|
|
},
|
|
|
|
handle(handlerInput) {
|
2024-07-15 20:41:47 +00:00
|
|
|
const intentName = Alexa.getIntentName(handlerInput.requestEnvelope);
|
2024-07-15 20:49:04 +00:00
|
|
|
const speakOutput = `You just triggered ${intentName}`;
|
2024-07-15 18:48:13 +00:00
|
|
|
return handlerInput.responseBuilder
|
|
|
|
.speak(speakOutput)
|
|
|
|
.getResponse();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const ErrorHandler = {
|
|
|
|
canHandle() {
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
handle(handlerInput, error) {
|
2024-07-15 20:49:04 +00:00
|
|
|
const speakOutput = 'Sorry, I had trouble doing what you asked. Please try again.';
|
|
|
|
console.log(`~~~~ Error handled: ${JSON.stringify(error)}`);
|
2024-07-15 18:48:13 +00:00
|
|
|
return handlerInput.responseBuilder
|
|
|
|
.speak(speakOutput)
|
|
|
|
.reprompt(speakOutput)
|
|
|
|
.getResponse();
|
|
|
|
}
|
|
|
|
};
|
2024-07-15 20:41:47 +00:00
|
|
|
exports.handler = Alexa.SkillBuilders.custom()
|
2024-07-16 01:29:54 +00:00
|
|
|
.addRequestHandlers(LaunchRequestHandler, HelloWorldIntentHandler, HelpIntentHandler, CancelAndStopIntentHandler, FallbackIntentHandler, SessionEndedRequestHandler, IntentReflectorHandler, KidShiftAuthIntentHandler)
|
2024-07-15 21:05:08 +00:00
|
|
|
.addErrorHandlers(ErrorHandler)
|
2024-07-16 00:55:50 +00:00
|
|
|
.withPersistenceAdapter(new DynamoDBPersistantAttributesAdapter.DynamoDbPersistenceAdapter({
|
|
|
|
tableName: process.env.DYNAMODB_PERSISTENCE_TABLE_NAME || 'ask-sdk-table',
|
|
|
|
createTable: false,
|
|
|
|
dynamoDBClient: new AWS.DynamoDB({ apiVersion: 'latest', region: process.env.DYNAMODB_PERSISTENCE_REGION })
|
|
|
|
}))
|
2024-07-15 20:20:25 +00:00
|
|
|
.withCustomUserAgent('sample/hello-world/v1.2')
|
2024-07-15 21:05:08 +00:00
|
|
|
.lambda();
|
|
|
|
//# sourceMappingURL=index.js.map
|