Domains Flashcards

1
Q

What are domains?

A

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 include templates for the things bots can sat

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to refer to Custom Actions and Slots in the domain?

A

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
“””

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to specify utterance templates?

A

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?”
Afterwards, you can use the template as an action in the stories:

greet the user
* intent_greet
- utter_greet
When utter_greet is run as an action, it will send the message from the template back to the user.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to use utterance templates in custom actions?

A

You can use the templates to generate response messages from your custom actions using the dispatcher: dispatcher.utter_template(“utter_greet”, tracker). This allows you to separate the logic of generating the messages from the actual copy. In you custom action code, you can send a message based on the template like this:

”””
from rasa_sdk.actions import Action

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

def run(self, dispatcher, tracker, domain):
dispatcher.utter_template(“utter_greet”, tracker)
return []
“””

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How to use images and buttons in the utterance template?

A

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"
"""

NB.:
Please keep in mind that it is up to the implementation of the output channel on how to display the defined buttons. The command line, for example, can’t display buttons or images, but tries to mimic them by printing the options.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can you ignore entities for certain intents?

A

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:
  - 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
    ignore_entities:
      - location
      - age
"""

This means that 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 as normal without this parameter, the entities will be featurized as normal.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly