Asking questions & queuing answers

Building Chatbots in Python

Alan Nichol

Co-founder and CTO, Rasa

Reusable patterns

"I'd like some Kenyan beans"

"I'm sorry, we're out of those. Shall I order some Brazilian ones for you?"

"Yes please"

"Can I get a box of 200 brown filters"

"I'm sorry, we're out of those, but I can get your some white ones. Should I order those for you?"

"Yes please"

Building Chatbots in Python

Pending actions

  • Policy returns two values: Selected action and pending_action
  • pending_action is saved in the outer scope
  • If we get a "yes" intent and there is a pending action, we execute it
  • If we get a "no" intent, we wipe any pending actions
Building Chatbots in Python

"I'd like to order some coffee"

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
  • Perfect! welcome back :)
Building Chatbots in Python

Let's practice!

Building Chatbots in Python

Preparing Video For Download...