The Domain File
Video
What's in the Domain File?
The domain.yml
is the configuration file of everything that your assistant "knows". It contains:
- Responses: These are the things the assistant can say to users.
- Intents: These are categories of things users say.
- Slots: These are variables remembered over the course of a conversation.
- Entities: These are pieces of information extracted from incoming text.
- Forms and actions: These add application logic & extend what your assistant can do.
Let's zoom in on responses and intents for now.
Responses
Here's an example snippet from a domain.yml
file that shows some example responses.
responses: utter_greet: - text: "Hey there!" utter_goodbye: - text: "Goodbye :(" utter_default: - text: "Sorry, I didn't get that, can you rephrase?" utter_youarewelcome: - text: "You're very welcome!" utter_iamabot: - text: "I am a bot, powered by Rasa."
There is a utter_<thing>
naming convention so that each response starts with
"utter". Note that we very much recommend having a utter_iamabot
in your domain
file since because assistant should be able to explain that they are not a human.
You're not limited to static responses though. You can also define responses that are dynamic.
responses:
utter_greet:
- text: "Hey, {name}. How are you?"
- text: "Hey, {name}. How is your day going?"
In this case, Rasa will randomly select one of the two responses whenever it needs
to send the utter_greet
response. It will also fill in the {name}
variable with
a slot value if there is one that's available.
You've also able to have responses that contain images or buttons as well!
responses: utter_greet: - text: "Hey! How are you?" buttons: - title: "great" payload: "/mood_great" - title: "super sad" payload: "/mood_sad" utter_cheer_up: - text: "Here is something to cheer you up:" image: "https://i.imgur.com/nGF1K8f.jpg"
You can even customise the message based on the channel that you're using.
responses: utter_ask_game: - text: "Which game would you like to play on Slack?" channel: "slack" - text: "Which game would you like to play?"
This way, slack users will be able to get a different message. You can even send custom payloads if you've made your own channel. It's an advanced use-case, but Rasa really allows you to customise what you send to the front-end.
responses: utter_book_time: - custom: blocks: - type: section text: text: "Book a time for your appointment:" type: mrkdown accessory: type: datepicker initial_date: "2019-05-21" placeholder: type: plain_text text: "Select a date"
Again, this is very much an advanced use-case for responses. But it's good to know.
Intents
Responses are things that you can send to the user, but we also need to define the intents that the user can send to the assitant. That's why the domain file also needs a list of intents that are used.
intents: - affirm - deny - greet - thankyou - goodbye - search_concerts - search_venues - compare_reviews - bot_challenge - how_to_get_started
The training data for these intents can be found in the nlu.yml
file. We recommend
starting with only a few intents when you're getting started, but you will need to define
the intents you want to use in the domain.yml
file.
Links
Exercises
Try to answer the following questions to test your knowledge.
- Try to name all the ways you can customise the responses in the
domain.yml
file. - Besides responses and intents, what else can we expect to find in our
domain.yml
file?