Below is sample chat to flight booking:
Hopper: Hello, John! It looks like you booked a Basic Economy flight.
Hopper: Are you aware that this flight doesn't have any storage for carry-on luggage?
> User is given the options [Yes] and [No]
User: No
Hopper: Some other limitations you may want to consider is that you will not be able to pick a seat.
Hopper: We're happy to let you know that we can upgrade you today for just $25!
Hopper: Would you like to do that now?
> User is given the options [Yes, please upgrade] and [Not right now]
User: Not right now
Conclusion: Okay, please let our customer service team know if you change your mind.
This conversation can take place in a different way based on user input. Deliver the entire conversation as a decision tree when the user enters the conversation interface. This particular conversation can be represented as follows (where each four spaces represents one indentation level):
Output(text="Hello, John! It looks like you booked a Basic Economy flight.")
Output(text="Are you aware that this flight doesn't have any storage for carry-on luggage?")
- Answer(text="No")
Output(text="Some other limitations you may want to consider is that you will not be able to pick a seat.")
Output(text="We're happy to let you know that we can upgrade you today for just $25!")
Output(text="Would you like to do that now?")
- Answer(text="Not right now")
Conclusion(text="Okay, please let our customer service team know if you change your mind.")
- Answer(text="Yes, please upgrade")
Conclusion(text="Okay, you've been upgraded!")
- Answer(text="Yes")
Output(text="We're happy to let you know that we can upgrade you today for just $25!")
Output(text="Would you like to do that now?")
- Answer(text="Not right now")
Conclusion(text="Okay, please let our customer service team know if you change your mind.")
- Answer(text="Yes, please upgrade")
Conclusion(text="Okay, you've been upgraded!")
This representation works, but we can see that there’s some room for reuse in this conversation to reduce the size of the payload. To do this, we implemented a “goto” system and label some of our output. Consider below eg:
Output(text="Hello, John! It looks like you booked a Basic Economy flight.")
Output(text="Are you aware that this flight doesn't have any storage for carry-on luggage?")
- Answer(text="No")
Output(text="Some other limitations you may want to consider is that you will not be able to pick a seat.")
Output(text="We're happy to let you know that we can upgrade you today for just $25!", label=1)
Output(text="Would you like to do that now?")
- Answer(text="Not right now")
Conclusion(text="Okay, please let our customer service team know if you change your mind.")
- Answer(text="Yes, please upgrade")
Conclusion(text="Okay, you've been upgraded!")
- Answer(text="Yes")
Goto(label=1)
In this example, the Goto(1) instruction would take the user straight to the existing subtree conversation, and Output has an optional second parameter to assign it a label. Outputs are the only thing that are a valid Goto target. It's another way of saying "continue the conversation from here".
You're given the conversation tree and an array of answers that the user picked, and your task is to construct what the conversation between the user and Hopper was. Essentially, this means running through the conversation tree and printing out what Hopper said and what the User said, and what the conversation ended with.
Below is eg of input:
Hello, John! It looks like you booked a Basic Economy flight.
Are you aware that this flight doesn't have any storage for carry-on luggage?
-No
Some other limitations you may want to consider is that you will not be able to pick a seat.
1:We're happy to let you know that we can upgrade you today for just $25!
Would you like to do that now?
-Not right now
=Okay, please let our customer service team know if you change your mind.
-Yes, please upgrade
=Okay, you've been upgraded!
-Yes
>1
---
No
Not right now
Any number of Outputs may follow a single Output (but only at the same indentation level), and any of them may have labels that can be referred to from anywhere in the tree.
An Output will always be followed by a series of Answers at the indentation of the Output + 1.
An Answer can only be followed either by an Output (rules above still apply), a Conclusion, or a Goto.
Goto and Conclusion cannot be followed by anything either at the same indentation level or the next one.
After an Answer to an Output has been specified, no more Outputs are allowed at that indentation level.
A Conclusion is meant to finish the conversation (all user answers after a Conclusion signal should be ignored).