-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
35 lines (24 loc) · 819 Bytes
/
test.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
import logging
from flask import Flask
from flask_assistant import Assistant, ask, tell, context_manager
app = Flask(__name__)
assist = Assistant(app)
logging.getLogger('flask_assistant').setLevel(logging.DEBUG)
@assist.action('talk to signals everywhere')
def greet_and_start():
speech = "Hey! Are you male or female?"
return ask(speech)
@assist.action("give-gender")
def ask_for_color(gender):
if gender == 'male':
gender_msg = 'Sup bro!'
else:
gender_msg = 'Haay gurl!'
speech = gender_msg + ' What is your favorite color?'
return ask(speech)
@assist.action('give-color', mapping={'color': 'sys.color'})
def repeat_color(color):
speech = 'Ok, {} is an okay color I guess.'.format(color)
return ask(speech)
if __name__ == '__main__':
app.run(debug=True)