You are viewing documentation for our open source project which is maintained by the community. If you want to get started building assistants with Rasa please check out our latest [documentation here](/content/docs/index.html).

If you don't have a Rasa project yet, you can build one in Docker without having to install Rasa on your local machine. If you already have a model you're satisfied with, see [Deploying a Rasa Assistant](https://legacy-docs-oss.rasa.com/docs/rasa/deploy/introduction) to learn how to deploy your model.

## Installing Docker 
If you're not sure if you have Docker installed, you can check by running:

```bash
docker -v
```

If Docker is installed on your machine, the output should show you your installed versions of Docker. If the command doesn't work, you'll have to install Docker. See [Docker Installation](https://docs.docker.com/install/) for details.

## Setting up your Rasa Project 
Just like starting a project from scratch, you'll use the `rasa init` command to create a project. The only difference is that you'll be running Rasa inside a Docker container, using the image `rasa/rasa`. To initialize your project, run:

```bash
docker run -v $(pwd):/app rasa/rasa:3.6.20-full init --no-prompt
```

### What does this command mean?
- `-v $(pwd):/app` mounts your current working directory to the working directory in the Docker container. This means that files you create on your computer will be visible inside the container, and files created in the container will get synced back to your computer.
- `rasa/rasa` is the name of the docker image to run. '3.6.20-full' is the name of the tag, which specifies the version and dependencies.
- The Docker image has the `rasa` command as its entrypoint, which means you don't have to type `rasa init`, just `init` is enough.

Running this command will produce a lot of output. What happens is:
- A Rasa project is created
- An initial model is trained using the project's training data.

To check that the command completed correctly, look at the contents of your working directory:

```bash
ls -1
```

The initial project files should all be there, as well as a `models` directory that contains your trained model.

**Note:** If you run into permission errors, it may be because the `rasa/rasa` images run as user `1001` as a best practice, to avoid giving the container `root` permissions. Hence, all files created by these containers will be owned by user `1001`. See the [Docker documentation](https://docs.docker.com/reference/cli/docker/container/run/) if you want to run the containers as a different user.

## Talking to Your Assistant 
To talk to your newly-trained assistant, run this command:

```bash
docker run -it -v $(pwd):/app rasa/rasa:3.6.20-full shell
```

This will start a shell where you can chat to your assistant. Note that this command includes the flags `-it`, which means that you are running Docker interactively, and you are able to give input via the command line.

## Training a Model 
If you edit any training data or edit the `config.yml` file, you'll need to retrain your Rasa model. You can do so by running:

```bash
docker run -v $(pwd):/app rasa/rasa:3.6.20-full train --domain domain.yml --data data --out models
```

### Here's what's happening in that command:
- `-v $(pwd):/app`: Mounts your project directory into the Docker container so that Rasa can train a model on your training data
- `rasa/rasa:3.6.20-full`: Use the Rasa image with the tag '3.6.20-full'
- `train`: Execute the `rasa train` command within the container. For more information see [Command Line Interface](https://legacy-docs-oss.rasa.com/docs/rasa/command-line-interface).

In this case, we've also passed values for the location of the domain file, training data, and the models output directory to show how these can be customized. You can also leave these out, since we are passing the default values.

## Customizing your Model 
### Choosing a Tag 
All `rasa/rasa` image tags start with a version number. The current version is 3.6.20. The tags are:
- `{version}`
- `{version}-full`
- `{version}-spacy-en`
- `{version}-spacy-de`
- `{version}-spacy-it`
- `{version}-mitie-en`

The `{version}-full` tag includes all possible pipeline dependencies, allowing you to change your `config.yml` as you like without worrying about missing dependencies. The plain `{version}` tag includes all the dependencies you need to run the default pipeline created by `rasa init`.

If your model has a dependency that is not included in any of the tags (for example, a different spaCy language model), you can build a docker image that extends the `rasa/rasa` image.

### Adding Custom Components 
If you are using a custom NLU component or policy in your `config.yml`, you have to add the module file to your Docker container. You can do this by either mounting the file or by including it in your own custom image (e.g. if the custom component or policy has extra dependencies). Make sure that your module is in the Python module search path by setting the environment variable `PYTHONPATH=$PYTHONPATH:<directory of your module>`.

### Adding Custom Actions 
To create more sophisticated assistants, you will want to use [Custom Actions](https://legacy-docs-oss.rasa.com/docs/rasa/actions#custom-actions). Continuing the example from above, you might want to add an action which tells the user a joke to cheer them up.

Build a custom action using the Rasa SDK by editing `actions/actions.py`, for example:

```python
import requests
import json
from rasa_sdk import Action

class ActionJoke(Action):
    def name(self):
        return "action_joke"

def run(self, dispatcher, tracker, domain):
        request = requests.get('http://api.icndb.com/jokes/random').json()  # make an api call
        joke = request['value']['joke']  # extract a joke from returned json response
        dispatcher.utter_message(text=joke)  # send the message back to the user
        return []
```

In `data/stories.yml`, replace `utter_cheer_up` in with the custom action `action_joke` to tell your bot to use this new action.

In `domain.yml`, add a section for custom actions, including your new action:

```yaml
actions:
- action_joke
```

After updating your domain and stories, you have to retrain your model:

```bash
docker run -v $(pwd):/app rasa/rasa:3.6.20-full train
```

Your actions will run on a separate server from your Rasa server. First create a network to connect the two containers:

```bash
docker network create my-project
```

You can then run the actions with the following command:

```bash
docker run -d -v $(pwd)/actions:/app/actions --net my-project --name action-server rasa/rasa-sdk:3.6.2
```

### Here's what's happening in that command:
- `-d`: Runs the container in detached mode so that you can run the rasa container in the same window.
- `-v $(pwd):/app`: Mounts your project directory into the Docker container so that the action server can run the code in the `actions` folder
- `net my-project`: Run the server on a specific network so that the rasa container can find it
- `--name action-server`: Gives the server a specific name for the rasa server to reference
- `rasa/rasa-sdk:3.6.2`: Uses the Rasa SDK image with the tag 3.6.2

### Deployment
Work on your bot until you have a minimum viable assistant that can handle your happy paths. After that, you'll want to deploy your model to get feedback from real test users. To do so, you can deploy the model you created via one of our [recommended deployment methods](https://legacy-docs-oss.rasa.com/docs/rasa/deploy/introduction#recommended-deployment-method).
