One of the most effective ways to make Einstein Bots quick and convenient for users is to enable the Natural Language Processing capabilities included in Einstein Bot Builder. Our goal is to make bots the fastest way to get at the services and information your users want. In this post, I’ll walk you through the process of training Einstein Bots for Intent detection so that your bots can interpret messages from your users and offer the correct responses.
You’ll see how to train your Einstein Bot to understand natural language, in this case using the English language. I’ll try to write a post on multi-language Einstein Bots in the near future, but for the time being, just know that the approach outlined here can be applied to other languages as well.
Intents are the reasons your customer’s interact with your bot. For example, scheduling an appointment, changing a flight or getting store hours. We will associate intents with your dialogs (things your bot knows how to do) and then train the bot to create a learning model that it can use to detect user intents. If your customers interact with your bot by typing a message, you can use intents to help your bot understand what they want.
Before we get started be sure you have already finished the Build an Einstein Bot project so that you’ll have a Salesforce instance and a basic bot to use as a foundation for the following. Get yourself logged into the org you used for that trail so that we can pick up right where you left off.
We’ll begin this exercise in the Einstein Bot Builder where we can teach our bots to understand customers who want to schedule an appointment or transfer to an agent.
1. Let’s start in Salesforce Lightning Setup. Click the little gear icon in the top-right corner of your screen and select Setup.
2. Use the Quick Find box in the upper-left of your screen to search for the word bot and click on the Einstein Bots setup node. You should see the bot you created previously in the Build an Einstein Bot project. Click on the down arrow to the right of the version of your bot you would like to modify. We are going to be making some changes, so click Clone to create a new version.
3. Salesforce will drop you into the Dialogs tab of the Einstein Bot Builder. We are going to start by training the bot to recognize when customers express the Intent for Transfer to Agent, so click on that dialog.
4. To make it easier to validate our testing later, let’s add a Message block to this dialog that tells the user when the bot is transferring them.
5. Now just click the Enable Dialog Intent button in the top-right corner of your screen.
5. Notice that we now have a brand new tab called Dialog Intent? Tap that. Here we can give our bot some utterance examples for the types of things people may say when they want it to Transfer To Agent. We need a minimum of 20 for testing, but 150 is the recommended minimum for production bots. You will notice a significant improvement in accuracy as you add more utterances, so be sure to take the time to enter as many as possible. After you’ve entered at least 20 utterances, flip the Einstein slider in the top-right of your screen to the On position.
Pro Tip: If you do not turn on the Einstein slider, the dialog will be in exact-match mode and only present the dialog to users who enter one of the utterances exactly as it is in the list.
You can download the data set I used for the Transfer To Agent intent here.
Pro Tip: If you get tired of the copy/paste routine, you may want to learn to use Workbench or Dataloader.io to speed things up. I’ve written a short tutorial on loading utterances with Workbench here.
6. Our bot now has some examples of the Transfer To Agent intent, but that’s it. Let’s give the bot some Appointment Related intents so that we can train an AI model to help choose between them based on what users say. You should already have a placeholder dialog called Appointment Related that you created previously in the Build an Einstein Bot trailhead project.
Let’s add another Message block here so that the bot will tell us when it detects our Appointment Related intent. Don’t worry, we’ll add more cool stuff here later.
7. Repeat the previous steps to Enable Dialog Intent, add some relevant utterances and turn on Einstein. Again, bulk loading the utterances with a tool like Workbench or Dataloader.io will save you a ton of time.
You can download the data set I used for the Appointment Related intent here.
1. Alright, now that we’ve given our bot some utterance samples and configured it with the intents we want it to detect, it’s time to train the Einstein AI model. Navigate to the Model Management tab in the upper-left corner of your screen and click the Build Model button. This process normally takes about 10 minutes, so take this time to ponder the existential implications of the AI mind you’ve just unleashed on humanity. Transfer To Agent indeed.
When the model finishes training, the dashboard will display a summary of the model intents and accuracy.
Pro Tip: You may be wondering where these accuracy numbers are coming from. The answer to that question is that Salesforce sets aside a percentage of the utterances you’ve entered. Instead of including them in the model training data set, they are reserved for testing the model after training is finished. The percentage correct displayed here indicates how many of the reserved utterances actually returned a high probability match for the correct intent.
2. Drill into the Appointment Related intent and check out the detailed dashboard. This gets much more interesting with poorly trained models where the intent conflict report will tell us why the bot is incorrectly classifying utterances. Check back here after you have more intents set up and are working to round out your utterance training data set.
3. Now it’s time to chat with our bot and see if it’s any smarter than last time. Navigate back to the Dialogs tab using the drop-down in the upper-right. Click on the Activate button, then Preview, then Submit and finally Chat with an Expert. Be sure to fill in all of the pre-chat fields before you hit Start Chatting.
4. Open the Service Console in another tab and set Omni-Channel to Available — Chat so that we can test out transfer to agent.
5. Now let’s switch back over to Bot Builder and send an Appointment Related message to see if the bot detects our intent. Try to use something not exactly the same as the utterances you entered like “Hi Jana. Can you schedule an appointment for me?”
Your bot should reply with the message we configured for the Appointment Related dialog earlier.
6. Now let’s tell the bot we want to Transfer To Agent by saying something like “Actually, I’d rather chat with a human about this.” The bot will print the message we configured previously and connect you with the agent in Service Console.