Bot Deployment Environments

Rasa Platform lets you run multiple Rasa Core and NLU models in parallel, allowing you to test different environments promoting them to production. In this section we’ll show you how to

  1. Launch additional Rasa Core and NLU servers that run your models
  2. Make the additional servers accessible in the /conversations tab
  3. Assign tags to the Rasa Core and NLU models so they’re run by the right server

Starting additional Rasa Core and NLU Servers

By default, Rasa Platform runs three servers for both Rasa Core and NLU: one that should be used in production, one for development and one that executes certain tasks like training and evaluating models. Let’s look at an example where we add a fourth Rasa Core server in addition to the predefined core, core-worker, and core-development servers. Let’s call it core-experimental. Create a file called docker-compose.override.yml in /etc/rasaplatform containing the following:

version: "3.4"

x-core-services: &default-core-service
  restart: always
  image: "rasa/rasa_core:${CORE_VERSION:-stable}"
  volumes:
  - ./credentials.yml:/app/credentials.yml
  - ./core_endpoints.yml:/app/endpoints.yml
  expose:
  - "5005"
  command: >
    start
    -p 5005
    --endpoints endpoints.yml
    --credentials credentials.yml
    --jwt_method HS256
    --jwt_secret ${JWT_SECRET}
    --auth_token '${RASA_CORE_TOKEN}'
    -u default/
    -d core-models
    --cors "*"
  depends_on:
  - api
  - event-service

x-mongo-credentials: &mongo-credentials
  MONGO_HOST: "mongodb://mongo:27017"
  MONGO_USERNAME: "admin"
  MONGO_PASSWORD: ${MONGO_PASSWORD}

x-rabbitmq-credentials: &rabbitmq-credentials
  RABBITMQ_HOST: "rabbit"
  RABBITMQ_USERNAME: "admin"
  RABBITMQ_PASSWORD: ${RABBITMQ_PASSWORD}

x-nlu-credentials: &nlu-credentials
  RASA_NLU_HOST: "http://nlu:5000"
  RASA_NLU_TOKEN: ${RASA_NLU_TOKEN}
  RASA_NLU_MODEL_DIR: "/app/nlu-models"

x-platform-credentials: &platform-credentials
  RASA_PLATFORM_HOST: ${RASA_PLATFORM_HOST:-http://api:5002}
  RASA_PLATFORM_TOKEN: ${RASA_PLATFORM_TOKEN}
  JWT_SECRET: ${JWT_SECRET}
  RASA_USER_APP: "http://app:5001"
  RASA_NLG_ENDPOINT_URL: ${RASA_PLATFORM_HOST:-http://api:5002}/nlg

x-core-credentials: &core-credentials
  <<: *mongo-credentials
  <<: *rabbitmq-credentials
  <<: *nlu-credentials
  <<: *platform-credentials
  RASA_CORE_TOKEN: ${RASA_CORE_TOKEN}
  RASA_CORE_MODEL_PULL_INTERVAL: 10

Right below, make an entry for the new Core service core-development:

services:
  core-experimental:
    <<: *default-core-service
    environment:
      <<: *core-credentials
      RABBITMQ_QUEUE: "core_experimental_events"
      RASA_CORE_MODEL_SERVER: ${RASA_PLATFORM_HOST:-http://api:5002}/projects/default/models/core/tags/experimental
      MONGO_DB: "core-experimental"

It’s important that the RABBITMQ_QUEUE and MONGO_DB variables are unique, and that RASA_CORE_MODEL_SERVER requests a unique tag, in this case experimental.

The process for adding additional NLU servers is similar: To add a new nlu-experimental service, add the following code to the services section in your docker-compose.override.yml:

nlu-experimental:
  <<: *default-nlu-service
  environment:
    <<: *platform-credentials
    <<: *nlu-credentials
    RASA_DUCKLING_HTTP_URL: "http://duckling:8000"
    RASA_NLU_MODEL_SERVER: ${RASA_PLATFORM_HOST:-http://api:5002}/projects/default/models/nlu/tags/experimental
    MONGO_DB: "nlu-experimental"

Updating the environments config

We need to let Rasa Platform know about the newly defined Rasa Core and NLU servers, so that you can talk to the models running on it in the /conversations view. Following the example of our core-experimental service, add an entry to your environments settings in the Platform:

core:
  production: (...)
  development: (...)
  experimental:
    url: http://core-experimental:5005
    token: ${RASA_CORE_TOKEN}
    db: core-experimental

The hostname part of url has to match the service name defined in docker-compose.override.yml (in this case core-experimental). The db entry has to be the same as the entry for MONGO_DB above.

Note

By default, all Core and NLU servers share the same token, but you are free to define a separate token for each service. To achieve this, replace ${RASA_CORE_TOKEN} or ${RASA_NLU_TOKEN} above with your <TOKEN>, and add an entry in the environments section of the new service in docker-compose.override.yml: RASA_CORE_TOKEN: "<TOKEN>".

Tagging a model

The final step is to upload a Rasa Core or NLU model and assign the right tag. Instructions on uploading Core models can be found in the docs section on how to Add a Rasa Core Model. You can read up on how to add Rasa NLU models here: Add NLU data and train a model. You can tag your uploaded or trained model in Rasa Platform, making it available to one of the available deployment environments.