# Training Data Importers

These docs are for version 1.x of Rasa Open Source. [Docs for the new version 2.0 can be found here.](/content/docs/rasa/index.html)

## Overview
By default, you can use command line arguments to specify where Rasa should look for training data on your disk. Rasa then loads any potential training files and uses them to train your assistant.

If needed, you can also customize how Rasa imports training data. Potential use cases for this might be:
- Using a custom parser to load training data in other formats
- Using different approaches to collect training data (e.g. loading them from different resources)

You can instruct Rasa to load and use your custom importer by adding the section `importers` to the Rasa configuration file and specifying the importer with its full class path:

```yaml
importers:
- name: "module.CustomImporter"
  parameter1: "value"
  parameter2: "value2"
- name: "module.AnotherCustomImporter"
```

The `name` key is used to determine which importer should be loaded. Any extra parameters are passed as constructor arguments to the loaded importer.

### RasaFileImporter (default)
By default Rasa uses the importer `RasaFileImporter`. If you want to use it on its own, you don’t have to specify anything in your configuration file. If you want to use it together with other importers, add it to your configuration file:

```yaml
importers:
- name: "RasaFileImporter"
```

### MultiProjectImporter (experimental)
With this importer you can build a contextual AI assistant by combining multiple reusable Rasa projects. You might, for example, handle chitchat with one project and greet your users with another. These projects can be developed in isolation and then combined at train time to create your assistant.

An example directory structure could look like this:

```
.
├── config.yml
└── projects
    ├── GreetBot
    │   ├── data
    │   │   ├── nlu.md
    │   │   └── stories.md
    │   └── domain.yml
    └── ChitchatBot
        ├── config.yml
        ├── data
        │   ├── nlu.md
        │   └── stories.md
        └── domain.yml
```

During the training process Rasa will import all required training files, combine them, and train a unified AI assistant. The merging of the training data happens during runtime, so no additional files with training data are created or visible.

**Note**: Rasa will use the policy and NLU pipeline configuration of the root project directory during training. **Policy or NLU configurations of imported projects will be ignored.**

### Writing a Custom Importer
If you are writing a custom importer, this importer has to implement the interface of [TrainingDataImporter](https://legacy-docs-v1.rasa.com/1.7.3/api/training-data-importers/#training-data-importers-trainingfileimporter):

```python
from typing import Optional, Text, Dict, List, Union

import rasa
from rasa.core.domain import Domain
from rasa.core.interpreter import RegexInterpreter, NaturalLanguageInterpreter
from rasa.core.training.structures import StoryGraph
from rasa.importers.importer import TrainingDataImporter
from rasa.nlu.training_data import TrainingData

class MyImporter(TrainingDataImporter):
    """Example implementation of a custom importer component."""

def __init__(self, config_file: Optional[Text] = None, domain_path: Optional[Text] = None, training_data_paths: Optional[Union[List[Text], Text]] = None, **kwargs: Dict):
        pass

async def get_domain(self) -> Domain:
        pass

async def get_stories(self, interpreter: "NaturalLanguageInterpreter" = RegexInterpreter(), template_variables: Optional[Dict] = None, use_e2e: bool = False, exclusion_percentage: Optional[int] = None) -> StoryGraph:
        pass

async def get_config(self) -> Dict:
        pass

async def get_nlu_data(self, language: Optional[Text] = "en") -> TrainingData:
        pass
```

### TrainingDataImporter
_class_ `rasa.importers.importer.TrainingDataImporter`
Common interface for different mechanisms to load training data.

- **_async_ `get_domain()`**: Retrieves the domain of the bot. Returns loaded `Domain`.
- **_async_ `get_config()`**: Retrieves the configuration that should be used for the training. Returns the configuration as dictionary.
- **_async_ `get_nlu_data(language='en')`**: Retrieves the NLU training data that should be used for training. Returns loaded NLU `TrainingData`.
- **_async_ `get_stories(...)`**: Retrieves the stories that should be used for training. Returns `StoryGraph` containing all loaded stories.
