April 7, 2017

Artificial Intelligence (“AI”) is a hot topic. AI companies are popping up like never before. All AI developers have one common goal: to impersonate human’s intelligence using computer software. Many of them produce AI products in the form of chatbots.

I made one myself, too. Check out ryanbot.io and feel free to play with it!

So, how do chatbots work? Let’s walk through the different components that chatbots use to understand, process, and respond to your messages.

Before we start, let’s keep this in mind: it is really difficult to replace the human brain. AI, at its core, consists of educated guesses and confidence level. The computer makes guesses based on the information it knows about the user, determine the confidence level of each guess, and picks the one it deems most likely to be the best guess.

Gathering Context

“Contexts” are supporting information that can help the bot determine the intention behind your message.

Bots can collect contexts from multiple different sources in order to determine your intent more accurately.

  • History of your interactions with the bot
  • Date and time
  • Your location
  • Your personal information
  • Your habits
  • Your device’s information
  • Applications you installed
  • Websites you visited
  • and many more…

Determining Intent

The next step, and the most important step, is determining the user’s intent behind writing the message.

Using a combination of Natural Language Processing (NLP – not to be confused with Neurolinguistic Programming) and the contexts gathered in the previous step, the bot will attempt to guess what the user’s trying to tell the bot.


Let’s say we have the following conversation between a smartphone user and a chatbot on the phone:

The message “reminders” is the first message sent by the user. Without any history of your interactions with the bot, the bot can assume that the user is requesting a list of reminders.

Now, let’s say that the message “reminders” is sent to the bot in connection to a previous message:

Using the history of your interactions with the bot, the bot can determine that your intention in connection to your previous request, opening an app.

So, the exact same message can be interpreted as having different intents by mixing in contexts.

Extracting Parameters

Parameters are information provided directly by the user in relation to a specific request or intent.

Examples (intents in bold, parameters underlined):

  • Remind me to take out the trash
  • Turn on the bedroom lights
  • Call Brian

A more complicated example:

“Show me directions to Union Square”
  • First, “Show me directions to union square”
    • We need to determine the intent: show me (could be “print me”, …).
    • The word “to” gives a clear separation between “directions” and the object, “union square”.
    • Show me what? The parameter: directions (could be “my calendar”, “my home address”, …)
  • Second, “Show me directions to Union Square
    • What is “Union Square”? Is it…
      • an address,
      • a point of interest,
      • a phone-related action (“show me directions to turn on airplane mode”)
      • a non-phone related action (“show me directions to change car battery”)
      • the list can go on and on…
    • Once we’ve determined “Union Square” is a point of interest and you want navigational directions to be shown on your screen (not printed), the next is to determine directions from where to where, exactly?
    • Assumption: starting place is current location. Where is “current location”? Current location can be obtained using GPS (this is a context).
    • Based on current GPS data (again, context), since you’re in New York City, you’ll be shown directions to the Union Square on 14th St. in Manhattan instead of the one in San Francisco.

Measuring Confidence Level

AI is all about educated guesses and confidence level. Let’s jump right into an example:

“Text Alex I’ll be home late”
  • First “Text Alex I’ll be home late
    • Intent: text – send an SMS text message
    • Text who & what? Parameter: “Alex I’ll be home late”
  • Next, figure out what “Alex I’ll be home late” means
    • The first word “Alex” sounds like a name. Continuing search to the next word…
    • The second word, “I’ll” is a common English word. It’s safe to assume “I’ll” won’t be part of the recipient’s name (“Alex I’ll” isn’t very likely to be a name). Remember, AI is all about educated guesses and confidence level.
    • The bot has access to the user’s contacts list (one of the many contexts the bot will utilize)
    • The bot found few “Alex”(s) in the contacts list.
    • The bot also know that “Alex” is a common abbreviation for “Alexander” and “Alexandra”.
    • Now, the bot has to figure out which one of these Alex(s), Alexander(s), and Alexandra(s) the user would like the message to be sent to.
    • The bot can utilize several contexts to make this determination. For example:
      • Which Alex the user interacts with most frequently?
      • Guessing from the message content, “I’ll be home late”, this seems like a message most commonly sent to a member of the user’s household. Does any of the Alex(s) share the user’s last name or listed as a family member on the user’s phone?
      • Let’s say the user’s last name is “Doe”, the bot can make the following analysis:
      • Note: in the illustration above, the confidence level is picked arbitrarily, for illustrational purposes only.
    • Once you’ve determined which Alex (the Alex with the highest confidence level) to send it to, the computer has completed its analysis.
    • Extra: it is common for bots to confirm with the user first if it has understood the user correctly before performing this kind of actions (sending text messages or email). As a safety precaution 🙂

Machine Learning

A great bot asks fewer questions, make assumptions, and correct those assumptions later – as it learns more about the user.

AI chat bots works better (in determining confidence level) when it has a vast amount of data – let it be of past interactions with the bot or data to be used as context – to use as guidelines when making decisions. Machine learning is the continual process of computers improving its “guessing” accuracy by learning from a data set. The more data it can learn from, the better.

Happy chat-botting!

Ryan Harijanto

Head of Engineering. Former Sr. Engineer @Netflix , @HotelTonight , @Shutterstock. Previously a Senior Systems Engineer at Netflix, currently technology advisor and board member for emerging companies. Diverse technological knowledge and understanding of various industries.

Leave a Reply

Your email address will not be published. Required fields are marked *