Connect a Rasa Deployment

Rasa X helps you improve your assistant by leveraging real conversations. If you’re already running a Rasa Open Source deployment, you can simply connect it to Rasa X to annotate conversations - even if it’s running on a separate system.

To achieve this, you have two options:

  1. Import historical conversations from your Rasa Open Source deployment into Rasa X
  2. Automatically forward all new incoming messages directly from Rasa Open Source to Rasa X

1. Import Existing Conversations from Rasa Open Source

In order to annotate conversations users have already had with a live Rasa Open Source deployment, you can import conversations from your current tracker store into Rasa X.

Rasa Open Source Configuration

Open the .env file in your Rasa X installation directory (/etc/rasa by default) and make a note of the following values: RABBITMQ_PASSWORD, RABBITMQ_USERNAME, RABBITMQ_QUEUE. If you’ve deployed Rasa X in a cluster using Helm, Kubernetes or OpenShift, check out Accessing Secrets.

Now go to your Rasa Open Source deployment and note down the following values used in your Rasa tracker store: the database username, the database password and the name of the database.

On a different machine, create a new file called endpoints.yml (alternatively you can go to your project directory in your Rasa Open Source deployment and modify the existing endpoints.yml there).

In this file, create two sections defining the tracker store from which to import conversations, as well as the event broker that’s used to move the conversations from your Rasa Open Source deployment to Rasa X. You will forward historical events in your Rasa Open Source deployment to the Rasa X event broker. RabbitMQ is used as the message broker for Rasa X, so we will use the Pika Python configuration in the Rasa endpoints.yml.

Create the following two entries in endpoints.yml, using the values copied from the .env file in your Rasa X deployment:

tracker_store:
  type: sql
  dialect: <your Rasa Open Source deployment's SQL dialect, e.g. "postgresql">
  url: <your Rasa Open Source URL, e.g. rasa.mydomain.com>
  username: <tracker database username in your Rasa Open Source deployment>
  password: <tracker database password in your Rasa Open Source deployment>
  db: <name of the tracker database in your Rasa Open Source deployment>

event_broker:
  type: "pika"
  url: <your rasa X deployment domain, e.g. rasax.mydomain.com>
  username: <value of RABBITMQ_USERNAME>
  password: <value of RABBITMQ_PASSWORD>
  queue: <value of RABBITMQ_QUEUE>

Migrate Conversations

You can use Rasa’s rasa export command-line tool to export conversations from the tracker database to an event broker. From there, your running Rasa X deployment will consume the events and save them to your Rasa X database.

Head to the same directory as your endpoints.yml file from above. To export all conversations contained in the tracker database, simply run

rasa export

The rasa export command allows you to specify a subset of conversation IDs to export, or restrict the time range of events. Just run rasa export --help for an overview of options, or check out the Rasa CLI docs on rasa export.

You can now log in to your Rasa X deployment and view the migrated conversations.

2. Connect a Live Rasa Open Source Deployment

This configuration allows Rasa X to monitor conversations taking place in the live Rasa Open Source deployment environment without modifying the deployment architecture.

These instructions assume Rasa Open Source and Rasa X are deployed and running on two separate systems.

Rasa X Configuration

Open the .env file in your Rasa X installation directory (/etc/rasa by default) and make a note of the following values: RABBITMQ_PASSWORD, RABBITMQ_USERNAME, RABBITMQ_QUEUE. If you’ve deployed Rasa X in a cluster using Helm, Kubernetes or OpenShift, check out Accessing Secrets. We will need these when configuring the event broker on the Rasa Open Source server.

You also need to allow external access to the event broker port. To do this, add the following block to your docker-compose.override.yml:

version: '3.4'
services:
  rabbit:
    ports:
      - "5672:5672"

Now, restart the RabbitMQ service with the docker-compose restart rabbit command.

Rasa Open Source Configuration

You need to configure your Rasa Open Source deployment to forward messages to the Rasa X event broker. The configuration is done in the endpoints.yml file which can be found in the Rasa project directory. Configure the event_broker section as described in Rasa Open Source Configuration (you do not need to modify the tracker store section).

Once you’ve updated the endpoints.yml file, restart the Rasa server.

If verbose logging is on using the --debug option, you should see the following messages in the Rasa logs indicating that messages are being forwarded to Rasa X:

rasa-production_1  | 2020-01-13 13:18:17 DEBUG    rasa.core.brokers.pika  - RabbitMQ connection to 'rasax.mydomain.com' was established.
rasa-production_1  | 2020-01-13 13:20:52 DEBUG    rasa.core.brokers.pika  - Published Pika events to queue 'rasa_production_events' on host 'rasax.mydomain.com':

You can now log into Rasa X and view conversations from your users as they come in. For further information on what to do with them, check out Review Conversations and Improve Assistant.