Skip to Content
Author's profile photo Dean Mathews

Using Recast.AI To Create A Simple Conversational Bot

This article is continuation of Adding Chat Bot To A Website Using SAP Web IDE – Part One.  In the first article we explored setting up Web IDE and preparing to integrate a chat bot.

In this article we will create a super simple conversational bot using Recast.AI.  In a subsequent article I will show you how to integrate your bot into the previously prepared Web IDE website.

If you have done your research on bots you may be a bit overwhelmed as the information is plentiful yet very diverse.  Basically a bot is a computer that a person either speaks directly to or types into using natural language. For instance you may say or type “How does the weather look like next week”, the bot will perform these basic high level operations…

  1. Parse your input (text or speech)
  2. Determine that you are asking about the weather
  3. Determine that you are interested in the weather for next week
  4. You did not specify a location, so it will lookup your current location
  5. Use your current location and next weeks date ranges to access a weather endpoint
  6. Convert the weather data to easy to read text or speech
  7. Respond to your question

Creating Your First Super Simple Chatbot

Here I will go over how to create an extremely basic bot to detect the mood of the user.  This is intended strictly for demonstration purposes. I would not recommend using these responses in a production system – I’m not much of a therapist so please excuse any not so great responses.

Please keep in mind that I am new to bots and this is my first time using Recast.AI.  It took about an hour to get my head around the concepts, once I had the basics, the bot only took about 10 minutes to create.

Starting off, If you do not already have a Recast.AI account here one here – https://recast.ai/signup/ or sign on

1) Click the new bot button

2) Click “Create a complete chatbot”

3) Skip Selecting Pre-defined skills

4) Give your bot a name, I choose Mood Detect

5) Choose your language, leave the bot public and click “CREATE A BOT”

Your bot is now created, the next step is to train your new bot.

Training Your Bot

Your next step is to train the bot, training allows the bot to know how to respond to user input.  We will add 3 intents “Detect Happy Person”, “Detect Sad Person” and “Detect Angry Person”

 

1) Click the “+ OR CREATE” button

2) Repeat the create process for the remaining 2 intents –  “Detect Sad Person” and “Detect Angry Person”. When your done, the page should look like this…

3) Click “detect-angry-person”, you will now be able to add expressions. Go ahead and add 3 expressions – mad, angry, furious.

When your done with the detect angry person intent, click back to the “Train” tab and repeat the process for “detect-sad-person” and “detect-happy-person” using these words respectively – sad, depressed, unhappy and happy, wonderful, glad.

4) Add skills to your bot – click the “Build” tab then click the “+” button.

We will start by adding the “detect happy” skill.  We will use floating as the skill type, as this is related to small talk.

5) Repeat from step 1 for “detect sad” again using floating as the skill type

6) Next, we need a fallback skill

The fallback skill is what the bot will “fallback” to when the other skills do not provide a response. For this skill I simply use the name “fallback”.  There can only be one fallback skill.

When you are done creating your skills, it should look like this…

Adding Triggers To Skills

Triggers do exactly what they are named, they trigger the skill based on conditions set up in the trigger.

1) Add Skills

Go ahead and click on the “detect-angry” skill, click on the “Triggers” tab, then click to the right if the “If” statement.  You will see your previously created intents. Click on the “@detect-angry-person” intent. Then click “Save”

 

2) Add Actions To The Skills

Now click the “Actions” tab, click “ADD NEW MESSAGE GROUP” you will then have the ability to add conditions to trigger a response message.

Click “Send Message”

Next, we will select the “Text” message type.  Being that we are in the “detect-angry” skill, we will respond to the user with a message that will hopefully calm the user down.  So in the message box, type in “I’m sorry that you are angry, sometimes I feel the same way” then click “SAVE”

 

3) Click back to the “Build” tab and repeat this process for the “detect-sad” and “detect-angry” skills.

Make sure you select the intents relative to the skill, e.g. the sad skill gets the sad intent and the happy skill gets the happy intent.

For the actions and triggered messages I used “Awesome, I’m happy too!” for happy skill and “Sorry to hear that, try to focus on the good things!” for the sad skill.

4) Add A Single Fallback Skill

Finally, we need to add the fallback skill, this will provide a response when the bot doesn’t know what to respond with. Click back to the “Build” tab and click the “fallback” skill.  You will notice that there are no conditions here, as this is a fallback, when all else fails.

Click “Actions”, “ADD NEW MESSAGE GROUP”, “SEND MESSAGE”, “Text”, then type in a friendly message like “Sorry, I don’t understand what you are saying”.  Make sure you click “Save”

Chat With The New Bot

Your first super simple bot is not setup and can be chatted with.  Recast give us an great chat/test tool that is available throughout the construction of the bot.  We will be using the “CHAT WITH YOUR BOT NOW” interface, however there is also a “TEST” area where you can diagnose issues.

Go ahead and click “CHAT WITH YOUR BOT NOW” in the lower right corner of your browser, type in a statement mentioning one of the mood words we trained the bot to pick up on, here I use happy…

Next I try the sad mood detector…

Next, I test the fallback…

We can see that the fallback works nicely.

Conclusion

So using Recast.AI I was able to create a functioning(albeit not too smart) bot that can pick up on the words a user types in order to detect the mood.  This was also my first experience using Recast.AI, I found the product easy to learn and use. While this bot only took about 10 minutes to create, I would expect a commercial bot to take days and even weeks to fully implement.

Assigned Tags

      5 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo nageswararao gudiseva
      nageswararao gudiseva

      Hello Mathews,

      It was really a nice blog. In your previous blog you have mentioned that you will integrate this chat bot with the sap web ide. When your going to integrate that? and one more thing can you please create some more blogs on Voice based chat bot.

      Author's profile photo Dean Mathews
      Dean Mathews
      Blog Post Author

      Hi, thanks for the reply. I would like to to the web ide/chat bot article soon, trying to find the time to do a nice job at it.

      Author's profile photo Dhananjay Hegde
      Dhananjay Hegde

      Hello Dean

       

      Nice blog.  I specifically liked how you tested the fallback skill of your bot 😀

      I would love to to know how you are going to integrate this bot with WebIDE / Fiori apps.

      Author's profile photo Manisha Madhwani
      Manisha Madhwani

      Hello all,

      Please find link to one such solution of recast chat bot integration with sap ui5.

      https://blogs.sap.com/2018/08/13/chatbot-integrationrecast.ai-with-sap-ui5/

      Hope you all find it useful. Integration is done using rest api's.
      
      Dean Mathews: Thanks for the above article it was quite useful. Please share if you find any alternate solution to integration.
      Regards,
      Manisha Madhwani
      Author's profile photo Marcus Schiffer
      Marcus Schiffer

      Hi,

       

      I have an account on recast.ai and try to build a bot according to the blog.

      It can  however not be tested. For every input the debug gives "no reply" and throws

      {"results":null,"message":"Request can not be processed without authentication"}

      The token seems to be correct (the one from settings) but no luck with any configuration.

      Any help is appreciated.