Building Chatbots in Python Chapter4
Building Chatbots in Python Chapter4
Stateful bots
Alan Nichol
Co-founder and CTO, Rasa
DataCamp Building Chatbots in Python
State machines
Browsing
Providing address, billing info
Order complete
DataCamp Building Chatbots in Python
Example rules:
policy_rules = {
(INIT, "order"): (CHOOSE_COFFEE, "ok, Columbian or Kenyan?"),
(CHOOSE_COFFEE, "specify_coffee"):
(ORDERED, "perfect, the beans are on their way!"),
}
DataCamp Building Chatbots in Python
Let's practice!
DataCamp Building Chatbots in Python
Alan Nichol
Co-founder and CTO, Rasa
DataCamp Building Chatbots in Python
Reusable patterns
"I'd like some Kenyan beans" "Can I get a box of 200 brown filters"
"I'm sorry, we're out of those. Shall I "I'm sorry, we're out of those, but I can
order some Brazilian ones for you?" get your some white ones. Should I
order those for you?"
"Yes please"
"Yes please"
DataCamp Building Chatbots in Python
Pending actions
Policy returns two values: Selected action and pending_action
state = INIT
action = "request_auth"
pending_state = AUTHED
Sounds good! I'd love to help you but you'll have to log in first, what's your phone
number?
"555-12345"
state = AUTHED
action = "acknowledge_auth"
pending_state = None
Let's practice!
DataCamp Building Chatbots in Python
Frontiers of dialogue
technology
Alan Nichol
Co-founder and CTO, Rasa
DataCamp Building Chatbots in Python
Seq2seq
Machine translation
Completely data driven, no hand-crafting
Requires large amount of data
No guarantee that output is coherent
Difficult to integrate DB / API calls & other logic
DataCamp Building Chatbots in Python
Language generation
Not recommended if building a bot
Pre-trained neural network which can generate text
Scripts of every episode of The Simpsons
DataCamp Building Chatbots in Python
Let's practice!
DataCamp Building Chatbots in Python
Congratulations!
Alan Nichol
Co-founder and CTO, Rasa
DataCamp Building Chatbots in Python
Let's practice!