-
Notifications
You must be signed in to change notification settings - Fork 0
/
lambda_function.txt
83 lines (78 loc) · 2.77 KB
/
lambda_function.txt
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import boto3
access_key = ""
access_secret = ""
region =""
queue_url = ""
def build_speechlet_response(title, output, reprompt_text, should_end_session):
return {
'outputSpeech': {
'type': 'PlainText',
'text': output
},
'card': {
'type': 'Simple',
'title': "SessionSpeechlet - " + title,
'content': "SessionSpeechlet - " + output
},
'reprompt': {
'outputSpeech': {
'type': 'PlainText',
'text': reprompt_text
}
},
'shouldEndSession': should_end_session
}
def build_response(session_attributes, speechlet_response):
return {
'version': '1.0',
'sessionAttributes': session_attributes,
'response': speechlet_response
}
def post_message(client, message_body, url):
response = client.send_message(QueueUrl = url, MessageBody= message_body)
def lambda_handler(event, context):
client = boto3.client('sqs', aws_access_key_id = access_key, aws_secret_access_key = access_secret, region_name = region)
intent_name = event['request']['intent']['name']
device_id = event['context']['System']['device']['deviceId']
#if intent_name == "HelloWorldIntent":
# post_message(client, 'hi', queue_url)
# message = "will do"
if intent_name == "ShowPC":
message = "showing PC"
elif intent_name == "LightsOn":
message="turning on the lights"
elif intent_name == "LightsOff":
message="turning off the lights"
elif intent_name == "ShowMac":
message="showing mac"
elif intent_name == "ShowHDMI":
message="showing HDMI"
elif intent_name == "MuteAudio":
message="Muting Audio"
elif intent_name == "UnmuteAudio":
message="unmuting audio"
elif intent_name == "ProjectorOn":
message="turning on projector"
elif intent_name == "ProjectorOff":
message="turning off projector"
elif intent_name == "ShowUsb":
message="showing usb"
elif intent_name == "ShowDvd":
message="showing dvd"
elif intent_name == "ShowCam":
message="showing doc cam"
elif intent_name == "SetVolume":
amplitude=0
message="volume changed to"
elif intent_name == "ShowUsb":
message="showing usb"
elif intent_name == "FreezeVideo":
message="Freezing Video"
elif intent_name == "MuteVideo":
message="muting video"
else:
message = "Okay"
post_message(client, intent_name, queue_url)
#post_message(client, device_id, queue_url)
speechlet = build_speechlet_response("Mirror Status", message, "", "true")
return build_response({}, speechlet)