Building Chatbots in Python
Alan Nichol
Co-founder and CTO, Rasa
"I love stateless systems!"
"don't what have drawbacks?"
"don't they have drawbacks?"
INIT = 0
CHOOSE_COFFEE = 1
ORDERED = 2
Example rules:
policy_rules = {
(INIT, "order"): (CHOOSE_COFFEE, "ok, Columbian or Kenyan?"),
(CHOOSE_COFFEE, "specify_coffee"):
(ORDERED, "perfect, the beans are on their way!"),
}
state = INIT
def respond(state, message):
(new_state, response) = policy_rules[(state,
interpret(message))]
return new_state, response
def send_message(state, message):
new_state, response = respond(state, message)
return new_state
state = send_message(state, message)
Building Chatbots in Python