RASA AI Integration

Integrating Rasa with Tiledesk offers many advantages, first of all the possibility to deflect RASA conversations to human agents, a mandatory task in today's chatbot integration design. Chatbots indeed cannot always satisfy every user request or, sometimes, a chatbot was there only to welcome the user, get the first question and then choosing the right human agent to forward the request to.

RASA is an open source platform tu build, train and deploy your own chatbots. Tiledesk is an open source integration platform for chatbots and humans. It's a common task today the option to deflect a chatbot conversation to humans, for many reasons. This is when connecting Tiledesk and RASA becomes the handy tool you was searching for. Simply switch from RASA to Tiledesk using directive that best suits your deflecting needs.  

Connect your RASA server

In this document we suppose you already have a RASA server up and running. If you don't have one or you need to better understand what RASA is and how it works, please refer to the official RASA website.

In Tiledesk you can easily connect your RASA server just using the UI, without a single line of code.

NOTE: Anyway, if you are a developer and you need to maximize control over your RASA integration you can always use our programmatic integration through external chatbots. You can find how in our programmatic RASA integration tutorial. Alternatively you can also refer to this Connector source code available on Github.

Create a new Project

To use Tiledesk APIs or integrate your own chatbots is mandatory to signup a new user on Tiledesk. Then go to the console, available on the following link https://console.tiledesk.com/v2/dashboard

After signup please follow the proposed wizard to create your first Tiledesk project.

We choosed "Connect RASA" as Project name:

 

As soon as you create the project you will be redirected to the project home (for this tutorial you can jump the next tutorial's steps).

Create your chatbot

As first step we will create a RASA chatbot connection.

Select the chatbot icon on the left menu, then press the "ADD BOT" button:

In the next chatbot selection window choose RASA:

And RASA connection form appears. Choose a name for your chatbot, then fillout the RASA URL field with your RASA Server webhooks endpoint (more details about the webhooks RASA connection mode).

Now press the CREATE BOT button. The bot is created, and a popup appears asking you if you want to “Activate the bot”:

Choose “Activate bot”. Activating the bot simply makes the chatbot available for the incoming conversations. From now on it will be the chatbot that will great the user as soon as he starts a new conversation and will be the chatbot to reply to his questions.

To test the RASA chatbot connection you can press the Simulate visitor button, in the Project's top bar:

A minimalist website will appear with just the widget installed that you can use to test your chatbot. Open the widget pressing the button:

Press “New conversation” to start a conversation. If your RASA server is up and running your chatbot will greet you as soon as the conversation starts:

 

Customize your “welcome message”

You want to get a custom welcome message as soon as a conversation starts. To correctly address this task you must train your RASA server to understand the welcome intent. Every time a new conversation starts and there is a chatbot as the department's receptionist, a hidden message is sent to the chatbot. This message contains a “\start” text.

You must train your RASA server to reply to this message, having your personal welcome message getting sent to the end-user.

In your RASA server folder open nlu.yml and add a couple of training phrases to the “greet” intent, just like in the follo wing example we added “\start” and “start”:

After this we can modify the domain.yml file, adding the reply phrase corresponding to the greet intent (see figure):

 

We added a reply for the greet intent, trained with the Tiledesk welcome trigger phrases - "\start" and “start”. RASA will reply with the text:

Welcome to RASA Connector

Choose an option    
* Help Center https://gethelp.tiledesk.com/    
* I want an agent

As soon as you start a new conversation…

Rasa will reply with a beautiful message, splitted in a couple of messages (RASA automatically “splits” a message based on a couple of "\n\n" as a message separator, and the Tiledesk RASA connector supports this formatting).

The message is followed by a couple of buttons. The first button is a “link” button, while the second is a “Quick reply” button.

To render these buttons you can see that we didn't use any particular magic. We just used the classic markdown bullet list synthax, that Tiledesk intelligently renders as buttons. The Tiledesk specific synthax is called “markbot”, and it is a special tagging language (similar in concept to the markdown tagging language) that allows you to simply send common message controls or contents to the communication channel. The synthax is channel-adaptive and will be rendered accordingly to the channel abilities to support certain controls.

Deflect conversation to a human agent

Let's add an intent now, with the purpose to explicitly deflect a conversation from the RASA chatbot to a human agent whenever the end-user feels he can't go on with the AI.

To correctly address this task we must train your RASA server to understand a phrase that will explicitly trigger the human handoff. We will also add a Quick Reply button to address this opportunity faster for the user, because pressing a button is surely better then guessing the right words to trigger the right intent :)

You must train your RASA server to reply to a message like “I want an agent” (or something similar), letting a reply message fly back to the end-user (carrying the special “\agent” directive that allows the desired handoff).

Open {RASA FOLDER}/data/nlu.yml. Add the agent intent, as in the following picture.

The nlu.yml train snippet (The agent intent):

- intent: agent
examples: |
  - I want an agent
  - Speak to agent

Now move to the rules.yml and add the last rule to connect the intent to the action

rules.yml train snippet:

- rule: Deflect to agent
 steps:
 - intent: agent
 - action: utter_agent

Later open {RASA FOLDER}/domain.yml. Add the following lines of code to make RASA know how to reply to the agent intent.

domain.yml source snippet:

intents:
 - greet
 - goodbye
 - affirm
 - deny
 - mood_great
 - mood_unhappy
 - bot_challenge
 - agent

responses:
 utter_agent:
 - text: "Moving you to an agent\n\\agent"

The main point for agent deflection is in the \agent directive. Tiledesk supports many directives to execute some tasks when a chatbot replies to a user. The \agent directive handoff the conversation to a human agent using the corrispondent department rules (i.e. Assigned or Pooled). You must place the directive on a new line to get it recognized.

Now that we added the new “agent” intent we can get rid ot the “start” intent showing a “I want agent” Quick Reply. It directly points to the “agent” intent. Let's see it in action.

All of this stuff is also available on the open source version on Tiledesk. Just install Tiledesk platform using the docker compose distribution.

If you have any problems do not esitate to write us on our Community forum!

Do you have suggestions on this article? Please send us your feedback writing an email to info@tiledesk.com

Tiledesk is free on both sides of story! While we are free and open source software - the tech side - we also provide our forever free account - the online service side - to enable connecting your chatbots and human agents togheter with your end-users for the best customer service experience. Run on Tiledesk and signup to create your FOREVER FREE account!