forked from serverless/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler.py
More file actions
31 lines (25 loc) · 674 Bytes
/
Copy pathhandler.py
File metadata and controls
31 lines (25 loc) · 674 Bytes
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
import random
def parseInt(value):
try:
return int(value)
except ValueError:
return 100
def lucky_number(event, context):
print(event)
upperLimitDict = event['request']['intent']['slots']['UpperLimit']
upperLimit = None
if 'value' in upperLimitDict:
upperLimit = parseInt(upperLimitDict['value'])
else:
upperLimit = 100
number = random.randint(0, upperLimit)
response = {
'version': '1.0',
'response': {
'outputSpeech': {
'type': 'PlainText',
'text': 'Your lucky number is ' + str(number),
}
}
}
return response