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.

  1. 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.
  2. From Setup, enter Einstein Bots in the Quick Find box, then select Einstein Bots.
  3. Select your bot Mobile Chatbot from the list of bots.
  4. 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.
    The Einstein Bot Builder Dialogs menu with 7 items prebuilt.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.
  5. Select the Order Related dialog.
  6. We first must deactivate the bot so that we can add more functionality. Click Deactivate at the top right of the screen.
  7. Now add a question by clicking Question from within the dialog.
    The Order Related Dialog setup screen with the mouse over the Questions option.
  8. Enter OK. I can help you with that. What is your order number? as the question. Specify [System] Text (Text) as the Entity Name.
    The Question with the Bot Asks question and Entity Name populated as mentioned in the previous step.
  9. Click in the Save Answer to Variable field and create a New Text Variable.
    A mouse hovers over the New Text Variable option in the Save Answer to Variable field.
  10. Specify OrderNumber as the variable name and click Save. This step stores the answer to the question in a variable named OrderNumber.
    In the New Variable window, OrderNumber is entered in the Name field as well as API Name field with Text as the Data Type.
  11. 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 plus icon just under this Question. The Question interface with the + button below, highlighted in a red box.
    • Click Message.
    • Enter Let me look up order number {!OrderNumber}…
      Under the Question, there is a Message where Bot Says Let me look up order number {!OrderNumber}… 
  12. Click Save.
  13. 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.

  1. Start a session and this time select Order Related from the menu options. When the bot asks you for the order number, enter 1234567.
    Einstein Bot open in an iPhone XR with a chat conversation where the customer indicates Order Related, Einstein Bot asks for the order number, and so on.

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.