-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
57 lines (35 loc) · 1016 Bytes
/
main.py
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
from flask import Flask
from flask_ask import Ask, statement, question
from machines.routine import DailyRoutineMachine
routine = DailyRoutineMachine('routine')
app = Flask(__name__)
ask = Ask(app, '/')
@ask.launch
def launched():
return question(routine.state)
@ask.intent('GetUp')
def get_up():
return routine.execute_transition('get_up')
@ask.intent('GoToBed')
def go_to_bed():
return routine.execute_transition('go_to_bed')
@ask.intent('State')
def get_state():
return statement(routine.state)
@ask.intent('AMAZON.YesIntent')
def yes_intent():
return routine.execute_transition('yes')
@ask.intent('AMAZON.NoIntent')
def no_intent():
return routine.execute_transition('no')
@ask.on_session_started
def new_session():
app.logger.debug('new session started')
def close_user_session():
app.logger.debug('user session stopped')
@ask.session_ended
def session_ended():
close_user_session()
return "", 200
if __name__ == '__main__':
app.run(debug=True)