According to a Gartner report from February 2018, “25 per cent of customer service and support operations will integrate virtual customer assistant (VCA) or chatbot technology across engagement channels by 2020, up from less than 2 per cent in 2017.” In the light of this, readers will find this tutorial on how the open source Recast. AI bot-creating platform works, helpful.
Chat bots, both voice based and others, have been in use for quite a while now. From chatbots that engage the user in a murder mystery game to bots which help in real estate deals and medical diagnosis, chatbots have traversed across domains.
There are many platforms which enable users to create and deploy bots. Recast.AI (now known as SAP Conversational AI after its acquisition by SAP) is a forerunner amongst these.
The cool interface, its collaborative nature and the analytics tools it provides, make it a popular choice.
As the Recast official site says, “It is an ultimate collaborative platform to build, train, deploy and monitor intelligent bots.”
Building a basic bot in Recast
Let us look at how to build a basic bot in Recast.
- Create an account in https://cai.tools.sap. Signing up can be done either with an email ID or with a GitHub account.
- Once you log in, you will land on the dashboard. Click on the + New Bot icon on the top right-hand side to create a new bot.
- On the next screen, you will see that there is a set of predefined skills you can select. Select Greetings for the time being (Figure 1). This bot is already trained to understand basic greetings.
- Provide a name for your bot. For now, since this is a very basic bot, you can have the bot crack some jokes, so let us name it Joke Bot and select the default language as English.
- Select Non-personal data under the data policy since you won’t be dealing with any sensitive information; then select the Public bot option and click on Create a bot.
So that’s your bot created on the Recast platform.
The five stages of developing a bot
To use the words from the official Recast blog, there are five stages in a bot’s life.
- Training – Teaching your bot what it needs to understand
- Building – Creating your conversational flow with the Bot Builder tool
- Coding – Connecting your bot with external APIs or a database
- Connecting – Shipping your bot to one or several messaging platforms
- Monitoring – Training your bot to make it sharper and get insights on its usage
Training a bot through intents
You will be able to see the options to either search, fork or create an intent in the dashboard.
“An intent is a box of expressions that mean the same thing but which are constructed in different ways. Intents are the heart of your bot’s understanding. Each one of your intents represents an idea your bot is able to understand.” (from the Recast.AI website)
As decided earlier, you need the bot to be able to crack jokes. So the base line is that the bot should be able to understand that the user is asking it to tell a joke; it shouldn’t be that even when the user just says, “Hi,” the bot responds with a joke – that would not be good.
So group the utterances that the user might make, like:
Tell me a joke. Tell me a funny fact. Can you crack a joke? What’s funny today?
Before going on to create the intent from scratch, let us explore the Search/fork option. Type Joke in the search field (Figure 3). This gives a list of intents created by users of Recast around the globe, which is public, and this is why Recast is said to be collaborative in nature. So there’s no need to create all intents from scratch, one can build upon intents already created. This brings down the effort needed to train the bot with common intents.
- Select the first intent in the list and fork it into the bot.
- Click on the Fork button. The intent is now added to the bot (Figure 4).
- Click on the intent @joke, and a list of expressions which already exist in the intent will be displayed (Figure 5).
- Add a few more expressions to it (Figure 6).
Once a few expressions are added, the bot gives suggestions like shown in Figure 7. Select a few and add them to the intent (Figure 7).
You can also tag your own custom entities to detect keywords, depending on your bot’s context.
A skill is a block of conversation that has a clear purpose and that your bot can execute to achieve a goal. It can be as simple as the ability to greet someone, but it can also be more complex, like giving movie suggestions based on information provided by the user.
It need not be just a one query-answer set, but rather, skills running through multiple exchanges. For example, consider a bot which helps you learn about currency exchange rates. It starts by asking the source currency, then the target currency, before giving the exact response. Skills can be combined to create complex conversational flows.
Here’s how you create a skill for the joke bot:
- Go to the Build tab. Click on the + icon to create a skill.
- Name the skill Joke (Figure 8)
- Once created, click on the skill. You will see four tabs. Read me, Triggers, Requirements and Actions.
- Navigate to the Requirements tab. You should store the information only if the intent joke is present. So, add a requirement as shown in Figure 9.
Since this is a simple use case, you needn’t consider any specific requirements in the Requirement tab but consider a case for which a response needs to be triggered only if certain keywords or entities are present – in such a case you will need ‘requirements’.
Requirements are either intents or entities that your skill needs to retrieve before executing actions. Requirements are pieces of information that are important in the conversation and that your bot can use; for example, the user’s name or a location. Once a requirement is completed, the associated value is stored in the bot’s memory for the entire conversation.
Now let us move to the Action tab to set the responses (see Figure 10).
Click on Add new message group. Then select Send message and add a text message, which can be any joke in this case. Also, since you don’t want your bot to crack the same joke each time, you can add multiple messages which will be randomly picked each time.
Well, the success of a bot also depends upon how easily it is accessible. Recast has built-in integrations with many messaging channels such as Skype for Business, Kik Messenger, Telegram, Line, Facebook Messenger, Slack, Alexa, etc. In addition to that, Recast also provides SDKs to develop custom channels.
Also, there is a ready-to-use Web chat provided by Recast (in the Connect tab). You can customise the colour schemes, headers, bot pictures, etc. It provides you with a script tag to be injected into the page. Your interface is now up (Figure 12).
The Web chat code base is open sourced, which makes it easier for developers to play around with the look and feel, the standard response types and much more.
The dashboard provides step-by-step procedures on how to deploy the bot on various channels. The joke bot was deployed in Telegram and in Web chat, as shown in Figure 13.
And there is more
Recast supports multiple languages, Select one language as the base while creating the bot, but then you also have the option to add as many languages as you want.
The example considered here is a simple static joke bot, but actual use cases will need interaction with various systems. Recast has a Web hook feature which allows users to connect with various systems to get responses. Also, there is detailed API documentation to help leverage each independent feature of the platform.
As for analytics, Recast has a monitoring dashboard which helps you understand the accuracy of the bot and train it further.
The author is an open-source enthusiast.