Building SMS Text Bots is a Breeze
As a nerdy guy, I love movies about other nerdy guys. Give me movies like “A Beautiful Mind,” “The Theory of Everything,” or “Einstein and Eddington” (two nerdy scientists for the price of one), and I am in geek heaven. Recently, I was thrilled by “The Imitation Game”—the story of Alan Turing and his quest to break Germany’s WWII secret code. While I would never dare to compare myself to Mr. Turing, I like to think that we would have a few things in common. One area would be our shared interest in natural language processing and intelligent behavior.
Way back in 1950, Turing crystallized his research into these studies in what has become known as The Turing Test. Simply put, The Turing Test is a test of a machine’s ability to impersonate a human being. For a machine to pass The Turing Test, it must be able to participate in a conversation with a human being to the point where the human doesn’t realize that he or she is interacting with a machine. I can only imagine what Turing would think of today’s technology such as Siri, Alexa, and Google Home. Better yet, imagine Alan conversing with the robot, Sophia. Would he be excited or frightened? Personally, I am a little of both.
Real or Not
If you have been reading my articles on No Jitter and here on the Avaya blog, you know how enamored I am of the Breeze and Zang workflow designers. Although I have spent the bulk of my professional life writing software in programming languages such C++ and Java, I have fallen in love with how quickly I can use the Breeze/Zang tools to go from idea, to prototype, to a production-quality application. I like to say that if you can draw it on a whiteboard, you can “code” it with Breeze.
So, the day I decided to build a text bot, I knew exactly how I was going to do it. Starting with a list of things I wanted my text bot to do, I was soon drawing out message flows and decision points (if this, do that). Once I was happy I had captured all the salient points, I turned to my computer and began typing. Early on, I realized that there was no way on earth I could capture all the different text messages my application would need to process. For instance, how many different ways can you ask for the location of a store? “Where are you located?” “What is your address?” “What city are you in?” “How can I find you?” The variations are nearly endless.
To solve this problem, I turned to natural language processing (NLP) and artificial intelligence (AI). That, of course, led me to the 500-pound gorilla in the room—IBM Watson. With Watson, I can build “Conversations” that allow me to create intents, entities, and dialogs. Intents are used to classify a request. You can think of entities as modifiers to those intents. Dialogs are the words you want to “speak” after determining the intent.
For example, consider the phrase “Are you open on Sunday?” Here, the intent could be classified as “hours.” The entity is “Sunday.” A proper dialog could be, “We are open on Sunday from 12:00 to 5:00.” To keep things simple, I created three intents for my bot: Directions, Holidays, Hours. Those intents resulted in three dialogs. I left off entities for now.
My next decision point had to do with maintaining a conversation over many text messages. For that I choose Avaya’s Contest Store, which allows me to temporarily store information about a text conversation. This information can then be accessed over the life of the chat.
Now that I had an engine to process incoming text messages (Watson), and a method of maintaining a chat’s context (Contest Store), it was time to launch the Avaya Breeze Engagement Designer. I will admit that I still had a few logic problems to work through, but I would not be stretching the truth if I said that I had a rough draft of my text bot up and running in less than an hour. Working through those remaining issues consumed another couple of hours, but in a fraction of the time it would take me to write my application in Java, my bot was accepting text messages, building contexts, and texting back replies.
I should also say that my bot is fully multi-user. It didn’t matter if one or one hundred people were all texting in at the same time. My bot kept track of each individual conversation and no one received a text meant for someone else.
While my example bot is fairly simple in terms of what it can handle, the framework is extendable to just about any SMS conversations you might want to support. Future plans have me using Context Store to save the entire conversation between human and machine. Not only could this be useful for determining how accurately my bot responds to incoming requests, but it could also be used to help better serve customers. A recorded chat sessions could be presented to a human agent in the case where the user moved from text to a phone call.
Next, I would love to incorporate some of the other features that Watson provides. For example, by detecting the tone/sentiment of the conversation, my bot could sense if the human was becoming frustrated with the answers he or she was receiving from my bot. This would allow the bot to either escalate the chat to a live agent, or have an agent follow up afterwards to help soothe over what might have been an unpleasant experience – or both.
Human to human conversations aren’t going away anytime soon, but more and more machines are going to step in to handle the easy to moderately hard stuff. The point is not to trick people into thinking they are talking to a human being. The point is that machines can handle tedious jobs without coming across as machines.
While I highly doubt that anyone will ever make a movie about Andrew and his fabulous text bots, it isn’t all about fame and glory, right? This is exciting technology and the fact that I can use Breeze to create sophisticated bots by easily combining powerful, but disparate technologies, is red-carpet stuff.