Tutorial: create, translate or update a chatbot#

🏁 Goal of this tutorial

By the end of this tutorial, you will know how to create or modify (eg to translate) a chatbot on your robot.


  • You must first read Dialogue management. It contains essential explaination about the RASA chatbot engine and the file structure.

Step 1: creating a new RASA model#

Let’s create a new RASA model for the Spanish language, so the robot can converse both in English and Spanish. We also want the robot to understand, in Spanish, “what is the capital of Germany?”.

First of all create a new RASA model directory, or if prefered, make a copy of the existing English chatbot. To make it easier, you can copy the folder to your machine from the robot. The new chatbot folder name should follow standard language codes, e.g. es_ES.


We follow the IETF language code: es_ES represents ‘Spanish from Spain’, while ca_ES would represent Catalan from Spain, and eg es_AR would represent Spanish as spoken in Argentina.

ssh pal@<robot>-0c
cd ~/.pal/chatbots-enabled/
cp -r en_GB es_ES

You can directly translate all the English content of the data/ folder to Spanish, if you wish the chatbot to be exactly the same as in English. If you are translating the chatbot to a new language, this is probably what you need.

In this case, you can directly jump to the Step 2: Train the new RASA model section.

But as we want to add a new question for the robot, we need to do more modifications.

As described in Dialogue management, each language model has a series of skills, for example:

  • chitchat: general smalltalk and questions

  • diagnostics: specific diagnostics questions (like the IP address of the robot, etc)

The question you want to ask may not fit either category. In this case, you can add a new skill, so that in the future you can add similar questions for the robot. Let’s create for instance a new geography chatbot.

Copy the same structure:

cp -r es_ES/chitchat es_ES/geography

Inside the data/ folder, update nlu.yml to include example ways to ask the question. Similar to chitchat, it is recommended to group all questions together, so whenever asks a geography related question the robot always replies. Intent name could be: geography/germany

version: "3.1"
- intent: geography/germany
  examples: |
    - cuál es la capital de Alemania?
    - capital de Alemania?

Update domain.yml by declaring the intent and example responses. As we are generalizing intent name it is enough to declare it once as geography.

It is important that the response follows the structure of utter_INTENT_NAME. It is recommended that intent and response names are language-independent.

version: '3.1'
- geography
    is_retrieval_intent: true
        - text: La capital es Berlin!
        - text: Berlin es la ciudad capital

Finally set-up the rule.yml so whenever a geography intent is detected, the corresponding response is returned:

version: "3.1"


- rule: response to geography question
- intent: geography
    - action: utter_geography

Step 2: Train the new RASA model#

First, you need to create a training configuration for your model (this only needs to be done the first time):

cd ~/.pal/chatbot_cfg/rasa-chatbots
cp -r en_GB es_ES
cd es_ES

Edit config.yml and replace 'language: en' by 'language: es'. Then:

rm data
ln -s ~/.pal/chatbots-enabled/es_ES/ data
rm models/*

Next, you can train the model:

cd ~/.pal/chatbot_cfg/rasa-chatbots/nl_NL
source /opt/pal/gallium/share/rasa/venv/bin/activate
export RASA_TELEMETRY_ENABLED=false # this is important! otherwise, you will get an error at the next step

Before training, you might want to validate your data, and clear all warning (otherwise, the training will fail):

rasa data validate --domain data

Then, you can train your model:

rasa train --domain data --fixed-model-name es_ES

This might take a few minutes.


You need to re-run this step every time you update the strings in your model.

You should now have a file models/es_ES.tar.gz. Congratulations, you have successfully trained your custom chatbot!

Step 3: Test your chatbot#

If previously the chatbot was in English, change it to Spanish language so it loads the latest model, by simply changing the current active language:

rosparam set /pal/language es_ES

Note it takes some time to load a new model. You can check the progress from the Diagnostics tab of the WebCommander.

Then, test the new chatbot by speaking to the robot and asking the questions you have included. The robot should say the expected responses.

If you wish to test the chatbot separately from the speech recognition, you can publish the expected input:

rostopic pub /humans/voices/anonymous_speaker/speech hri_msgs/LiveSpeech "header:
seq: 0
    secs: 0
    nsecs: 0
frame_id: ''
incremental: ''
final: 'capital de Alemania?'
confidence: 0.0"

The text-to-speech output can be monitored with:

rostopic echo /tts/goal

Next steps#

  • More advanced usage such as using RASA actions is covered in triggering-actions-from-rasa

  • You might also want to refer to the RASA documentation to learn about all the features and syntax supported by the chatbot engine.

  • If you want to know more speech recognition, continue with How-to: Automatic Speech Recognition (ASR)