Last active
          August 7, 2019 20:53 
        
      - 
      
- 
        Save pkarthikr/c67f075abb5934f31fedd03526d7cf27 to your computer and use it in GitHub Desktop. 
Revisions
- 
        pkarthikr revised this gist Aug 6, 2019 . 1 changed file with 0 additions and 8 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,14 +9,6 @@ const data = [ 'Jupiter has the shortest day of all the planets.', 'The Sun is an almost perfect sphere.', ]; const GET_FACT_MESSAGE = "Here's your fact: "; const LaunchRequestHandler = { 
- 
        pkarthikr renamed this gist Aug 6, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewingFile renamed without changes.
- 
        pkarthikr revised this gist Jul 24, 2019 . 1 changed file with 13 additions and 5 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,12 +3,20 @@ // session persistence, api calls, and more. const Alexa = require('ask-sdk-core'); const data = [ 'A year on Mercury is just 88 days long.', 'Despite being farther from the Sun, Venus experiences higher temperatures than Mercury.', 'On Mars, the Sun appears about half the size as it does on Earth.', 'Jupiter has the shortest day of all the planets.', 'The Sun is an almost perfect sphere.', ]; /* 'बुध ग्रह में एक साल में केवल अठासी दिन होते हैं', 'सूरज से दूर होने के बावजूद, Venus का तापमान Mercury से ज़्यादा होता हैं', 'Earth के तुलना से Mars में सूरज का size तक़रीबन आधा हैं', 'सारे ग्रहों में Jupiter का दिन सबसे कम हैं', 'सूरज का shape एकदम गेंद आकार में हैं' */ const GET_FACT_MESSAGE = "Here's your fact: "; const LaunchRequestHandler = { 
- 
        pkarthikr revised this gist Jul 24, 2019 . 1 changed file with 1 addition and 9 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,15 +7,7 @@ const data = [ 'Despite being farther from the Sun, Venus experiences higher temperatures than Mercury.', 'Venus rotates counter-clockwise, possibly because of a collision in the past with an asteroid.', 'On Mars, the Sun appears about half the size as it does on Earth.', 'Earth is the only planet not named after a god.' ]; const GET_FACT_MESSAGE = "Here's your fact: "; 
- 
        pkarthikr renamed this gist Jul 24, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewingFile renamed without changes.
- 
        pkarthikr renamed this gist Jul 13, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewingFile renamed without changes.
- 
        pkarthikr created this gist Apr 27, 2019 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,154 @@ // This sample demonstrates handling intents from an Alexa skill using the Alexa Skills Kit SDK (v2). // Please visit https://alexa.design/cookbook for additional examples on implementing slots, dialog management, // session persistence, api calls, and more. const Alexa = require('ask-sdk-core'); const data = [ 'A year on Mercury is just 88 days long.', 'Despite being farther from the Sun, Venus experiences higher temperatures than Mercury.', 'Venus rotates counter-clockwise, possibly because of a collision in the past with an asteroid.', 'On Mars, the Sun appears about half the size as it does on Earth.', 'Earth is the only planet not named after a god.', 'Jupiter has the shortest day of all the planets.', 'The Milky Way galaxy will collide with the Andromeda Galaxy in about 5 billion years.', 'The Sun contains 99.86% of the mass in the Solar System.', 'The Sun is an almost perfect sphere.', 'A total solar eclipse can happen once every 1 to 2 years. This makes them a rare event.', 'Saturn radiates two and a half times more energy into space than it receives from the sun.', 'The temperature inside the Sun can reach 15 million degrees Celsius.', 'The Moon is moving approximately 3.8 cm away from our planet every year.', ]; const GET_FACT_MESSAGE = "Here's your fact: "; const LaunchRequestHandler = { canHandle(handlerInput) { return handlerInput.requestEnvelope.request.type === 'LaunchRequest'; }, handle(handlerInput) { const speechText = 'Welcome, you can say Hello or Help. Which would you like to try?'; return handlerInput.responseBuilder .speak(speechText) .reprompt(speechText) .getResponse(); } }; const HelloWorldIntentHandler = { canHandle(handlerInput) { return handlerInput.requestEnvelope.request.type === 'IntentRequest' && handlerInput.requestEnvelope.request.intent.name === 'HelloWorldIntent'; }, handle(handlerInput) { const speechText = 'Hello World!'; return handlerInput.responseBuilder .speak(speechText) //.reprompt('add a reprompt if you want to keep the session open for the user to respond') .getResponse(); } }; const GetNewFactIntentHandler = { canHandle(handlerInput) { return handlerInput.requestEnvelope.request.type === 'IntentRequest' && handlerInput.requestEnvelope.request.intent.name === 'GetNewFactIntent'; }, handle(handlerInput) { const factArr = data; const factIndex = Math.floor(Math.random() * factArr.length); const randomFact = factArr[factIndex]; const speechOutput = GET_FACT_MESSAGE + randomFact; const speechText = speechOutput; return handlerInput.responseBuilder .speak(speechText) //.reprompt('add a reprompt if you want to keep the session open for the user to respond') .getResponse(); } }; const HelpIntentHandler = { canHandle(handlerInput) { return handlerInput.requestEnvelope.request.type === 'IntentRequest' && handlerInput.requestEnvelope.request.intent.name === 'AMAZON.HelpIntent'; }, handle(handlerInput) { const speechText = 'You can say hello to me! How can I help?'; 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!'; return handlerInput.responseBuilder .speak(speechText) .getResponse(); } }; const SessionEndedRequestHandler = { canHandle(handlerInput) { return handlerInput.requestEnvelope.request.type === 'SessionEndedRequest'; }, handle(handlerInput) { // Any cleanup logic goes here. return handlerInput.responseBuilder.getResponse(); } }; // 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 handlerInput.requestEnvelope.request.type === 'IntentRequest'; }, handle(handlerInput) { const intentName = handlerInput.requestEnvelope.request.intent.name; const speechText = `You just triggered ${intentName}`; return handlerInput.responseBuilder .speak(speechText) //.reprompt('add a reprompt if you want to keep the session open for the user to respond') .getResponse(); } }; // 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(); } }; // 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, GetNewFactIntentHandler, HelpIntentHandler, CancelAndStopIntentHandler, SessionEndedRequestHandler, IntentReflectorHandler) // make sure IntentReflectorHandler is last so it doesn't override your custom intent handlers .addErrorHandlers( ErrorHandler) .lambda();