Create your first chat bot
This article will walk you through the process of creating and running your first chat bot.
Create a bot
Create a new bot and call it TravelBot and click Save.
We’ve created a bot that will interact with users. It is preferable to have a bot per scenario. For example, you might require a bot that can handle travel-related activities and hotel room booking.Next, we’ll teach our bot to identify what the user wants by creating an intent.
Create an intent
Let’s add an intent by clicking Add Intent and call it BookFlight.Next, we’ll create a few phrases called utterances that a customer might use to describe what they want to do.
Create an utterance
Let us add a few sample phrases that someone talking to our flight-booking bot might use and save them. For example:
- I want to book a flight from Madrid to New York.
- Book me a flight to San Fransisco.
- I want to fly to Frankfurt.
Since we’re creating a travel bot, let’s include an utterance that has airport codes.
- I would like a flight to LHR from SAN.
Create a custom slot type
We’ve added some sample utterances that use city names and airport codes, so we have to teach our bot that certain words or phrases are actionable items. These items are called slots and in this case, they will stand in for actual city names. Let’s add a City Name slot.
- Click Slot Types in the left panel and click Add Slot Type.
- Enter City Name and click Save.
Now, we’ll add some names of cities as slots. For each entity you can add synonyms for different ways a user might provide information. In this case, we’ll add NYC and NY (abbreviations) as synonyms for New York area. We could also add JFK and LGA (airport codes) as synonyms for New York. You can add as many synonyms as you like.
- Select the Allow synonyms option, add synonyms to each entity, and click Save.
Map slots in an utterance
- Go to the Utterances tab of the BookFlight intent from the Intents option in the left panel.
- Double-click the word Madrid in the utterance, I want to book a flight from Madrid to New York.
- As we do not have any slots defined, let’s add a new slot by clicking Add new slot.
- In the Add Slot dialog, name it as Origin as we’re trying to capture where the user is flying from.
- Select City Name in the Slot Type option to tell the bot that this entity will use values from the City Name custom slot type we created earlier.
- As the origin location is required for our bot to book tickets, select the Slot required option.
- To let the users know that they have to enter something, let us add a message in the Prompts field asking to enter some information: Where are you flying from? Press Enter to save the prompt.
- You can add more prompts which the bot will display to the user.
- Save the new slot and select it from the Select Slot option.
- Similarly, tag the starting locations in the other utterances also. You can also create a new slot for the destination city and tag the destinations with the same City Name custom slot type.
Test the bot
Now that we have some basic rules set up for our bot to identify travel information. Let’s see how well our bot understands the user input and identifies the slots.
- Click Test Bot in the top-right corner.
- Start a conversation with your bot by typing an utterance that mimics the sample utterances that you provided.