Domains

These docs are for version 1.x of Rasa Open Source.

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.

An example of a Domain

As an example, the DefaultDomain has the following yaml definition:

intents:
  - greet
  - goodbye
  - affirm
  - deny
  - mood_great
  - mood_unhappy
  - bot_challenge

actions:
- utter_greet
- utter_cheer_up
- utter_did_that_help
- utter_happy
- utter_goodbye
- utter_iamabot

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"

utter_iamabot:
  - text: "I am a bot, powered by Rasa."

session_config:
  session_expiration_time: 60
  carry_over_slots_to_new_session: true

Your NLU model will define the intents and entities that you need to include in the domain.

Slots

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

Actions are the things your bot can actually do. For example, an action could:

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:

  1. 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:


2. You can use the templates to generate response messages from your custom actions using the dispatcher:

from rasa_sdk.actions import Action

class ActionGreet(Action): def name(self): return 'action_greet'

def run(self, dispatcher, tracker, domain): dispatcher.utter_message(template="utter_greet") return []


## Images and Buttons

Templates defined in a domain’s yaml file can contain images and buttons as well:

templates: utter_greet:


## 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. The value should match the name defined in the `name()` method of the channel’s `OutputChannel` class.

templates: utter_ask_game:


## Variables

You can use **variables** in your templates to insert information collected during the dialogue. For example:

templates: utter_greet:


## 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 like this:

intents:


## Session configuration

A conversation session represents the dialogue between the assistant and the user. Conversation sessions can begin in three ways:

> 1. the user begins the conversation with the assistant,
>
> 2. the user sends their first message after a configurable period of inactivity, or
>
> 3. a manual session start is triggered with the `/session_start` intent message.

You can define the period of inactivity after which a new conversation session is triggered in the domain under the `session_config` key.

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