Make Your Bot Smarter
Make Your Chatbot Smarter
You might’ve noticed that our chatbot isn’t all that smart… yet. For instance, if you select one of the menu options we created, nothing happens. Let’s go back to our bot in our org and build out the chatbot a little bit more.
- Tab over to your Trailhead Playground. If it’s closed, feel free to open it from the playground selector at the bottom of this page.
- From Setup, enter
Einstein Bots
in the Quick Find box, then select Einstein Bots. - Select your bot
Mobile Chatbot
from the list of bots. - From the Dialogs tab, notice that you already have some dialogs built out for you. A dialog is nothing more than a conversation snippet that controls what your bot can do.
There are some default dialogs such as Welcome, Main Menu, Transfer To Agent, End Chat, Confused, along with the dialogs automatically created for each of the main menu items you specified when setting up your bot.
- Select the Order Related dialog.
- We first must deactivate the bot so that we can add more functionality. Click Deactivate at the top right of the screen.
- Now add a question by clicking Question from within the dialog.
- Enter
OK. I can help you with that. What is your order number?
as the question. Specify [System] Text (Text) as the Entity Name.
- Click in the Save Answer to Variable field and create a New Text Variable.
- Specify
OrderNumber
as the variable name and click Save. This step stores the answer to the question in a variable named OrderNumber.
- To let the customer know we really understood the order number in chat, let’s have the bot send a message back to them with the variable name. To use a variable in a message, use the format
{!VARIABLE_NAME}
. So, below the question we just created, let’s add a Message.- Click the + button
just under this Question.
- Click Message.
- Enter
Let me look up order number {!OrderNumber}…
- Click the + button
- Click Save.
- Now Activate the bot again and test it out!
Test the Bot
Go back to your app in Xcode and launch it. Notice that we don’t have to change any code to use the updated bot.
- Start a session and this time select Order Related from the menu options. When the bot asks you for the order number, enter
1234567
.
The bot passes that order number back to you in its message. Pretty slick, huh?
As you’ve probably guessed, we’ve barely scraped the surface of what a bot can do. But look what you did!
- You set up chat easily through the click-by-click menu in Service Setup.
- You built an Einstein Bot.
- You built a native iOS app using Xcode.
- You integrated Salesforce with your app using the Services SDK.
- You made the bot work.
What Else Can Chatbots Do?
There are endless ways to enhance your chatbot. Here are some highlights:
- Use regular expressions to detect and verify relevant text from within the conversation, such as order number.
- Access pre-chat form data and other context information from within the bot.
- Call Apex actions from within a dialog.
- Call flow actions from within a dialog.
- Use natural language processing to understand customer intent.
- Create dynamic menus based on user input or other information.
- Search your knowledge base and return relevant knowledge articles.
- Automate the transfer to an agent when the intent detection failures pass a specified threshold.
To see all this stuff in action, check out our Einstein Bot Developer Cookbook.
And to flesh out your app and customize the SDK, remember to check out the Service SDK developer guide: Using Chat with the Service SDK for iOS.