diff --git a/sample-functions/ChangeColorIntent/Dockerfile b/sample-functions/ChangeColorIntent/Dockerfile index 3abd8cdb8e4f8a4c1f9966b15820b02d95a68f3d..22aa324979b439d4062ba4ddf166f675a1674605 100644 --- a/sample-functions/ChangeColorIntent/Dockerfile +++ b/sample-functions/ChangeColorIntent/Dockerfile @@ -1,15 +1,16 @@ 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"] diff --git a/sample-functions/ChangeColorIntent/build.sh b/sample-functions/ChangeColorIntent/build.sh index 79fbc49e66cbc8dee9a39a82895273fc5edfa195..9c4431fa18a8b47ba47189c56ded6f5c799a4054 100755 --- a/sample-functions/ChangeColorIntent/build.sh +++ b/sample-functions/ChangeColorIntent/build.sh @@ -1,4 +1,4 @@ #!/bin/bash -docker build -t alexellis2/faas-alexachangecolorintent . +docker build -t alexellis2/faas-alexachangecolorintent:latest-dev1 . diff --git a/sample-functions/ChangeColorIntent/handler.js b/sample-functions/ChangeColorIntent/handler.js index 3a5d9ce148aaf330a660242c5d11f0ca06c023e5..f51e5226ff6111f921078877becfe09480dc052e 100644 --- a/sample-functions/ChangeColorIntent/handler.js +++ b/sample-functions/ChangeColorIntent/handler.js @@ -1,6 +1,6 @@ "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 +} diff --git a/sample-functions/ChangeColorIntent/off.json b/sample-functions/ChangeColorIntent/off.json new file mode 100644 index 0000000000000000000000000000000000000000..e79376614467fa245fe73d9201d2ee7e46d947e6 --- /dev/null +++ b/sample-functions/ChangeColorIntent/off.json @@ -0,0 +1,29 @@ +{ + "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" +} diff --git a/sample-functions/ChangeColorIntent/sample_response.json b/sample-functions/ChangeColorIntent/sample_response.json new file mode 100644 index 0000000000000000000000000000000000000000..5caf707d66ce26c902e13679b3191c6257c26de8 --- /dev/null +++ b/sample-functions/ChangeColorIntent/sample_response.json @@ -0,0 +1,16 @@ +{ + "version": "1.0", + "response": { + "outputSpeech": { + "type": "PlainText", + "text": "OK, red." + }, + "card": { + "content": "OK, red.", + "title": "Office Lights", + "type": "Simple" + }, + "shouldEndSession": true + }, + "sessionAttributes": {} +} diff --git a/sample-functions/NodeInfo/main.js b/sample-functions/NodeInfo/main.js index fd477e6e14da7ba0f60e949da164fbffb3235184..37ae78643df6e0fbf1b98556ee3b3dc70e3bf9c4 100644 --- a/sample-functions/NodeInfo/main.js +++ b/sample-functions/NodeInfo/main.js @@ -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 +});