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
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.
The recommended deployment methods described below make it easy to share your assistant with test users via the share your assistant feature in Rasa X. Then, when you’re ready to make your assistant available via one or more Messaging and Voice Channels, you can easily add them to your existing deployment set up.
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
Kubernetes/Openshift is the best option if you need a scalable architecture. It’s straightforward to deploy if you use the helm charts we provide. However, you can also customize the Helm charts if you have specific requirements.
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.
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
Then build a custom action using the Rasa SDK, e.g.:
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()
joke = request['value']['joke']
dispatcher.utter_message(text=joke)
return []
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
This pulls the image for the Rasa SDK which includes the action server, mounts your custom actions into it, and starts the server.
To instruct Rasa to use the action server you have to tell Rasa its location.
Add this to your endpoints.yml (if it does not exist, create it):
action_endpoint:
url: http://action_server:5055/webhook
Run docker-compose up to start the action server together with Rasa.
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.
Using PostgreSQL as Tracker Store
Start by adding PostgreSQL to your docker-compose file:
postgres:
image: postgres:latest
Then add PostgreSQL to the tracker_store section of your endpoint configuration config/endpoints.yml:
type: sql
dialect: "postgresql"
url: postgres
db: rasa
Using MongoDB as Tracker Store
Start by adding MongoDB to your docker-compose file:
mongo:
image: mongo
environment:
MONGO_INITDB_ROOT_USERNAME: rasa
MONGO_INITDB_ROOT_PASSWORD: example
Then add the MongoDB to the tracker_store section of your endpoints configuration endpoints.yml:
type: mongod
url: mongodb://mongo:27017
username: rasa
password: example