Let’s get started! By the end of this tutorial, you’ll be able to build a fully functional bot using the Recast.AI platform. By using Recast.AI, you can easily design complex conversational flows fuelled by a powerful artificial intelligence.
To begin, create an account on Recast.AI! It’s free 🙂
The 4 stages of bot building
There are 4 phases of your bot life represented on our platform through the use of 4 tabs:
- Train – teach your bot what it needs to understand.
- Build – create your conversational flow with our Bot Builder tool.
- Run – connect your bot to a messaging channel of your choice.
- Monitor – regularly train your bot to keep it up to date, and get insights on its usage!
Let’s take a look at each step in detail. The point? Building a food ordering bot.
Create your bot
To create a new bot, login and click on
“+ NEW BOT” in the header section.
- Choose your name: ‘food-bot’
- Add a description: ‘Order food easily with RestoBot‘
- Set English as the default language.
- Choose a template (the default bot is a good start).
- You can keep your bot public as there is no private info
After that, you are redirected to the main page. This is the heart of your bot, where all its understanding is gathered, decomposed in intents.
Intents are “boxes” of sentences (that we often call “expressions”) that all mean the same thing but are phrased differently. Each intent matches one action your user wants to perform.
For example, an intent ‘greetings’ makes your bot understand when a user says ‘Hello’ or ‘Hi’.
Explore each intent by clicking on their names.
There are certain intents all bots should have to understand basic things such as ‘greetings’, ‘agree’, ‘disagree’, and when a user asks for help.
Our platform being collaborative, you do not have to recreate each intent every time! You can ‘fork’ an intent someone already created to clone it right into your bot.
To add an existing intent called “Help”
Write ‘help’ in the input Search and Fork from the community
Click on search
Select one of the first results and just click on the ‘FORK’ button on the right.
Repeat this process for ‘agree’ and ‘disagree’
Create a new intent
If you want a custom intent, you can build it from scratch.
Here, we want the bot to understand when someone orders food, and if he would like it to be delivered or take-away. Let’s create these intents.
Write ‘order’ in the input Search and Fork from the community
Click on create.
Repeat this with ‘delivery’ and ‘takeaway’
Now that intents are created, we have to enter various expressions.
The optimal amount of paraphrased expressions for an intent is around 20.
Click on one intent, and add expressions you want your bot to understand. Put yourself in the shoes of the people talking to your bot. What could they possibly ask? Enter a new expression by typing in the field Add an expression. Here are some examples:
- I would like to order.
- Can I get pasta please
- I want to order tacos
- Is it possible to order some sushi?
- I would like to have some nachos
- I want to order something.
- Do you have noodles?
- Deliver at 163 avenue de Clichy Paris
- I’d like to order delivered
- I want to be delivered
- at home, 123 food street, Paris
- I want to order take out
- I want to take away at the name of Hugo
- I would like some food to take-away
- take away
- take out at the name of Bruno Gantelmi
For some expressions, you’re going to need to extract some key data to use later. That’s what entities are for. Entities are keywords detected in expressions. You can see them by clicking on an expression. Some are automatically detected (like dates, temperatures or locations) and are called gold entities.
You can also create your own custom entities. We’ll use them here to get the type of food the user order.
To create a custom entity:
Select the word(s) you want to tag as ‘food’ in your expression.
Type ‘food’ in the search bar.
Repeat for each expression of the ‘order’ intent containing taggable food.
Test your bot
Now that we’ve filled the mind of your bot with tons of phrases and expressions, let’s test it with the console:
Click on the
TEST bubble icon on the top right
Select the tab “Analyse”
Type a message “I want some sushi”
You will see which intent is detected and which entities are extracted.
If “sushi” is not extracted as FOOD, your intent is lacking expressions. Add sentences and try again.
Click on the “Smart view” toggle to switch the view to the JSON mode.
The JSON contains a lot of useful information about the message you’ve sent, because of the enrichments we provide for gold entities.
Build and manage your conversational flow
Now that the brain of your bot is all filled up, click on the ‘build’ tab, launch the builder, and discover the magic!
Define your actions
Let’s take some time to picture the flow.
- user says hello
- user chooses either delivery or pick-up
- user orders
- user confirms the order or doesn’t.
Here is the outline of the bot flow. Each step on this outline is an action. An action, as we call it in Bot Builder, is one step in your conversation flow that is associated to an intent. You can have several actions for the same intent.
To put an action on your builder playground:
- Click on the plus in the left side toolbar.
- Click on the right intent
- A module appears, you can move it anywhere, anytime.
Reproduce this scheme in Bot Builder. Don’t bother with the connections yet.
Link the actions
There are two types of links:
- Green links create an action flow where the user is guided in one direction, but remains free to start at any other step of the conversation.
- Red links create an action flows where the user has to follow a defined path.
To connect actions:
- Click on the right end of the action you want to link.
- Click now on the left end of the other action you want to connect it to.
- Change the color of your link by clicking on it then on the right color in the toolbar.
Since the ‘order’ action needs the user to choose between delivery and take away, the only red connections we have to make are:
- order -> delivery
- order -> takeaway
Let’s take some time to talk about
When two red links are connected to the same action on the right, a small red bloc appears: it can be a
To change from one to the other one, click on the crossing arrows below its name.
‘OR’ means that only one of the action has to be done.
‘AND’ means that both of them are required.
Here, the user chooses between ‘delivery’ or ‘takeaway’: so we set an
Define the notions
Now that we’ve set the flow, some actions need specific information (entities) to be completed: we call them notions.
Click on the small pen on the ‘order’ action.
Click on the ‘Add Notion’ Button
Search the ‘food’ custom entity we created earlier and set the alias as ‘food’
Then click on the back button on the bottom.
You now have your food notion added in your overview.
As we need a name for take away and an address for delivery, set these 2 notions the same way you did the first one.
At this point, the hardest part is done. Let’s now give your bot a voice!
Set bot replies
There are 3 different replies you can set:
- A reply when the action is done
- A reply when a notion is missing in the sentence
- A reply when you need a previous action to be done before (red linked)
To set them:
- Just go on the overview of any action card
- Click on ‘Add bot replies’.
- Add replies for each state of your action
You can also add variables by using the alias of your notion like this:
Do you confirm the booking for the room:
Test your flow
Now that the flow is complete and replies are set, we can finally test the bot!
- Use the console, exactly like earlier
- Say “Hello”
- Have fun testing your bot before we start coding
Connect your bot
We’re now done with setting the bot. The last thing you have to do is to connect it to a channel to share it with the world!
How does it work? You will be able to connect your bot to multiple channels with our tool named “Bot Connector”. Bot Connector takes care of receiving all messages and transfers it to your bot in a standardized format.
Go to the Run tab and toggle the channel you want to connect your bot in the list. Follow the instructions to configure the channel. You will need to have accounts on these other platform and get the relevant tokens.
Now, go on Messenger, Kik, or any other channel you chose and look for you bot, it’s there, it’s live!
Train and keep your bot up to date
When your bot is launched and has users, go to the Monitor tab and manage your logs:
- Archive the message if it matches the right intent
- Redirect the message to the right intent if it mismatches.
- Keep an eye on this tab to make your bot better.
If you want to code now to integrate an external service, go to the
RUN tab and click on “code”. Follow the steps and launch your bot 😉
Hope this tutorial helped you create a first efficient bot! Don’t hesitate to ask if you need help in your bot building, and keep coding 🙂