Skip to content

Commit 81a4e9f

Browse files
committed
initial commit
0 parents  commit 81a4e9f

File tree

8 files changed

+201
-0
lines changed

8 files changed

+201
-0
lines changed

.ask/config

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"deploy_settings": {
3+
"default": {
4+
"skill_id": "amzn1.ask.skill.98eff9ef-5cdf-4daf-9271-b9acdfd6d358",
5+
"was_cloned": true,
6+
"merge": {
7+
"skillManifest": {
8+
"apis": {
9+
"custom": {
10+
"endpoint": {
11+
"uri": "skilltemplates-api-starter-alexa"
12+
}
13+
}
14+
}
15+
}
16+
}
17+
}
18+
}
19+
}

assets/rocket-man-lcon-lg.png

31.5 KB
Loading

assets/rocket-man-logo-sm.png

4.05 KB
Loading

lambda/custom/index.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
var Alexa = require('alexa-sdk');
2+
var http = require('http');
3+
4+
exports.handler = function(event, context, callback){
5+
var alexa = Alexa.handler(event, context);
6+
alexa.registerHandlers(handlers);
7+
alexa.execute();
8+
};
9+
10+
var handlers = {
11+
'LaunchRequest': function () {
12+
this.emit('GetAstros');
13+
},
14+
'GetAstros': function() {
15+
16+
getAstrosHttp((data) => {
17+
18+
var outputSpeech = `There are currently ${data.people.length} astronauts in space. `;
19+
for (var i=0;i<data.people.length;i++){
20+
if (i === 0) {
21+
//first record
22+
outputSpeech = outputSpeech + 'Their names are: ' + data.people[i].name + ', '
23+
} else if (i === data.people.length-1) {
24+
//last record
25+
outputSpeech = outputSpeech + 'and ' + data.people[i].name + '.'
26+
} else {
27+
//middle record(s)
28+
outputSpeech = outputSpeech + data.people[i].name + ', '
29+
}
30+
}
31+
32+
this.emit(':tell', outputSpeech);
33+
}
34+
);
35+
},
36+
'AMAZON.HelpIntent': function () {
37+
this.emit(':ask', "What can I help you with?", "How can I help?");
38+
},
39+
'AMAZON.CancelIntent': function () {
40+
this.emit(':tell', "Okay!");
41+
},
42+
'AMAZON.StopIntent': function () {
43+
this.emit(':tell', "Goodbye!");
44+
}
45+
};
46+
47+
48+
function getAstrosHttp(callback) {
49+
//http://api.open-notify.org/astros.json
50+
var options = {
51+
host: 'api.open-notify.org',
52+
port: 80,
53+
path: '/astros.json',
54+
method: 'GET'
55+
};
56+
57+
var req = http.request(options, res => {
58+
res.setEncoding('utf8');
59+
var returnData = "";
60+
61+
res.on('data', chunk => {
62+
returnData = returnData + chunk;
63+
});
64+
65+
res.on('end', () => {
66+
var result = JSON.parse(returnData);
67+
68+
callback(result);
69+
70+
});
71+
72+
});
73+
req.end();
74+
}

lambda/custom/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "rocket-man-alexa-skill",
3+
"version": "1.0.0",
4+
"private": true,
5+
"dependencies": {
6+
"alexa-sdk": "^1.0.10"
7+
}
8+
}

models/en-US.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"interactionModel": {
3+
"languageModel": {
4+
"invocationName": "api starter",
5+
"intents": [
6+
{
7+
"name": "GetAstros",
8+
"samples": [
9+
"how many people are in space",
10+
"how many people are in space now",
11+
"how many people are currently in space",
12+
"how many humans are in space",
13+
"how many humans are in space now",
14+
"how many humans are currently in space",
15+
"how many astronauts are in space",
16+
"how many astronauts are in space now",
17+
"how many astronauts are currently in space"
18+
]
19+
},
20+
{
21+
"name": "AMAZON.StopIntent"
22+
},
23+
{
24+
"name": "AMAZON.CancelIntent"
25+
},
26+
{
27+
"name": "AMAZON.HelpIntent"
28+
}
29+
]
30+
}
31+
}
32+
}

readme.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# API Starter - Alexa Skill Template
2+
3+
This is an Alexa skill template that provides a simple example of a skill that shows how to call an external API. The API that is used is the [api.open-notify.org API](http://api.open-notify.org/astros.json) which returns a JSON response containing a list of the astronauts currently in space.
4+
5+
### Try it out
6+
To try an example of this skill template, you can enable the [Ground Control Alexa skill](https://www.amazon.com/Dabble-Lab-Ground-Control/dp/B075CWGY1P/ref=sr_1_sc_1?ie=UTF8&qid=1514557483&sr=8-1-spell&keywords=grond+control+alexa+skill). Just say: `Alexa, enable Ground Control` and then `Alexa, open Ground Control`.
7+
8+
### Using this template
9+
10+
This template was designed to be used with the [Alexa Skills Kit Command-Line Interface](https://developer.amazon.com/docs/smapi/ask-cli-intro.html) (aka: ASK-CLI). After installing the ASK-CLI you can run the following command to setup a new skill project based on this template.
11+
12+
`$ ask new --template --url http://skilltemplates.com/templates.json`
13+
14+
After running the previous command you'll see of list of templates to choose from. Pick the template named `API Starter`. This will create a new folder named `./api-starter/` all of the code for the template will be located in that folder.
15+
16+
### Video Tutorial
17+
18+
[coming soon]

skill.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"skillManifest": {
3+
"publishingInformation": {
4+
"locales": {
5+
"en-US": {
6+
"summary": "Provides the total number of astronauts who are currently in space.",
7+
"examplePhrases": [
8+
"Alexa, ask API Starter how many people are in space",
9+
"Alexa, ask how many astronauts are in space from API Starter",
10+
"Alexa, ask API Starter how many humans are in space now"
11+
],
12+
"keywords": [
13+
"space",
14+
"astronauts",
15+
"rocket"
16+
],
17+
"name": "API Starter",
18+
"description": "Guess how many astronauts are currently in space? Know the answer? Alexa does. Just say: Alexa, ask rocket man how many people in space.",
19+
"smallIconUri": "https://s3.amazonaws.com/cdn.dabblelab.com/img/skill-template-default-sm.png",
20+
"largeIconUri": "https://s3.amazonaws.com/cdn.dabblelab.com/img/skill-template-default-lg.png"
21+
}
22+
},
23+
"isAvailableWorldwide": true,
24+
"testingInstructions": "No special instructions",
25+
"category": "EDUCATION_AND_REFERENCE",
26+
"distributionCountries": []
27+
},
28+
"apis": {
29+
"custom": {
30+
"endpoint": {
31+
"sourceDir": "lambda/custom"
32+
}
33+
}
34+
},
35+
"manifestVersion": "1.0",
36+
"privacyAndCompliance": {
37+
"allowsPurchases": false,
38+
"locales": {
39+
"en-US": {
40+
"termsOfUseUrl": "http://dabblelab.com/terms",
41+
"privacyPolicyUrl": "http://dabblelab.com/privacy"
42+
}
43+
},
44+
"isExportCompliant": true,
45+
"containsAds": false,
46+
"isChildDirected": false,
47+
"usesPersonalInfo": false
48+
}
49+
}
50+
}

0 commit comments

Comments
 (0)