You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
811 B
Python
32 lines
811 B
Python
import logging
|
|
logging.getLogger('flask_assistant').setLevel(logging.DEBUG)
|
|
|
|
from flask import Flask
|
|
from flask_assistant import Assistant, ask, tell, event, build_item
|
|
|
|
app = Flask(__name__)
|
|
assist = Assistant(app, route='/')
|
|
|
|
|
|
@assist.action('greeting')
|
|
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 ask_for_season(color):
|
|
speech = 'Ok, {} is an okay color I guess'.format(color)
|
|
return ask(speech)
|
|
|
|
if __name__ == '__main__':
|
|
app.run(debug=True) |