DEV Community

loading...
Cover image for RASA - Installing Rasa and creating a project

RASA - Installing Rasa and creating a project

Petr Janik
I'm a student of applied informatics at Masaryk University in Brno. I love coding, especially in React, Java and Python.
Updated on ・3 min read

Installing Rasa

Rasa requires Python 3.6, 3.7 or 3.8. You can download Python here if you don't already have it installed.
To find out, which version of Python you have installed, execute:

python --version
Enter fullscreen mode Exit fullscreen mode

Next, create a new folder named rasa-dev-tutorial.

mkdir rasa-dev-tutorial
cd rasa-dev-tutorial
Enter fullscreen mode Exit fullscreen mode

Because we don't want to instal our project dependencies on a system level, we will create a virtual environment.

python -m venv venv
Enter fullscreen mode Exit fullscreen mode

This will create a folder venv inside our project's folder.
Activate the virtual environment by running:

source venv/bin/activate
Enter fullscreen mode Exit fullscreen mode

(You can deactivate the virtual environment by running deactivate if you later need to.)

Next, install Rasa.

pip install rasa
Enter fullscreen mode Exit fullscreen mode

If you need further help during the installation process, check out the Rasa documentation.

To create a basic Rasa project, run:

rasa init
Enter fullscreen mode Exit fullscreen mode

During the installation, you will be asked where to initialize the project. Hit enter to initialize the project in the current folder. Press y when you are asked if it's okay that the folder already contains files.
A chatbot called Moodbot has been created.
You can try chatting with it for a while.
Type /stop to exit the chat.
This step provided us with the right folder structure and files we will need in the next steps.

Versioning your project

Feel free to skip this part if you are familiar with git.
If you want to make this a git repository (strongly advised, this will allow us to version our code), run git init and create a file .gitignore with the following contents:

venv
# exclude everything from models folder
models/*
# except for .gitkeep, so that the folder itself is included
!models/.gitkeep
Enter fullscreen mode Exit fullscreen mode

This will tell git to ignore virtual environment folder and models in models folder (models can be quite large, we will store them later on using GitHub Actions).

If anyone then clones the repository, they need to know which Python modules you used. Those are usually written in file requirements.txt. Create this file by running:

pip freeze > requirements.txt
Enter fullscreen mode Exit fullscreen mode

Add all files (that are not ignored) to git and commit them:

git add .
git commit -m "Bootstrap project"
Enter fullscreen mode Exit fullscreen mode

You can push your code to GitHub to safely store it and to be able to access it from anywhere. Create a new repository on GitHub named rasa-dev-tutorial.
Then, in your terminal in your project folder, run:

git remote add origin git@github.com:<username>/rasa-dev-tutorial.git
git push --set-upstream origin master
Enter fullscreen mode Exit fullscreen mode

Don't forget to replace the <username> with your own GitHub username.
If you or anyone else wants to clone the repository, all they have to do is:

git clone git@github.com:<username>/rasa-dev-tutorial.git
cd rasa-dev-tutorial
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Enter fullscreen mode Exit fullscreen mode

Basic command line commands

To see a list of available Rasa commands, run:

rasa --help
Enter fullscreen mode Exit fullscreen mode

We have already met rasa init command, which creates a new project with example training data, actions, and config files.

To chat with the chatbot, you have to first train it using rasa train and then start a chat in the terminal using rasa shell.

In the next chapter, we will look at the individual files that have been created and do some modifications to our chatbot.

Repository for this tutorial:

You can checkout the state of the repository at the end of this tutorial by running:

git clone --branch 01-creating-project git@github.com:petr7555/rasa-dev-tutorial.git
Enter fullscreen mode Exit fullscreen mode

Discussion (0)