mirror of
https://github.com/openfaas/faas.git
synced 2025-06-18 12:06:37 +00:00
Enable turning off in sample function
This commit is contained in:
@ -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 sample_response.json .
|
||||
|
||||
RUN npm i
|
||||
|
||||
ENV fprocess="node handler.js"
|
||||
CMD ["fwatchdog"]
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
docker build -t alexellis2/faas-alexachangecolorintent .
|
||||
docker build -t alexellis2/faas-alexachangecolorintent:latest-dev1 .
|
||||
|
||||
|
@ -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,6 +21,13 @@ function tellWithCard(speechOutput) {
|
||||
}
|
||||
|
||||
function handle(request, intent) {
|
||||
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") {
|
||||
@ -37,3 +45,4 @@ function handle(request, intent) {
|
||||
return tellWithCard(speechOutput);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
29
sample-functions/ChangeColorIntent/off.json
Normal file
29
sample-functions/ChangeColorIntent/off.json
Normal file
@ -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"
|
||||
}
|
16
sample-functions/ChangeColorIntent/sample_response.json
Normal file
16
sample-functions/ChangeColorIntent/sample_response.json
Normal file
@ -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": {}
|
||||
}
|
@ -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());
|
||||
}
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user