Teach Natural Language to Einstein Bots

Best practices in designing dialog intents

Ruby Kandah
6 min readDec 13, 2019

Does my bot need to understand natural language?

Peering at historical chat transcripts will illustrate if your chatbot needs natural language processing (NLP). If visitors are opting to free text their concerns in lieu of selecting pre-canned menu options, NLP may be a very important feature to build in your chatbot. However, if visitors are actively using clickable menus to carry long conversations with your chatbot, sustaining a menu based chatbot could suffice for your business.

Best practices for building a NLP bot

NLP, which stands for Natural Language Processing, is technology allowing devices like Alexa to translate human language into actions Alexa performs, such as, checking the weather. Training your bot to understand human language is akin to teaching a kid sentence structure and word meanings. You have to provide example sentences, known as “utterances”, to the bot and categorize these sentences with a label, known as “intent”. Providing high quality utterances is highly critical towards building a high-IQ conversational AI. The following best practices aid you in creating high quality utterances for your chatbot to learn from.

Best Practice #1 — Create a balanced dataset

The achilles heel of chatbot NLP is unbalanced data sets. Einstein bots (at the time of writing this article) require a minimum of 150 utterances per NLP dialog. If your bot is seeming to function inadequately from initial tests, its probably due to a highly unbalanced dataset. Avoid large discrepancies in utterance count (i.e. one dialog with 35 and another with 170 utterances). Unbalance leads to a training bias where your NLP model will be overly confident in dialogs with high utterance counts. Overconfidence results in a higher rate of prediction to those dialogs; so, if someone asks a question most representative of dialog Intent E, your bot will likely misclassify to Intent B. Ensure your model is equally confident across all dialog intents by first, meeting the recommend minimum 150 utterances per dialog intent and second, if certain dialogs contain utterances above the minimum, ensure all other dialog intents are topped off and brought up to the same level. Generating utterances can be a cumbersome task; lessen this undertaking by leveraging the following:

  1. Use an utterance generator such as Microsoft Luis.AI
  1. Download historical chat transcript data, extract real utterances said by customers to support agents and upload these scrubbed utterances (i.e. remove PII) to the bot configuration through dataLoader. (preferable)

Best Practice #2 — Remove proper nouns from utterances

Remove proper nouns (such as first name or unique order number…) from utterances entirely. The natural language processing algorithm seeks patterns between utterances in a particular dialog intent. Proper nouns introduce too much variability within an utterance, and, in doing so, make it difficult for the bot to identify patterns.

Best Practice #3— Create close-to-natural sentences

Small phrases with little context can be unnatural during conversation. Ensure utterances are as close to natural language and natural behavior as possible. Remove special and irrelevant characters ($, @, &, *…) and add variation to the prefixes and suffixes of your utterances.

Best Practice #4 — Convert low count intents to “Exact Match”

How many different ways can you say “hello”? Probably less than 150; dialogs such as Salutation, Bye, Transfer, and others limited in variations, are better suited for Exact Match over NLP. A toggle on the dialog enables you to exclude a low utterance count dialog from the NLP model entirely. Unlike NLP, exact match is case sensitive & punctuation sensitive. Add every variation of “hello” to an exact match model (e.g. “HELLO”, “Hello”, “Hello!”).

Best Practice #5 — Combine similar intents

There is high likelihood your bot will frequently confuse two dialog intents of great similarity. Combine dialog intents whenever possible and use an entity or conditional rules to redirect to a specialized dialog.

  1. “I want to return a pair of shoes” ← Return Issue topic
  2. “I want a exchange for a pair of shoes” ← Exchange Issue topic

These two utterances are very similar (<5 word variation) and identifying a unique pattern is difficult for a chatbot. Instead, create an umbrella dialog intent — lets name it “Unhappy with Purchase” — and add utterance #1 and #2 to “Unhappy with Purchase”. Then, create a bot question on “Unhappy with Purchase” dialog, something like:

This is a great example of a hybrid bot, one which caters to a free text input from a customer and uses menu based options to dig deeper into the correct action the bot should take.

Best Practice #6 — Continual training

Continuous training prevents chatbot staleness. While most visitors ask questions the chatbot is already trained to recognize and understand, some visitors may free text net-new questions the chatbot has not been trained to recognize. Einstein bots store all net-new questions in memory and request your help in categorizing new utterances through an interactive training game. Clicking through the training game will categorize new utterances to the bot’s memory. Once complete, retrain the bot’s NLP model to see your additions and changes take effect.

Einstein bots provide a “Natural Language Understanding (NLU)” dashboard out of the box. One alert in the NLU dashboard notifies you when the model is dated and needs to be rebuilt. When rebuilding the NLP model, your bot may become unavailable to converse with a visitor; therefore, its advised to rebuild NLP models during off-peak hours for your chatbot.

Best Practice #7 — Use QBox to maximize training data performance

QBox.ai pinpoints problematic dialog intents, provides recommendations on utterance design and shows you which dialogs intents are frequently confused with one another. Export all intents and utterances through the Salesforce metadata API and import them directly into Qbox to visualize the fidelity of your NLP. Off the shelf tools, such as QBox, can supplement your NLP journey.

Next Steps

Building a conversational NLP model takes time and investment. Once you’ve built a NLP model in one language, translating to other languages can be quick and easy. Einstein bots natively support NLP models in English (US), Spanish, Portuguese, French, Italian and German. If your language of interest is not listed, find a 3rd party NLP provider of your choice and connect it to your Einstein Bot via APEX callout. This article, along with two additional articles, form a trilogy of instructional material for building an advancing Einstein bots:

  1. Get ready for Einstein Bots in 5 steps
  2. Build your first rules based bot
  3. Teach natural language to your chatbot

About the Author

As a former Salesforce customer, I’ve implemented Salesforce (Sales Cloud, Service Cloud, Pardot), AI tools and telephony systems for 2,000+ users across almost every business unit at a high growth startup — Doordash. Salesforce then hired me as Director of Product to build Einstein Bots with admin-centric features to make bot building intuitive, friendly and powerful. Today, I serve as the CEO of CloudX (www.cloudx.design), a Salesforce implementation firm specializing in Zendesk to Service Cloud migrations, Einstein bot implementations, digital channel development and more. We’ve successfully implemented Einstein bots for companies of all sizes and have done so in as little as 5 weeks. Drop me a line to learn how CloudX can springboard your CRM/AI/Automation strategy!

--

--

Ruby Kandah

CEO of CloudX 👩🏻‍💻, xNASA engineer, xDirector of Product at Salesforce, xDirector of Eng at Doordash, Inventor on patent #10,258,531, PhD BME