Stories
These docs are for version 1.x of Rasa Open Source.
User Guide
- Installation
- Tutorial: Rasa Basics
- Tutorial: Building Assistants
- Command Line Interface
- Architecture
- Messaging and Voice Channels
- Testing Your Assistant
- Setting up CI/CD
- Validate Data
- Configuring the HTTP API
- Deploying Your Rasa Assistant
- Cloud Storage
NLU
- About
- Using NLU Only
- Training Data Format
- Language Support
- Choosing a Pipeline
- Components
- Entity Extraction
Core
- About
- Stories
- Domains
- Responses
- Actions
- Reminders and External Events
- Policies
- Slots
- Forms
- Retrieval Actions
- Interactive Learning
- Fallback Actions
- Knowledge Base Actions
Stories
Rasa stories are a form of training data used to train Rasa’s dialogue management models.
A story is a representation of a conversation between a user and an AI assistant, converted into a specific format where user inputs are expressed as corresponding intents (and entities where necessary) while the responses of an assistant are expressed as corresponding action names.
A training example for the Rasa Core dialogue system is called a story. This is a guide to the story data format.
You can also spread your stories across multiple files and specify the folder containing the files for most of the scripts (e.g. training, visualization). The stories will be treated as if they would have been part of one large file.
Format
Here’s an example of a dialogue in the Rasa story format:
## greet + location/price + cuisine + num people <!-- name of the story - just for debugging -->
* greet
- action_ask_howcanhelp
* inform{"location": "rome", "price": "cheap"} <!-- user utterance, in format intent{entities} -->
- action_on_it
- action_ask_cuisine
* inform{"cuisine": "spanish"}
- action_ask_numpeople <!-- action that the bot should execute -->
* inform{"people": "six"}
- action_ack_dosearch
What makes up a story?
- A story starts with a name preceded by two hashes
## story_03248462. - The end of a story is denoted by a newline, and then a new story starts again with
##. - Messages sent by the user are shown as lines starting with
*in the formatintent{"entity1": "value", "entity2": "value"}. - Actions executed by the bot are shown as lines starting with
-and contain the name of the action.
User Messages
While writing stories, you do not have to deal with the specific contents of the messages that the users send. Instead, you can take advantage of the output from the NLU pipeline, which lets you use just the combination of an intent and entities to refer to all the possible messages the users can send to mean the same thing.
Actions
While writing stories, you will encounter two types of actions: utterance actions and custom actions. Utterance actions are hardcoded messages that a bot can respond with. Custom actions, on the other hand, involve custom code being executed.
Events
Events such as setting a slot or activating/deactivating a form have to be explicitly written out as part of the stories. Having to include the events returned by a custom action separately, when that custom action is already part of a story might seem redundant. However, since Rasa cannot determine this fact during training, this step is necessary.
Slot Events
Slot events are written as - slot{"slot_name": "value"}. If this slot is set inside a custom action, it is written on the line immediately following the custom action event.
Form Events
A form action event (e.g. - restaurant_form) is used in the beginning when first starting a form, and also while resuming the form action when the form is already active.
Checkpoints and OR statements
Checkpoints and OR statements should both be used with caution, if at all. There is usually a better way to achieve what you want by using forms and/or retrieval actions.
Checkpoints can be useful, but do not overuse them. Using lots of checkpoints can quickly make your example stories hard to understand. Here is an example story file which contains checkpoints:
## first story
* greet
- action_ask_user_question
> check_asked_question
## user affirms question
> check_asked_question
* affirm
- action_handle_affirmation
> check_handled_affirmation
## user denies question
> check_asked_question
* deny
- action_handle_denial
> check_handled_denial
## user leaves
> check_handled_denial
> check_handled_affirmation
* goodbye
- utter_goodbye
End-to-End Story Evaluation Format
The end-to-end story format combines both NLU and Core training data into a single file for evaluation.