-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from StudentCode-in/main
Merge upstream
- Loading branch information
Showing
94 changed files
with
67,774 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: Greetings | ||
|
||
on: [pull_request, issues] | ||
|
||
jobs: | ||
greeting: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/first-interaction@v1 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
issue-message: 'Message that will be displayed on users'' first issue' | ||
pr-message: 'Message that will be displayed on users'' first pr' |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## Simple Draw Number Alexa's skill: | ||
This skill draws up to 6 numbers within a minimum range of 10 numbers. | ||
A simple skill, good for learning the basics of skill development for Alexa. | ||
|
||
### Using the skill: | ||
To trigger the skill you must say "Alexa, open Draw Number" and then say "draw a number from 1 to 10" or "draw 5 numbers from 10 to 50". |
147 changes: 147 additions & 0 deletions
147
Alexa Skills/Draw Number/interactionModels/custom/en-US.json
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
{ | ||
"interactionModel": { | ||
"languageModel": { | ||
"invocationName": "draw numbers", | ||
"intents": [ | ||
{ | ||
"name": "AMAZON.CancelIntent", | ||
"samples": [] | ||
}, | ||
{ | ||
"name": "AMAZON.HelpIntent", | ||
"samples": [] | ||
}, | ||
{ | ||
"name": "AMAZON.StopIntent", | ||
"samples": [] | ||
}, | ||
{ | ||
"name": "DrawANumberIntent", | ||
"slots": [ | ||
{ | ||
"name": "quantity", | ||
"type": "AMAZON.NUMBER" | ||
}, | ||
{ | ||
"name": "start", | ||
"type": "AMAZON.NUMBER" | ||
}, | ||
{ | ||
"name": "end", | ||
"type": "AMAZON.NUMBER" | ||
} | ||
], | ||
"samples": [ | ||
"draw a number from {start} to {end}", | ||
"draw {quantity} numbers from {start} to {end}" | ||
] | ||
}, | ||
{ | ||
"name": "AMAZON.NavigateHomeIntent", | ||
"samples": [] | ||
}, | ||
{ | ||
"name": "AMAZON.FallbackIntent", | ||
"samples": [] | ||
} | ||
], | ||
"types": [], | ||
"modelConfiguration": { | ||
"fallbackIntentSensitivity": { | ||
"level": "LOW" | ||
} | ||
} | ||
}, | ||
"dialog": { | ||
"intents": [ | ||
{ | ||
"name": "DrawANumberIntent", | ||
"confirmationRequired": false, | ||
"prompts": {}, | ||
"slots": [ | ||
{ | ||
"name": "quantity", | ||
"type": "AMAZON.NUMBER", | ||
"elicitationRequired": false, | ||
"confirmationRequired": false, | ||
"prompts": {}, | ||
"validations": [ | ||
{ | ||
"type": "isGreaterThan", | ||
"prompt": "Slot.Validation.369584108735.323387405418.830329908207", | ||
"value": "0" | ||
}, | ||
{ | ||
"type": "isLessThanOrEqualTo", | ||
"prompt": "Slot.Validation.1507590893522.866414625147.637929507255", | ||
"value": "6" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "start", | ||
"type": "AMAZON.NUMBER", | ||
"elicitationRequired": false, | ||
"confirmationRequired": false, | ||
"prompts": {}, | ||
"validations": [ | ||
{ | ||
"type": "isGreaterThan", | ||
"prompt": "Slot.Validation.369584108735.654545011642.1058104282907", | ||
"value": "0" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "end", | ||
"type": "AMAZON.NUMBER", | ||
"elicitationRequired": false, | ||
"confirmationRequired": false, | ||
"prompts": {} | ||
} | ||
] | ||
} | ||
], | ||
"delegationStrategy": "ALWAYS" | ||
}, | ||
"prompts": [ | ||
{ | ||
"id": "Elicit.Slot.369584108735.323387405418", | ||
"variations": [ | ||
{ | ||
"type": "PlainText", | ||
"value": "How many numbers may I have to draw?" | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "Slot.Validation.369584108735.323387405418.830329908207", | ||
"variations": [ | ||
{ | ||
"type": "PlainText", | ||
"value": "the number of numbers to be drawn must be greater than zero. How many numbers should I draw" | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "Slot.Validation.369584108735.654545011642.1058104282907", | ||
"variations": [ | ||
{ | ||
"type": "PlainText", | ||
"value": "choose a number greater than zero to be the starting number" | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "Slot.Validation.1507590893522.866414625147.637929507255", | ||
"variations": [ | ||
{ | ||
"type": "PlainText", | ||
"value": "I can only draw until six numbers. How many numbers should I draw" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"version": "7" | ||
} |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
/* * | ||
* 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 logic = require('./logic'); // this file encapsulates all "business" logic | ||
|
||
const LaunchRequestHandler = { | ||
canHandle(handlerInput) { | ||
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'LaunchRequest'; | ||
}, | ||
handle(handlerInput) { | ||
const speakOutput = 'Welcome, I can draw numbers for you. Say how many numbers do I have to draw, starting and ending by which numbers?'; | ||
|
||
return handlerInput.responseBuilder | ||
.speak(speakOutput) | ||
.reprompt(speakOutput) | ||
.getResponse(); | ||
} | ||
}; | ||
|
||
const DrawANumberIntentHandler = { | ||
canHandle(handlerInput) { | ||
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest' | ||
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'DrawANumberIntent'; | ||
}, | ||
handle(handlerInput) { | ||
const {attributesManager, requestEnvelope} = handlerInput; | ||
const qty = Alexa.getSlot(requestEnvelope, 'quantity').value || 0 | ||
const start = Alexa.getSlot(requestEnvelope, 'start').value | ||
const end = Alexa.getSlot(requestEnvelope, 'end').value | ||
|
||
if(qty === 0) { | ||
const speechText = 'How many numbers do you want me to draw?' | ||
return handlerInput.responseBuilder | ||
.speak(speechText) | ||
.reprompt(speechText) | ||
.addElicitSlotDirective('quantity') | ||
.getResponse(); | ||
}else if(9 > (end - start + 1)){ | ||
const speechText = `the range of numbers to be drawn must be at least 10. Say a final number greater than ${end}` | ||
return handlerInput.responseBuilder | ||
.speak(speechText) | ||
.reprompt(speechText) | ||
.addElicitSlotDirective('end') | ||
.getResponse(); | ||
}else{ | ||
console.log(`${qty}, ${start}, ${end}`) | ||
const result = logic.generateRandomNumbers(qty, start, end) | ||
const speechText = `the numbers drawn were: ${result}` | ||
|
||
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 Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest' | ||
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.HelpIntent'; | ||
}, | ||
handle(handlerInput) { | ||
const speakOutput = 'You can say hello to me! How can I help?'; | ||
|
||
return handlerInput.responseBuilder | ||
.speak(speakOutput) | ||
.reprompt(speakOutput) | ||
.getResponse(); | ||
} | ||
}; | ||
|
||
const CancelAndStopIntentHandler = { | ||
canHandle(handlerInput) { | ||
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest' | ||
&& (Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.CancelIntent' | ||
|| Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.StopIntent'); | ||
}, | ||
handle(handlerInput) { | ||
const speakOutput = 'Goodbye!'; | ||
|
||
return handlerInput.responseBuilder | ||
.speak(speakOutput) | ||
.getResponse(); | ||
} | ||
}; | ||
/* * | ||
* 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'; | ||
}, | ||
handle(handlerInput) { | ||
const speakOutput = 'Sorry, I don\'t know about that. Please try again.'; | ||
|
||
return handlerInput.responseBuilder | ||
.speak(speakOutput) | ||
.reprompt(speakOutput) | ||
.getResponse(); | ||
} | ||
}; | ||
/* * | ||
* 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'; | ||
}, | ||
handle(handlerInput) { | ||
console.log(`~~~~ Session ended: ${JSON.stringify(handlerInput.requestEnvelope)}`); | ||
// Any cleanup logic goes here. | ||
return handlerInput.responseBuilder.getResponse(); // notice we send an empty response | ||
} | ||
}; | ||
/* * | ||
* 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'; | ||
}, | ||
handle(handlerInput) { | ||
const intentName = Alexa.getIntentName(handlerInput.requestEnvelope); | ||
const speakOutput = `You just triggered ${intentName}`; | ||
|
||
return handlerInput.responseBuilder | ||
.speak(speakOutput) | ||
//.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) { | ||
const speakOutput = 'Sorry, I had trouble doing what you asked. Please try again.'; | ||
console.log(`~~~~ Error handled: ${JSON.stringify(error)}`); | ||
|
||
return handlerInput.responseBuilder | ||
.speak(speakOutput) | ||
.reprompt(speakOutput) | ||
.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, | ||
DrawANumberIntentHandler, | ||
HelpIntentHandler, | ||
CancelAndStopIntentHandler, | ||
FallbackIntentHandler, | ||
SessionEndedRequestHandler, | ||
IntentReflectorHandler) | ||
.addErrorHandlers( | ||
ErrorHandler) | ||
.withCustomUserAgent('sample/hello-world/v1.2') | ||
.lambda(); |
Oops, something went wrong.