Bot Basics, Bot Development

Behind The Scenes of Chatbots: Using NLP to Power a Chatbot

Explore chatbot architecture, and learn about how natural language processing works in a chatbot. Plus, find out what intents and entities of a message are.

By Aarushi Ramesh
July 11, 2019

Similar to the Genie from Aladdin, chatbots have the ability to fulfill any user’s wish—a realistic wish, of course. Whether it’s making an online purchase or getting a weather update, chatbots have it all. There is a reason chatbots are among the leading technological intelligence tools. From automated online shopping via text to your vehicle’s phone voice recognition system, chatbots are essential tools used to communicate with humans to perform tasks. But how does a chatbot translate the human language to its own, and how does it understand the message and perform the task required by the user? The answer to these questions is natural language processing (NLP).

About natural language processing

NLP is a form of artificial intelligence (AI) that allows chatbots to understand and respond to the user’s message. Artificial intelligence is the science of making machines and computers do tasks that require human intelligence. So NLP essentially falls into the ocean of AI and plays a super important role when it comes to building chatbots. Without NLP, chatbots wouldn’t be able to differentiate between certain phrases. For example, we need NLP to help give context to the chatbot so that it understands the difference between “Hi” and “See ya.”

How does NLP work in a chatbot?

In order for the chatbot to understand the user’s message, it needs to somehow convert the unstructured human language to structured data that computers can interpret. When a user sends a message to the chatbot, it needs to use algorithms to get meaning and context from every sentence to collect data from them. This process is called natural language understanding (NLU), and it’s a subset of natural language processing. It consists of interpreting the user’s message by extracting important and relevant details from it.

A way to extract the essential parts of a sentence is to differentiate between the entities and the intent. An intent of a sentence is the goal of the statement. What does the user actually want to achieve? For instance, if the message was, “When does the Chipotle at 24th Street close?” the intent of the message is to know when the restaurant closes. An entity of a sentence is something that modifies or supports the intent. For instance, the entities of the question, “What are your closing hours on Tuesday?” are Tuesday and closing hours. An entity is basically anything that can be named (like place, person, name, or object).

The chatbot basically needs to recognize the entities and intents of the user’s messages. In order to do that, we need to build an NLP model for every entity for an intent. For example, we can build an NLP intent model for the chatbot to recognize when a user wants to know the opening hours of a place. We can build an NLP entity model for the chatbot to recognize locations and directions. We can then use these NLP models for the chatbot to offer the opening hours of any place, based on the user’s location.

The NLP process is a core part of the chatbot architecture and process, since it is the foundation for translating the natural human language to structured data.

Diagram of chatbot architecture

The chatbot process breaks down this way:

1.) Let’s say you want to purchase something and you decide to use the help of a chatbot. You type in your request.
2.) When you send a message to the chatbot, asking to purchase something, the chatbot sends the plain text to the NLP engine.
3.) The NLP engine, which uses natural language processing and NLU, converts the text message into structured data for itself. This is where the different NLP models come into play for extracting the intents and entities of the message.
4.) The chatbot moves the data that was collected (the intents and entities) to the decision-making engine.
5.) The decision-making model derives a solid decision based on previous actions and results taken. (It makes a call to the database to make a decision.)
6.) This is where the chatbot converts the decision data to text. Natural language generation (NLG) consists of converting data into plain text. Using NLG, the message generator outputs the message. This message is presented to the user in the form of a text message or voice.

This is where the chatbot converts the decision data to text. Natural language generation (NLG) consists of converting data into plain text. Using NLG, the message generator outputs the message. This message is presented to the user in the form of a text message or voice.

Amazon Lex and NLP

Amazon Alexa is a great example of how NLP is used to feed in the user’s message and to output the decision message. Alexa is powered by Amazon Lex, which is an amazing resource to implement deep learning tools, such as automatic speech recognition (ASR) and conversational platforms (through voice or text). One interesting feature offered by Amazon Lex is its NLU platform, which extracts the intent of the user’s message and delivers an appropriate and accurate response.

Conclusion

Natural language processing holds great significance when it comes to building chatbots. NLP is the main tool used for the chatbot to interpret the user’s intent properly and accurately. Just like how AI is an broad and enormous field, natural language processing is also essentially an ocean of different algorithms used to convert text to important data for the chatbot to use. So the next time you use a chatbot, think about how NLP gives it the power to grant our wishes.

Leave a Reply

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