Chatbot architecture

A chatbot is nothing but a computer program that can chat with a user and perform certain levels of tasks on behalf of the user. Chatbots seem to have a direct connection between the user's problem and the solution. The main aspects of chatbots are as follows:

The main aspect of a chatbot is to generate a proper or appropriate response to the user's text using some predefined library or database, or using machine learning models to generate a response. A machine learning algorithm allows training bots with lots of examples of data or conversations to pick a pattern. It uses intent classification and entities to generate a response. To find the intents and entities, it uses the concept of Natural Language Understanding (NLU):

Using machine learning for chatbots requires a great understanding of machine learning algorithms, which is out of the scope of this book.

We will be looking into an option where machine learning is not involved, and such a model is called a retrieval-based model, where the response is generated from some predefined logic and context. It is easy to build and reliable, but not 100% accurate in response generation. It is widely used, and several APIs and algorithms are available for such models. It generates a response on the basis of an if...else condition, which is known as pattern base response generation:

It relies on Artificial Intelligence Markup Language (AIML) to record patterns and responses. This will be discussed in the next section.