Understanding YAML
Source: Dev.to
Contents
- YAML
- Intents
- Entities
- Slots
YAML (or YML)
YAML is a markup language. Unlike HTML or XML, it isn’t used for website design; in RASA it forms the structural foundation for all configuration files.
- YAML works through indentation to create hierarchical blocks.
- A type can be thought of as a superclass that contains its sub‑types (e.g., intents, slots, entities).
Typical block structure
- type:
examples: |
- e.g. 1
- e.g. 2
- e.g. 3
This pattern is commonly used for defining intents, slots, or entities with example phrases.
Intents
An intent captures what the user wants to say—the purpose behind a message. RASA’s NLU component maps many phrasings with the same meaning to a single intent.
Example intents
| User utterance | Mapped intent |
|---|---|
| I think I have a stomachache | intent_symptom_stomach_ache |
| My stomach hurts | intent_symptom_stomach_ache |
| I might be having abdominal pain | intent_symptom_stomach_ache |
How intents flow through a pipeline
[User query] → [NLU: intent & entity prediction] → [Dialogue manager] → [Bot response]
JSON representation of a prediction
{
"intent": {
"name": "report_symptom",
"confidence": 0.92
},
"entities": [
{"entity": "symptom", "value": "cough"},
{"entity": "duration", "value": "two days"}
]
}
Example NLU file (nlu.yml)
version: "3.1"
nlu:
- intent: greet
examples: |
- hello
- hi
- good morning
- intent: report_symptom
examples: |
- I have a headache
- My head hurts
- I've been coughing for two days
Declaring intents in domain.yml
intents:
- greet
- goodbye
- affirm
- deny
- mood_great
- mood_unhappy
- report_symptom
Entities
While intents answer what the user wants, entities provide the specific values mentioned in the utterance.
- Entities enable the bot to respond with detailed, context‑aware information.
- They are extracted by the NLU component and passed to the dialogue manager.
Example entity extraction (JSON)
{
"entities": [
{"entity": "symptom", "value": "fever"},
{"entity": "duration", "value": "three days"}
]
}
Defining entities in nlu.yml
nlu:
- intent: report_symptom
examples: |
- I have a [fever](symptom)
- I've been coughing for [two days](duration)
- My [head](body_part) hurts
Types of entities
- Word (free text)
- Categorical (pre‑defined list)
- Numerical (numbers, dates, etc.)
- Lookup / Regex (pattern‑based)
Slots
Slots are RASA’s memory system.
- Entities are extracted from a single user message.
- Slots persist across multiple turns, allowing the bot to retain context.
Why slots are needed
User: I have a fever.
Bot: How long have you had it?
User: Three days.
The bot must remember that the symptom is fever while it asks for the duration. Slots make this continuity possible; without them, each turn would be treated as an isolated input.
Slot flow diagram
[User input] → [Intent & Entity extraction] → [Slot filling / update] → [Dialogue manager (policies)] → [Bot response]
Defining slots in domain.yml
slots:
symptom:
type: text
influence_conversation: true
duration:
type: text
influence_conversation: true
When an entity is extracted, RASA can automatically map it to a corresponding slot (if the names match). This mapping bridges NLU output and the dialogue manager’s decision‑making.
TL;DR
- YAML structures all RASA configuration files.
- Intents capture the user’s goal.
- Entities capture the specific pieces of information within the utterance.
- Slots store those pieces of information across turns, enabling contextual, coherent conversations.
Understanding these building blocks is essential before moving on to Stories, Rules, and Policies, which orchestrate how the bot reacts based on intents, entities, and slots.
Slots in JSON Representation
{
"slots": {
"symptom": "fever",
"duration": "three days"
}
}
Types of Slots
- Text slots – store raw strings (e.g., symptoms, names)
- Categorical slots – restrict values to a predefined set (e.g., mild / moderate / severe)
- Boolean slots – true/false flags (e.g.,
emergency_present) - Float / integer slots – numerical values such as age or dosage
- List slots – store multiple values (e.g., multiple symptoms)
The next blog: To be released.