Context Variables and Slots
Problem Our current bot cannot remember user input from one utterance to the next.
- When is your Toronto store open?
- It is open from 6am until 9pm
- Where is it located?
- A list of our store locations is available ...
^^ Problem: A human would have known the user was referring to the Toronto store, not generically to all stores.
Lifecycle of entities
$context_variables store values about the user interaction and stay available throughtout the entire conversation, so we can refer to them at any time.
If an entity pops up in the user input voluntarily, we can save that entiry into a context variable for later use. This is optional.
- So if a generic (no-entity) question is asked, we can provide a generic answer and no context variable is set. If one is mentioned, it is set, and we can use it.
We can make the slot required by adding a question to the slot and changing the slot type from 'optional' to 'required'
This ensures that if an entitiy is required for the bot's functionality to progress, it is available.
- Keep in mind that the slot will continue to ask for the value until one is provided.
Using multiple slots per entity/intent is great for collecting user information. Take, for example, the back-end/front-end situation for a restaurant booking below.
These values can then be stored through the use of a back-end API and piped into a database or JSON file etc.