Last active
May 15, 2020 03:54
-
-
Save epireve/1374fa9c277193cfbd44bced61541daf to your computer and use it in GitHub Desktop.
Dummy Coffee Chatbot. Chatbot Evolution and Dialog Trees
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define your functions | |
def coffee_bot(): | |
print("Welcome to the cafe!") | |
size = get_size() | |
print(size) | |
drink_type = get_drink_type() | |
print(drink_type) | |
print('Alright, that\'s a {} {}!'.format(size, drink_type)) | |
extra_options() | |
name = input('Can I get your name please? \n> ') | |
print('Thanks, {}! Your drink will be ready shortly.'.format(name)) | |
def get_size(): | |
res = input('What size drink can I get for you? \n[a] Small \n[b] Medium \n[c] Large \n> ') | |
if res == 'a': | |
return 'small' | |
elif res == 'b': | |
return 'medium' | |
elif res == 'c': | |
return 'large' | |
else: | |
print_message() | |
return get_size() | |
def print_message(): | |
print("I'm sorry, I did not understand your selection. Please enter the corresponding letter for your response.") | |
def get_drink_type(): | |
res = input('What type of drink would you like? \n[a] Brewed Coffee \n[b] Mocha \n[c] Latte \n> ') | |
if res == 'a': | |
return 'brewed coffee' | |
elif res == 'b': | |
return 'mocha' | |
elif res == 'c': | |
return 'latte' | |
else: | |
print_message() | |
return get_drink_type() | |
def order_latte(): | |
res = input('And what kind of milk for your latte? \n[a] 2% milk \n[b] Non-fat milk \n[c] Soy milk \n> ') | |
if res == 'a': | |
return 'latte' | |
elif res == 'b': | |
return 'non-fat latte' | |
elif res == 'c': | |
return 'soy latte' | |
else: | |
print_message() | |
return order_latte() | |
def get_drink_type(): | |
res = input('What type of drink would you like? \n[a] Brewed Coffee \n[b] Mocha \n[c] Latte \n> ') | |
if res == 'a': | |
return 'brewed coffee' | |
elif res == 'b': | |
return 'mocha' | |
elif res == 'c': | |
return order_latte() | |
else: | |
print_message() | |
return get_drink_type() | |
def extra_options(): | |
res = input('Would you like a plastic cup or did you bring your own reusable cup? \n[a] I\'ll need a cup. \n[b] Brought my own! \n> ') | |
if res == 'a': | |
print('Okay, no problem! We\'ll get you a plastic cup.') | |
elif res == 'b': | |
print('Great! We\'ll fill up your reusable cup.') | |
else: | |
print_message() | |
return extra_options() | |
coffee_bot() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment