Domains
These docs are for version 1.x of Rasa Open Source.
User Guide
- Installation
- Rasa Tutorial
- Command Line Interface
- Architecture
- Messaging and Voice Channels
- Evaluating Models
- Validate Data
- Running the Server
- Running Rasa with Docker
- Cloud Storage
NLU
- About
- Using NLU Only
- Training Data Format
- Choosing a Pipeline
- Language Support
- Entity Extraction
- Components
Core
Conversation Design
API Reference
- Action Server
- HTTP API
- Jupyter Notebooks
- Agent
- Custom NLU Components
- Events
- Tracker
- Tracker Stores
- Event Brokers
- Training Data Importers
- Featurization
- Migration Guide
- Rasa Change Log
Migrate from (beta)
Reference
Domains
The Domain defines the universe in which your assistant operates. It specifies the intents, entities, slots, and actions your bot should know about. Optionally, it can also include templates for the things your bot can say.
Example Domain
As an example, the DefaultDomain has the following yaml definition:
intents:
- greet
- goodbye
- affirm
- deny
- mood_great
- mood_unhappy
actions:
- utter_greet
- utter_cheer_up
- utter_did_that_help
- utter_happy
- utter_goodbye
templates:
utter_greet:
- text: "Hey! How are you?"
utter_cheer_up:
- text: "Here is something to cheer you up:"
image: "https://i.imgur.com/nGF1K8f.jpg"
utter_did_that_help:
- text: "Did that help you?"
utter_happy:
- text: "Great carry on!"
utter_goodbye:
- text: "Bye"
What does this mean?
Your NLU model will define the intents and entities that you need to include in the domain.
Slots hold information you want to keep track of during a conversation. A categorical slot called risk_level would be defined like this:
slots:
risk_level:
type: categorical
values:
- low
- medium
- high
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!
Custom Actions and Slots
To reference slots in your domain, you need to reference them by their module path. To reference custom actions, use their name. For example, if you have a module called my_actions containing a class MyAwesomeAction, and module my_slots containing MyAwesomeSlot, you would add these lines to the domain file:
actions:
- my_custom_action
...
slots:
- my_slots.MyAwesomeSlot
Utterance templates
Utterance templates are messages the bot will send back to the user. There are two ways to use these templates:
- If the name of the template starts with
utter_, the utterance can directly be used as an action. You would add the utterance template to the domain:
templates:
utter_greet:
- text: "Hey! How are you?"
- You can use the templates to generate response messages from your custom actions using the dispatcher:
dispatcher.utter_template("utter_greet", tracker).
Images and Buttons
Templates defined in a domain’s yaml file can contain images and buttons as well:
templates:
utter_greet:
- text: "Hey! How are you?"
buttons:
- title: "great"
payload: "great"
- title: "super sad"
payload: "super sad"
utter_cheer_up:
- text: "Here is something to cheer you up:"
image: "https://i.imgur.com/nGF1K8f.jpg"
Custom Output Payloads
You can also send any arbitrary output to the output channel using the custom: key. Note that since the domain is in yaml format, the json payload should first be converted to yaml format.
Channel-Specific Utterances
If you have certain utterances that you would like sent only to specific channels, you can specify this with the channel: key.
Variables
You can also use variables in your templates to insert information collected during the dialogue.
Variations
If you want to randomly vary the response sent to the user, you can list multiple responses and Rasa will randomly pick one of them.
Ignoring entities for certain intents
If you want all entities to be ignored for certain intents, you can add the use_entities: [] parameter to the intent in your domain file.
👋 I can help you get started with Rasa and answer your technical questions.