-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlambda.js
More file actions
65 lines (52 loc) · 1.97 KB
/
Copy pathlambda.js
File metadata and controls
65 lines (52 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"use strict";
var Alexa = require("alexa-sdk");
var rosbridge = require('./rosbridge.js'); //for communication with ROS
const APP_ID = undefined;
const HELP_MESSAGE = 'You can give me any command you see through the Graspit interface. Please tell me your command.';
const HELP_REPROMPT = 'What can I help you with?';
const STOP_MESSAGE = 'Goodbye!';
var handlers = {
"HelloIntent": function () {
this.response.speak("What's up");
this.emit(':responseReady');
},
"AMAZON.HelpIntent": function () {
this.response.speak(HELP_MESSAGE).listen(HELP_REPROMPT);
//this.response.speak(HELP_MESSAGE); //link to help text in YAML
this.emit(':responseReady');
},
"AMAZON.CancelIntent": function () {
this.response.speak(STOP_MESSAGE);
this.emit(':responseReady');
},
"SendCommandIntent": function () {
const commandSlot = this.event.request.intent.slots.Command;
var commandName;
var validPhrases = rosbridge.returnValidPhrases();
console.log("phrases: " + validPhrases);
if(commandSlot && commandSlot.value){
commandName = commandSlot.value;
console.log(commandName);
if(validPhrases.indexOf(commandName) != -1){
this.response.speak("Command received");
console.log("valid command received: " + commandName);
rosbridge.publishCommand(commandName);
}
else{
this.response.speak("Invalid command received");
}
}
else{
this.response.speak("No command received");
}
//const command = myCommandList[commandName]
this.emit(':responseReady');
}
};
//what port does this use...3000?
exports.handler = function (event, context, callback) { //for Lambda AWS
var alexa = Alexa.handler(event, context);
alexa.appId = undefined;
alexa.registerHandlers(handlers);
alexa.execute();
};