slots
If you have a value that is recurring in more than one place, you can factor it out to the slots
section.
slots:
- &wants-pizza
ask: Would you like to order pizza?
type: boolean
actions:
- say: I can only help with pizza reservations.
when:
not: *wants-pizza
- say: you want pizza!
when: *wants-pizza
Types of slots
Currently supported types:
Person name
&name
ack: Nice to meet you {}!
ask: What is your name?
type: name
Address
&address
ask: What is your address?
type: address
Phone
&phone
ask: What is your phone number?
type: phone
&email
ask: What is your email?
type: email
Amount of
&amount_of_something
ask: How many dogs do you have?
amount-of: dogs
Boolean
&user-wants-pizza
ask: Would you like to order pizza?
type: boolean
Intent
&user-wants-to-complain
intent:
- I have a complaint
- I want to complain
Choice
&size-of-shirt
ask: What size of t-shirt would you like?
choice:
- small
- medium
- large
Dynamic choice
The list of choices can also be dynamically generated by a remote function based on other slots values.
For example:
&toppings
ask: "Which toppings would you like? you can choose from: {}"
choice:
state-remote: http://localhost/toppings
needs:
- key: is-vegan
value:
ask: Are you vegan?
type: boolean
The server will be called with a post request with a JSON body containing known items from the needs
dictionary.
It must return a JSON string list with possible choices or null to indicate "unknown".
Date time choice
When the choice list consists exclusively of ISO 8601 formatted strings. The bot will try to understand date/time utterances and resolve it to unique choice.
For example for the list: ["2022-04-25T11:00:00","2022-04-25T12:00:00"]
:
- if the user says "12 pm" the bot will understand the second option.
- if the user says "25th" the bot will ask the user to rephrase because it can not resolve the ambiguity.
Multiple choice
&choice-of-toppings
ask: What kind of toppings would you like?
multiple-choice:
- mushrooms
- olives
- tomatoes
- onions
Compound slots
Slots can be combined into compound slots via operators.
List of available operators:
not
all
any
greater_equals
equals
For example:
slots:
- &age
ask: What is your age?
type: number
- &gender
ask: What is your gender?
multiple-choice:
- male
- female
- non binary
- &male_and_above_18
all:
- is: age
greater_than: 18
- is: gender
equals: female