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

---

# User Guide

- [Installation](https://legacy-docs-v1.rasa.com/1.10.8/user-guide/installation/)
- [Tutorial: Rasa Basics](https://legacy-docs-v1.rasa.com/1.10.8/user-guide/rasa-tutorial/)
- [Tutorial: Building Assistants](https://legacy-docs-v1.rasa.com/1.10.8/user-guide/building-assistants/)
- [Command Line Interface](https://legacy-docs-v1.rasa.com/1.10.8/user-guide/command-line-interface/)
- [Architecture](https://legacy-docs-v1.rasa.com/1.10.8/user-guide/architecture/)
- [Messaging and Voice Channels](https://legacy-docs-v1.rasa.com/1.10.8/user-guide/messaging-and-voice-channels/)
- [Testing Your Assistant](https://legacy-docs-v1.rasa.com/1.10.8/user-guide/testing-your-assistant/)
- [Setting up CI/CD](https://legacy-docs-v1.rasa.com/1.10.8/user-guide/setting-up-ci-cd/)
- [Validate Data](https://legacy-docs-v1.rasa.com/1.10.8/user-guide/validate-files/)
- [Configuring the HTTP API](https://legacy-docs-v1.rasa.com/1.10.8/user-guide/configuring-http-api/)
- [Deploying Your Rasa Assistant](https://legacy-docs-v1.rasa.com/1.10.8/user-guide/how-to-deploy/)
- [Cloud Storage](https://legacy-docs-v1.rasa.com/1.10.8/user-guide/cloud-storage/)

# NLU

- [About](https://legacy-docs-v1.rasa.com/1.10.8/nlu/about/)
- [Using NLU Only](https://legacy-docs-v1.rasa.com/1.10.8/nlu/using-nlu-only/)
- [Training Data Format](https://legacy-docs-v1.rasa.com/1.10.8/nlu/training-data-format/)
- [Language Support](https://legacy-docs-v1.rasa.com/1.10.8/nlu/language-support/)
- [Choosing a Pipeline](https://legacy-docs-v1.rasa.com/1.10.8/nlu/choosing-a-pipeline/)
- [Components](https://legacy-docs-v1.rasa.com/1.10.8/nlu/components/)
- [Entity Extraction](https://legacy-docs-v1.rasa.com/1.10.8/nlu/entity-extraction/)

# Core

- [About](https://legacy-docs-v1.rasa.com/1.10.8/core/about/)
- [Stories](https://legacy-docs-v1.rasa.com/1.10.8/core/stories/)
- [Domains](https://legacy-docs-v1.rasa.com/1.10.8/core/domains/)
- [Responses](https://legacy-docs-v1.rasa.com/1.10.8/core/responses/)
- [Actions](https://legacy-docs-v1.rasa.com/1.10.8/core/actions/)
- [Reminders and External Events](https://legacy-docs-v1.rasa.com/1.10.8/core/reminders-and-external-events/)
- [Policies](https://legacy-docs-v1.rasa.com/1.10.8/core/policies/#)
- [Slots](https://legacy-docs-v1.rasa.com/1.10.8/core/slots/)
- [Forms](https://legacy-docs-v1.rasa.com/1.10.8/core/forms/)
- [Retrieval Actions](https://legacy-docs-v1.rasa.com/1.10.8/core/retrieval-actions/)
- [Interactive Learning](https://legacy-docs-v1.rasa.com/1.10.8/core/interactive-learning/)
- [Fallback Actions](https://legacy-docs-v1.rasa.com/1.10.8/core/fallback-actions/)
- [Knowledge Base Actions](https://legacy-docs-v1.rasa.com/1.10.8/core/knowledge-bases/)

# Conversation Design

- [Dialogue Elements](https://legacy-docs-v1.rasa.com/1.10.8/dialogue-elements/dialogue-elements/)
- [Small Talk](https://legacy-docs-v1.rasa.com/1.10.8/dialogue-elements/small-talk/)
- [Completing Tasks](https://legacy-docs-v1.rasa.com/1.10.8/dialogue-elements/completing-tasks/)
- [Guiding Users](https://legacy-docs-v1.rasa.com/1.10.8/dialogue-elements/guiding-users/)

# API Reference

- [Action Server](https://legacy-docs-v1.rasa.com/1.10.8/api/action-server/)
- [HTTP API](https://legacy-docs-v1.rasa.com/1.10.8/api/http-api/)
- [Jupyter Notebooks](https://legacy-docs-v1.rasa.com/1.10.8/api/jupyter-notebooks/)
- [Agent](https://legacy-docs-v1.rasa.com/1.10.8/api/agent/)
- [Custom NLU Components](https://legacy-docs-v1.rasa.com/1.10.8/api/custom-nlu-components/)
- [Rasa SDK](https://legacy-docs-v1.rasa.com/1.10.8/api/rasa-sdk/)
- [Events](https://legacy-docs-v1.rasa.com/1.10.8/api/events/)
- [Tracker](https://legacy-docs-v1.rasa.com/1.10.8/api/tracker/)
- [Tracker Stores](https://legacy-docs-v1.rasa.com/1.10.8/api/tracker-stores/)
- [Event Brokers](https://legacy-docs-v1.rasa.com/1.10.8/api/event-brokers/)
- [Lock Stores](https://legacy-docs-v1.rasa.com/1.10.8/api/lock-stores/)
- [Training Data Importers](https://legacy-docs-v1.rasa.com/1.10.8/api/training-data-importers/)
- [Featurization of Conversations](https://legacy-docs-v1.rasa.com/1.10.8/api/core-featurization/)
- [TensorFlow Configuration](https://legacy-docs-v1.rasa.com/1.10.8/api/tensorflow_usage/)
- [Migration Guide](https://legacy-docs-v1.rasa.com/1.10.8/migration-guide/)
- [Rasa Open Source Change Log](https://legacy-docs-v1.rasa.com/1.10.8/changelog/)

# Migrate from (beta)

- [Dialogflow](https://legacy-docs-v1.rasa.com/1.10.8/migrate-from/google-dialogflow-to-rasa/)
- [Wit.ai](https://legacy-docs-v1.rasa.com/1.10.8/migrate-from/facebook-wit-ai-to-rasa/)
- [LUIS](https://legacy-docs-v1.rasa.com/1.10.8/migrate-from/microsoft-luis-to-rasa/)
- [IBM Watson](https://legacy-docs-v1.rasa.com/1.10.8/migrate-from/ibm-watson-to-rasa/)

# Reference

- [Glossary](https://legacy-docs-v1.rasa.com/1.10.8/glossary/)

# Versions

viewing: 1.10.8

# Policies

The `rasa.core.policies.Policy` class decides which action to take at every step in the conversation.

There are different policies to choose from, and you can include multiple policies in a single [`rasa.core.agent.Agent`](https://legacy-docs-v1.rasa.com/1.10.8/api/agent/#rasa.core.agent.Agent).

Note

Per default a maximum of 10 next actions can be predicted by the agent after every user message. To update this value you can set the environment variable `MAX_NUMBER_OF_PREDICTIONS` to the desired number of maximum predictions.

Your project’s `config.yml` file takes a `policies` key which you can use to customize the policies your assistant uses.

In the example below, the last two lines show how to use a custom policy class and pass arguments to it.

```yaml
policies:
  - name: "KerasPolicy"
    featurizer:
    - name: MaxHistoryTrackerFeaturizer
      max_history: 5
      state_featurizer:
        - name: BinarySingleStateFeaturizer
  - name: "MemoizationPolicy"
    max_history: 5
  - name: "FallbackPolicy"
    nlu_threshold: 0.4
    core_threshold: 0.3
    fallback_action_name: "my_fallback_action"
  - name: "path.to.your.policy.class"
    arg1: "..."
```

## Configuring Policies

One important hyperparameter for Rasa Core policies is the `max_history`.
This controls how much dialogue history the model looks at to decide which action to take next.

You can set the `max_history` by passing it to your policy’s `Featurizer` in the policy configuration yaml file.

Note

Only the `MaxHistoryTrackerFeaturizer` uses a max history, whereas the `FullDialogueTrackerFeaturizer` always looks at the full conversation history.

As an example, let’s say you have an `out_of_scope` intent which describes off-topic user messages. If your bot sees this intent multiple times in a row, you might want to tell the user what you can help them with. So your story might look like this:

```yaml
* out_of_scope
   - utter_default
* out_of_scope
   - utter_default
* out_of_scope
   - utter_help_message
```

For Rasa Core to learn this pattern, the `max_history` has to be at least 4.

If you increase your `max_history`, your model will become bigger and training will take longer. If you have some information that should affect the dialogue very far into the future, you should store it as a slot. Slot information is always available for every featurizer.

## Data Augmentation

When you train a model, by default Rasa Core will create longer stories by randomly gluing together the ones in your stories files. This is because if you have stories like:

```yaml
# thanks
* thankyou
   - utter_youarewelcome

# bye
* goodbye
   - utter_goodbye
```

You actually want to teach your policy to **ignore** the dialogue history when it isn’t relevant and just respond with the same action no matter what happened before.

You can alter this behavior with the `--augmentation` flag. Which allows you to set the `augmentation_factor`. The `augmentation_factor` determines how many augmented stories are subsampled during training.

## Action Selection

At every turn, each policy defined in your configuration will predict a next action with a certain confidence level. The bot’s next action is then decided by the policy that predicts with the highest confidence.

In the case that two policies predict with equal confidence, the priority of the policies is considered. Rasa policies have default priorities that are set to ensure the expected outcome in the case of a tie.

This priority hierarchy ensures that, for example, if there is an intent with a mapped action, but the NLU confidence is not above the `nlu_threshold`, the bot will still fall back.

## Keras Policy

The `KerasPolicy` uses a neural network implemented in [Keras](http://keras.io/) to select the next action. The default architecture is based on an LSTM, but you can override the `KerasPolicy.model_architecture` method to implement your own architecture.

```python
def model_architecture(self, input_shape: Tuple[int, int], output_shape: Tuple[int, Optional[int]]) -> tf.keras.models.Sequential:
    """Build a keras model and return a compiled model. """
    # Build Model
    model = Sequential()
    model.add(Masking(mask_value=-1, input_shape=input_shape))
    model.add(LSTM(self.rnn_size, dropout=0.2))
    model.add(Dense(units=output_shape[-1]))
    model.add(Activation("softmax"))
    model.compile(...)
    return model
```

You can implement the model of your choice by overriding these methods, or initialize `KerasPolicy` with pre-defined `keras model`.

## Embedding Policy

> Warning
> `EmbeddingPolicy` was renamed to `TEDPolicy`. Please use [TED Policy](https://legacy-docs-v1.rasa.com/1.10.8/core/policies/#ted-policy) instead of `EmbeddingPolicy` in your policy configuration. The functionality of the policy stayed the same.

## TED Policy

The Transformer Embedding Dialogue (TED) Policy has a pre-defined architecture...

## Mapping Policy

The `MappingPolicy` can be used to directly map intents to actions. The mappings are assigned by giving an intent the property `triggers`.

```yaml
intents:
 - ask_is_bot:
     triggers: action_is_bot
```

If you do not want your intent-action mapping to affect the dialogue history, the mapped action must return a `UserUtteranceReverted()` event...

## Memoization Policy

The `MemoizationPolicy` simply memorizes the conversations in your training data.

## Augmented Memoization Policy

The `AugmentedMemoizationPolicy` remembers examples from training stories for up to `max_history` turns...

## Fallback Policy

The `FallbackPolicy` invokes a [fallback action](https://legacy-docs-v1.rasa.com/1.10.8/core/fallback-actions/#fallback-actions) if certain conditions are met...

## Two-Stage Fallback Policy

The `TwoStageFallbackPolicy` handles low NLU confidence in multiple stages by trying to disambiguate the user input...

## Form Policy

The `FormPolicy` is an extension of the `MemoizationPolicy` which handles the filling of forms. Once a `FormAction` is called, the `FormPolicy` will continually predict the `FormAction` until all required slots in the form are filled.
