Categories
General

Rasa: Install an Open Source Chatbot

Rasa is a machine learning framework to automate text- and voice-based assistants. Rasa is open source and free of charge.

Rasa can be configured with Python and some yaml files. In this blog we take the first steps by installing the software on your laptop.

Prerequisite

For this tutorial we assume you have Anaconda installed on your Mac or Windows 10 laptop.

On Windows you need to perform an extra step, before you start installing the Rasa software in your Anaconda environment.

Windows users need to install visual C++ on their laptop, because Tensorflow needs that. Click on this link and wait for the download of VS_BuildTools to start.

Then install the software package: this gives a lot of options. Only choose the first check box on the first page: this installs the C++ libraries needed to run TensorFlow.
First check box is: Visual Studio Build Tools 2019 version 16.5.4 with the standard selected additional components.

Please note that the installation will take a while. When you are ready, reboot the computer.

1. Create environment

Choose or create a folder where you want to install Rasa and your first project. Then, open an Anaconda prompt, not an Anaconda Powershell prompt, to create an environment for Rasa to run in. And at the same time force the Python version you want to use. This will look something like this:

C:\Users\artyficial\Documents\Rasa\MyFirstRasa>
conda create --name installingrasa python==3.7.6

2. Activate environment

To activate the environment you just created, use:

conda activate installingrasa

After activation (base) has changed to (installingrasa).

To deactivate an active environment when you are ready, use:

conda deactivate

3. Install UltraJSON

UltraJSON is an ultra fast JSON encoder and decoder written in pure C with bindings for Python 2.7 and 3.5+.  To install it, type:

conda install ujson

4. Install TensorFlow

TensorFlow is used for the Machine Learning in Rasa. To install TensorFlow in Anaconda, type:

conda install tensorflow

5. Install Rasa

Install Rasa with pip, as there is currently no conda version available:

pip install rasa

6. Init Rasa

On the Anaconda prompt, type:

rasa init

Check the current directory, and choose no if you want to change that first and run the command again. Then choose yes to start.

You have started Rasa for the first time and it will run the Machine Learning algorithm once. Because you work with a limited test set, you can get the following message:

Warning: c:\users\artyficial\anaconda3\envs\installingrasa\lib\site-packages\rasa\utils\common.py:351: UserWarning: You specified 'DIET' to train entities, but no entities are present in the training data. Skip training of entities.

Ignore the warning and the program goes on, until you get the message:

Your Rasa model is trained and saved at 'C:\Users\artyficial\Documents\Rasa\MyFirstRasa\models\20200430-184313.tar.gz'.

Now you chatbot works! You can have very limited conversations with it as it is not trained yet, but you can ask: “How are you?”

If the chatbot asks: “How are you?”, you can respond with: “I am very sad today”. The response is: “Maybe this will cheer you up:”
https://i.imgur.com/nGF1K8f.jpg

7. Quit Rasa

After installation and testing, the last step is to stop the program from running. On the command line type:

/stop