Skip to content
Snippets Groups Projects
Commit 07ee1f22 authored by Alex's avatar Alex
Browse files

Enable turning off in sample function

parent ea361933
No related branches found
No related tags found
No related merge requests found
FROM alpine:latest
RUN apk --update add nodejs
#ADD https://github.com/alexellis/faas/releases/download/v0.3-alpha/fwatchdog /usr/bin
COPY ./fwatchdog /usr/bin/
ADD https://github.com/alexellis/faas/releases/download/v0.3-alpha/fwatchdog /usr/bin
#COPY ./fwatchdog /usr/bin/
RUN chmod +x /usr/bin/fwatchdog
COPY package.json .
COPY handler.js .
COPY sendColor.js .
COPY sample.json .
COPY package.json .
COPY handler.js .
COPY sendColor.js .
COPY sample_response.json .
RUN npm i
ENV fprocess="node handler.js"
CMD ["fwatchdog"]
#!/bin/bash
docker build -t alexellis2/faas-alexachangecolorintent .
docker build -t alexellis2/faas-alexachangecolorintent:latest-dev1 .
"use strict"
let fs = require('fs');
let sample = require("./sample.json");
let sample = require("./sample_response.json");
let SendColor = require('./sendColor');
let sendColor = new SendColor("alexellis.io/officelights")
......@@ -12,6 +12,7 @@ getStdin().then(content => {
});
function tellWithCard(speechOutput) {
console.log(sample)
sample.response.outputSpeech.text = speechOutput
sample.response.card.content = speechOutput
sample.response.card.title = "Office Lights";
......@@ -20,20 +21,28 @@ function tellWithCard(speechOutput) {
}
function handle(request, intent) {
let colorRequested = intent.slots.LedColor.value;
let req = {r:0,g:0,b:0};
if(colorRequested == "red") {
req.r = 255;
} else if(colorRequested== "blue") {
req.b = 255;
} else if (colorRequested == "green") {
req.g = 255;
if(intent.name == "TurnOffIntent") {
let req = {r:0,g:0,b:0};
var speechOutput = "Lights off.";
sendColor.sendColor(req, () => {
return tellWithCard(speechOutput);
});
} else {
let colorRequested = intent.slots.LedColor.value;
let req = {r:0,g:0,b:0};
if(colorRequested == "red") {
req.r = 255;
} else if(colorRequested== "blue") {
req.b = 255;
} else if (colorRequested == "green") {
req.g = 255;
}
else {
return tellWithCard("I heard "+colorRequested+ " but can only do: red, green, blue.", "I heard "+colorRequested+ " but can only do: red, green, blue.");
}
sendColor.sendColor(req, () => {
var speechOutput = "OK, " + colorRequested + ".";
return tellWithCard(speechOutput);
});
}
else {
return tellWithCard("I heard "+colorRequested+ " but can only do: red, green, blue.", "I heard "+colorRequested+ " but can only do: red, green, blue.");
}
sendColor.sendColor(req, () => {
var speechOutput = "OK, " + colorRequested + ".";
return tellWithCard(speechOutput);
});
}
\ No newline at end of file
}
{
"session": {
"sessionId": "SessionId.3f589830-c369-45a3-9c8d-7f5271777dd8",
"application": {
"applicationId": "amzn1.ask.skill.b32fb0db-f0f0-4e64-b862-48e506f4ea68"
},
"attributes": {},
"user": {
"userId": "amzn1.ask.account.AEUHSFGVXWOYRSM2A7SVAK47L3I44TVOG6DBCTY2ACYSCUYQ65MWDZLUBZHLDD3XEMCYRLS4VSA54PQ7QBQW6FZLRJSMP5BOZE2B52YURUOSNOWORL44QGYDRXR3H7A7Y33OP3XKMUSJXIAFH7T2ZA6EQBLYRD34BPLTJXE3PDZE3V4YNFYUECXQNNH4TRG3ZBOYH2BF4BTKIIQ"
},
"new": true
},
"request": {
"type": "IntentRequest",
"requestId": "EdwRequestId.9ddf1ea0-c582-4dd0-8547-359f71639c1d",
"locale": "en-GB",
"timestamp": "2017-01-28T11:02:59Z",
"intent": {
"name": "TurnOffIntent",
"slots": {
"LedColor": {
"name": "LedColor",
"value": "red"
}
}
}
},
"version": "1.0"
}
{
"version": "1.0",
"response": {
"outputSpeech": {
"type": "PlainText",
"text": "OK, red."
},
"card": {
"content": "OK, red.",
"title": "Office Lights",
"type": "Simple"
},
"shouldEndSession": true
},
"sessionAttributes": {}
}
......@@ -11,9 +11,9 @@ getStdin().then((content) => {
console.log("Arch: " + os.arch());
console.log("CPU count: " + os.cpus().length);
console.log("Uptime: " + os.uptime())
console.log("User info: " + os.userInfo());
if (content && content.length && content.indexOf("verbose") > -1) {
console.log(os.cpus());
console.log(os.networkInterfaces());
}
});
});
\ No newline at end of file
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment