Deploying your Rasa Assistant
Deploying your Rasa Assistant
This page explains when and how to deploy an assistant built with Rasa. It will allow you to make your assistant available to users and set you up with a production-ready environment.
When to deploy your assistant
Recommended Deployment Methods
Kubernetes/Openshift
- Docker Compose
Rasa-Only Deployment with Docker Compose
When to deploy your assistant
The best time to deploy your assistant and make it available to test users is once it can handle the most important happy paths or is what we call a minimum viable assistant.
Recommended Deployment Methods
The recommended way to deploy an assistant is using either the Docker Compose or Kubernetes/Openshift options we support. Both deploy Rasa X and your assistant. They are the easiest ways to deploy your assistant, allow you to use Rasa X to view conversations and turn them into training data, and are production-ready.
Kubernetes/Openshift
- Default: Read the docs here.
- Custom: Read the docs here and customize the open source Helm charts.
Docker Compose
Rasa-Only Deployment with Docker Compose
It is also possible to deploy a Rasa assistant using Docker Compose without Rasa X.
- Installing Docker
- Building an Assistant with Rasa and Docker
- Customizing your Model
Installing Docker
If you’re not sure if you have Docker installed, you can check by running:
docker -v && docker-compose -v
# Docker version 18.09.2, build 6247962
# docker-compose version 1.23.2, build 1110ad01
Building an Assistant with Rasa and Docker
This section will cover the following:
- Setting up your Rasa project and training an initial model
- Talking to your AI assistant via Docker
- Choosing a Docker image tag
- Training your Rasa models using Docker
- Talking to your assistant using Docker
- Running a Rasa server with Docker
Setup
Just like in the tutorial, you’ll use the rasa init command to create a project.
docker run -v $(pwd):/app rasa/rasa init --no-prompt
To check that the command completed correctly, look at the contents of your working directory:
ls -1
The initial project files should all be there, as well as a models directory that contains your trained model.
Talking to Your Assistant
To talk to your newly-trained assistant, run this command:
docker run -it -v $(pwd):/app rasa/rasa shell
Customizing your Model
Choosing a Tag
To keep images as small as possible, we publish different tags of the rasa/rasa image with different dependencies installed. See Choosing a Pipeline for more information about dependencies.
Training a Custom Rasa Model with Docker
Edit the config.yml file to use the pipeline you want, and place your NLU and Core data into the data/ directory. Now you can train your Rasa model by running:
docker run \
-v $(pwd):/app \
rasa/rasa:latest-full \
train \
--domain domain.yml \
--data data \
--out models
Running the Rasa Server
To run your AI assistant in production, configure your required Messaging and Voice Channels in credentials.yml. If this file does not exist, create it using:
touch credentials.yml
Then edit it according to your connected channels. After, run the trained model with:
docker run \
-v $(pwd)/models:/app/models \
rasa/rasa:latest-full \
run
Using Docker Compose to Run Multiple Services
To run Rasa together with other services, such as a server for custom actions, it is recommended to use Docker Compose.
Start by creating a file called docker-compose.yml:
touch docker-compose.yml
Add the following content to the file:
version: '3.0'
services:
rasa:
image: rasa/rasa:latest-full
ports:
- 5005:5005
volumes:
- ./:/app
command:
- run
Adding Custom Actions
To create more sophisticated assistants, you will want to use Custom Actions.
Creating a Custom Action
Start by creating the custom actions in a directory actions:
mkdir actions
# Rasa SDK expects a python module.
# Therefore, make sure that you have this file in the directory.
touch actions/__init__.py
touch actions/actions.py
Adding the Action Server
The custom actions are run by the action server. To spin it up together with the Rasa instance, add a service action_server to the docker-compose.yml:
version: '3.0'
services:
rasa:
image: rasa/rasa:latest-full
ports:
- 5005:5005
volumes:
- ./:/app
command:
- run
action_server:
image: rasa/rasa-sdk:latest
volumes:
- ./actions:/app/actions
Adding Custom Dependencies
If your custom action has additional dependencies of systems or Python libraries, you can add these by extending the official image.
Adding a Custom Tracker Store
By default, all conversations are saved in memory. This means that all conversations are lost as soon as you restart the Rasa server. If you want to persist your conversations, you can use a different Tracker Store.