The Anatomy of a Chatbot
Let's explore the primary elements of a bot and reveal some of the technical skills you may need to build one.
Join the DZone community and get the full member experience.Join For Free
The use of chatbots in line of business applications is on the rise. We explore the primary elements of a bot and reveal some of the technical skills you may need to build one.
What should developers be thinking about when preparing to build a chatbot? Who better to learn the answer from than someone who has dedicated much of his time to the subject. Hristo Borisov is our in-house expert responsible for the ideation, creation, and development of Progress NativeChat, the artificial intelligence-driven platform for creating and deploying chatbots.
Hristo has written many blog posts on the topic — you can follow him on Medium — but for this article, I picked his brain about the basic building blocks of a chatbot. Here's what I learned from him about the primary elements of a chatbot and some of the skills you may need to build one.
So without further ado, I give you the anatomy of a chatbot.
The backend of the chatbot is designed to handle messages from different channels and process them with Natural Language Processing (NLP) services (more on this the section after Channels). Most backend services support both .NET and Node.js server-side SDKs, so if you have experience with languages that run in either of those two popular frameworks, you are golden.
As of this writing, Microsoft Bot Framework is the most commonly used framework to handle the communication layer of your chatbot (this is certainly the case within the Microsoft community — see my blog post from the Microsoft MVP Summit). Other popular frameworks include Facebook's Wit.ai, Google's DialogFlow, and Amazon Lex.
The best way to think about "Channels" is to think of them as the place where your bot sends and receives messages with your users. Skype, Twilio, Slack, and Facebook all have pre-defined channels that allow your chatbot to live in any of these major chat products — you can essentially create endpoints for integration with their UI.
While every channel integration is different, in general, your channels are established by setting up an endpoint in your backend for sending and receiving messages that rely on access token authorization. Once the channel is established, you can then determine some of the UI by using pre-defined visual elements to help guide the conversation. If you choose not to integrate a pre-defined channel, you can always build your own. Obviously, technology will vary depending on the channel you choose and the framework on which your application is built.
Natural Language Processing
With the backend set up and the channel established, you are ready to send and receive messages. At this point, you will likely employ a Natural Language Processing (NLP) service to extract intents and entities out of the user messages.
Hristo promised me that setting up an NLP service and processing the messages using an SDK for the service is straightforward (the more popular ones like Wit.ai and LUIS all support both .NET and Node.js SDKs). However, he does caution that "training the NLP intents and entities that might be already existing in an external system is not trivial since the NLP services provide UI for inputting the entities and their values manually. You will need to understand entities that map to specific objects that already exist in an existing system such as Products, Contacts, Employees, etc."
He goes on to say "as with any user input, you will need to implement some business logic validation rules on top of the extracted data. It can range from simple validation such as regular expressions, or custom validation calling a web service to check the validity of a pin code."
Conversational intelligence is where the rubber meets the road. Again, Hristo cautions that "designing an intelligent conversation based on the NLP intents and entities is a journey that can be as deep as a black hole." You have to develop an algorithm for each conversation and a simple navigation. You can use simple decision trees, state workflows, slot-based algorithms or some advanced deep learning algorithms to control the conversation. The more intelligent you try to make these bots the less trivial it will be to implement them, hence the black hole.
The final piece is the Conversational UI. We've touched on it a bit as we talked about the channels — visual elements like buttons, calendars, cards — are all essential not just to the look and feel of the chatbot, but they contribute holistically to the natural flow of the conversation.
Let's first focus on the visual. Pre-defined channels provide a stock conversational UI — meaning that a chatbot living in a Facebook channel will have the same look and feel as Facebook. There is nothing wrong with this. That said, developers can break out of a pre-defined stock UI by providing your own UI outside of these channels.
Secondly, we will look at a natural conversation flow. Proper visual guidance can allow the developer to help the user navigate the conversation more effectively. Not only does this provide a better overall experience for the end user, but it means a more productive development cycle for the developer when it comes to NLP and conversational intelligence.
One thing many people don't think of, but a necessary feature that you, the developer will need to build is a health monitor dashboard for your chatbot to provide insight and analytics about your bot. This can be a simple dashboard that allows you to see your chatbots conversation history (although some channels have this feature built-in), explore your users, discover error logs, and more. This is also the place where you can monitor your bot's performance using simple analytics metrics.
As chatbots gain momentum and popularity, we are starting to see a democratization of some of the technical elements — Artificial Intelligence, Machine Learning, Deep Learning, etc. — allowing developers to use their current skills to build chatbots as either an integral part of their applications or as a standalone app. I hope this brief tour piques your interest enough to get out and build one. Use some of the frameworks available to you and see what you can do.
And if you are interested in learning more about Hristo's experience building NativeChat, watch the "Designing a Conversational Chatbot Experience: Tales from the Trenches" webinar recording and get an insider's view into creating efficient human-computer interaction.
Published at DZone with permission of Sara Faatz, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.