Domain
Rasa Domain Example
You are viewing documentation for our open source project which is maintained by the community. If you want to get started building assistants with Rasa please check out our latest documentation here.
Here is a full example of a domain, taken from the concertbot example:
version: "3.1"
intents:
- affirm
- deny
- greet
- thankyou
- goodbye
- search_concerts
- search_venues
- compare_reviews
- bot_challenge
- nlu_fallback
- how_to_get_started
entities:
- name
slots:
concerts:
type: list
influence_conversation: false
mappings:
- type: custom
venues:
type: list
influence_conversation: false
mappings:
- type: custom
likes_music:
type: bool
influence_conversation: true
mappings:
- type: custom
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."
utter_get_started:
- text: "I can help you find concerts and venues. Do you like music?"
utter_awesome:
- text: "Awesome! You can ask me things like \"Find me some concerts\" or \"What's a good venue\""
actions:
- action_search_concerts
- action_search_venues
- action_show_concert_reviews
- action_show_venue_reviews
- action_set_music_preference
session_config:
session_expiration_time: 60 # value in minutes
carry_over_slots_to_new_session: true
## Multiple Domain Files
The domain can be defined as a single YAML file or split across multiple files in a directory. When split across multiple files, the domain contents will be read and automatically merged together. Using the [command line interface](https://legacy-docs-oss.rasa.com/docs/rasa/next/command-line-interface#rasa-train), you can train a model with split domain files by running:
```shell
rasa train --domain path_to_domain_directory
Intents
The intents key in your domain file lists all intents used in your NLU data and conversation training data.
Ignoring Entities for Certain Intents
To ignore all entities for certain intents, you can add the use_entities: [] parameter to the intent in your domain file like this:
intents:
- greet:
use_entities: []
To ignore some entities or explicitly take only certain entities into account you can use this syntax:
intents:
- greet:
use_entities:
- name
- first_name
- farewell:
ignore_entities:
- location
- age
- last_name
You can only use_entities or ignore_entities for any single intent. Excluded entities for those intents will be unfeaturized and therefore will not impact the next action predictions. This is useful when you have an intent where you don't care about the entities being picked up. If you list your intents without a use_entities or ignore_entities parameter, the entities will be featurized as normal.
Entities
New in 3.1
As of 3.1, you can use the influence_conversation flag under entities. The flag can be set to false to declare that an entity should not be featurized for any intents. It is a shorthand syntax for adding an entity to the ignore_entities list of every intent in the domain. The flag is optional and default behaviour remains unchanged.
The entities section lists all entities that can be extracted by any entity extractor in your NLU pipeline.
For example:
entities:
- PERSON # entity extracted by SpacyEntityExtractor
- time # entity extracted by DucklingEntityExtractor
- membership_type # custom entity extracted by DIETClassifier
- priority # custom entity extracted by DIETClassifier
Slots
Slots are your bot's memory. They act as a key-value store which can be used to store information the user provided (e.g. their home city) as well as information gathered about the outside world (e.g. the result of a database query).
Slots are defined in the slots section of your domain with their name, type and if and how they should influence the assistant's behavior.
For example:
slots:
slot_name:
type: text
mappings:
- type: from_entity
entity: entity_name
Slots and Conversation Behavior
You can specify whether or not a slot influences the conversation with the influence_conversation property. If you want to store information in a slot without it influencing the conversation, set influence_conversation: false when defining your slot.
Slot Types
Text Slot
- Type
text
- Use For
Storing text values.
- Example
slots:
cuisine:
type: text
mappings:
- type: from_entity
entity: cuisine
Responses
Responses are actions that send a message to a user without running any custom code or returning events. These responses can be defined directly in the domain file under the responses key and can include rich content such as buttons and attachments.
Forms
Forms are a special type of action meant to help your assistant collect information from a user. Define forms under the forms key in your domain file.
Actions
Actions are the things your bot can actually do. For example, an action could:
- respond to a user,
- make an external API call,
- query a database, or
- just about anything!
Session configuration
A conversation session represents the dialogue between the assistant and the user. Conversation sessions can begin in three ways:
- the user begins the conversation with the assistant,
- the user sends their first message after a configurable period of inactivity, or
- a manual session start is triggered with the
/session_startintent message.
You can define the period of inactivity after which a new conversation session is triggered in the domain under the session_config key.
Available parameters are:
session_expiration_timedefines the time of inactivity in minutes after which a new session will begin.carry_over_slots_to_new_sessiondetermines whether existing set slots should be carried over to new sessions.
The default session configuration looks as follows:
session_config:
session_expiration_time: 60 # value in minutes, 0 means infinitely long
carry_over_slots_to_new_session: true # set to false to forget slots between sessions
Config
The config key in the domain file maintains the store_entities_as_slots parameter. This parameter is used only in the context of reading stories and turning them into trackers. If the parameter is set to True, this will result in slots being implicitly set from entities if applicable entities are present in the story.