Introduction
Objective
Introduce the basic concepts behind chatbots, explain how they are classified, and trace their history and the main approaches to building them.
1.1 Background
For many people, a chatbot such as ChatGPT is now an essential tool for getting work done, drafting emails, and translating text. What once inspired amazement has become something people rely on. In this book, a chatbot is a computer program that simulates human conversation through text or audio. It can answer questions, chat about a range of topics, or help carry out a specific task, such as opening a bank account or booking a flight to see your favorite singer.
To understand how we got here, it helps to look back at the term itself. ELIZA, created by Weizenbaum (1966), is often cited as one of the earliest examples of conversational software. The term “chatbot” was not yet in use in the 1960s. Michael Mauldin popularized the related term “chatterbot” in 1994 while describing his program JULIA (Mauldin 1994). Later publications, including the proceedings of the 1998 Virtual Worlds and Simulation Conference (Jacobstein et al. 1998), helped establish these terms among researchers.
ELIZA was a landmark experiment in human–computer interaction (Weizenbaum 1966). Its best-known script, DOCTOR, used simple pattern matching to mimic a psychotherapist. If a user typed “I’m sad,” for example, ELIZA could respond, “Why are you sad today?” The program turned the user’s statement into a question.
ELIZA relied on a small set of rules and substitutions. The DOCTOR script worked well for a simple form of dialogue because its replies needed little knowledge of the outside world. Its rules could produce a follow-up question or reflect the user’s statement back to them. Keyword matching and sentence transformations made the conversation sound natural.
Note
Chapter 2 explains how ELIZA and the DOCTOR script work, with examples in Python.
OpenAI’s ChatGPT is another well-known chatbot. It uses deep neural networks to generate humanlike text from the prompts and information it receives. It can translate and summarize text, answer questions, and explain concepts. Its replies can convey empathy even though the system has no conscious experience of emotion.
ChatGPT is powered by large language models (LLMs) based on the Transformer architecture, introduced in 2017 (Vaswani et al. 2017). Models of this kind are trained on large collections of text. Self-attention lets the model weigh relationships among tokens while processing a sequence. ELIZA used rules written by hand. LLMs learn language patterns from training data.
ELIZA and ChatGPT illustrate the conversational chatbot category. They appeared decades apart, in 1966 and 2022 respectively, and produce replies in very different ways. Both can answer questions or sustain a dialogue on a given topic. Conversational chatbots are designed for exchanges on general topics.
Task-oriented chatbots help users complete specific actions, such as opening a bank account or ordering a pizza. Businesses often build them around predefined conversation flows that incorporate business rules. A customer who opens a chat to order a pizza will usually expect help placing the order. A discussion of Immanuel Kant’s ethics can wait until dinner.
These categories describe two common objectives. A single application can offer modes with different objectives. Figure 1.1 uses ChatGPT and Claude as examples. The chat mode of each application focuses on dialogue. ChatGPT Work and Claude Cowork focus on carrying out tasks. The next section discusses how chatbots relate to agents. For a fuller treatment of agents, see our book Construindo Agentes.

Figure 1.1. Chatbots by purpose, with examples of modes in ChatGPT and Claude.
Chatbots have become more popular across a range of applications (Marcondes et al. 2020; Klopfenstein et al. 2017; Sharma et al. 2020). Figure 1.2 shows growing interest in the search term “chatbot” in Google Trends between 2020 and 2025. The scale represents relative search interest over time. A value of 100 marks the peak for the selected period. A zero can indicate too little data to report a value.

Figure 1.2. Search interest in “chatbot” (Google Trends, 2020–2025). Data accessed April 5, 2025.
1.2 Agents
The terms “chatbot” and “agent” are sometimes used interchangeably. A chatbot is designed to interact with users in natural language. The concept of an agent is broader. An agent perceives its environment through sensors and acts on it through actuators.
Under that definition, a chatbot (Figure 1.4) can be viewed as a particular kind of agent whose primary purpose is natural-language conversation. Figure 1.3 presents the general agent architecture.

Figure 1.3. Conceptual architecture of an agent. Adapted from Russel and Norving (2013).

Figure 1.4. Schematic representation of a chatbot.
Language models based on architectures such as the Generative Pre-trained Transformer (GPT) have changed how the term “agent” is used in conversational software. In this setting, a chatbot primarily generates conversational responses. An agent can also use tools, such as a browser, a code interpreter, or an API, to take actions in its environment. For example, a system that can navigate a retailer’s website, confirm a delivery address, and complete a purchase through the browser is acting as an agent.
1.3 Conversation Flow
A chatbot responds to user input, but a conversation is more than a series of isolated exchanges. Each turn should follow logically from the preceding turns and connect to what has already been said. Conversation analysis studies how people organize interactions to achieve that coherence.
In his work on conversation in Portuguese, Marcuschi (Marcuschi 1986) examined how related turns form coherent units. One such unit is the conversational topic, which groups turns that deal with the same subject or serve the same purpose. Chatbot developers have applied ideas from conversation analysis, such as topic management, to keep dialogues coherent and relevant to the user (Neves and Barros 2005).
In conversational software, the sequence of possible turns is often called the conversation flow or dialogue flow. How explicitly a system models that sequence depends on its purpose and complexity.
Figure 1.5 shows a simple example. A user types “I want pizza.” The chatbot asks whether it should deliver the order to the user’s home. If the user answers yes, the chatbot confirms that the order is on its way and ends the conversation. If the user answers no, the example chatbot repeats the question. The interaction advances only once the user confirms. This question-and-answer structure is typical of task-oriented chatbots that guide users through a process.

Figure 1.5. An example of a chatbot conversation flow.
Figure 1.6 shows a different kind of flow for a chatbot that sells clothing online.

Figure 1.6. A decision tree for selling clothing online. From Raj (2019).
1.4 A Brief History
A major milestone after ELIZA was ALICE, which introduced Artificial Intelligence Markup Language (AIML), an XML-based markup language (Wallace 2000). AIML gave developers a way to build conversational agents from reusable units of knowledge. Its rules match user input against predefined patterns and associate each pattern with a response.
Cybele, inspired by ELIZA, was one of the earliest documented Brazilian chatbots that could converse in Portuguese (PRIMO and COELHO 2001). Elecktra was later developed in Portuguese for distance education (Leonhardt et al. 2003). In 2019, a chatbot offered a conversational interface for registration for Brazil’s National High School Examination (ENEM), as shown in Figure 1.7.

Figure 1.7. Chatbot interface for registration for Brazil’s 2019 National High School Examination (ENEM).
Major companies also invested in conversational systems. IBM developed Watson to tackle open-domain question answering, a difficult problem in artificial intelligence. In 2011, Watson demonstrated what it could do by beating human contestants on the quiz show Jeopardy! (Ferrucci 2012).
Other systems were built for particular domains. BUTI used affective computing to support cardiovascular health (Junior 2008). EduBot helped users develop ontologies based on description logic (Lima 2017). PMKLE was an intelligent learning environment for project management (Torreao 2005). RENAN used description logic in an intelligent dialogue system (Azevedo 2015), and MOrFEu supported collaborative work in intelligent web environments (Bada 2012).
The LLM era has brought a wider range of systems, including Alibaba’s Qwen, DeepSeek, Brazil’s Portuguese-focused Maritaca, Google’s multimodal Gemini, Mistral AI’s Le Chat, Meta AI with its Llama model family, Anthropic’s Claude, NVIDIA’s Nemotron model family, and xAI’s Grok.
1.5 Approaches to Building Chatbots
Since ELIZA, developers have explored approaches including AIML pattern matching, syntactic parsing, Markov chain models, ontologies, recurrent neural networks (RNNs), long short-term memory networks (LSTMs), sequence-to-sequence models, adversarial learning for dialogue generation, and retrieval-based and generative methods (Borah et al. 2018; Ramesh et al. 2017; Shaikh et al. 2016; Abdul-Kader and Woods 2015; Li et al. 2018).
-
ELIZA. An early chatbot that influenced later conversational systems through its use of simple pattern matching to simulate a psychotherapist (Weizenbaum 1966).
-
AIML. An XML-based markup language used by ALICE. Its rules map patterns in user input to predefined replies (Wallace 2000).
-
Transformers. An attention-based neural network architecture that transformed natural language processing (Vaswani et al. 2017). BERT and GPT are examples of Transformer-based models used in modern chatbot systems.
Frameworks such as CrewAI (CrewAI 2025) and Mangaba.AI (Mangaba AI 2025), along with tools available through Hugging Face, provide Python abstractions for coordinating components and connecting agents to external tools.
1.6 Do Chatbots Think?
Despite progress in conversational systems, the mechanisms behind human-level intelligence are still poorly understood. Shum and colleagues identify several areas for further research, including empathetic dialogue, knowledge and memory modeling, interpretable and controllable machine intelligence, and the design of reward signals that account for emotion (Shum et al. 2018).
For a rule-based, task-oriented chatbot such as ALICE, one challenge is managing the conditional logic that determines where a dialogue goes next (Raj 2019). Each additional decision can add branches. A chatbot that supports a complex task needs a flow that accounts for the relevant decisions and conditions. A flowchart makes those paths easier to see before they are implemented.
Note
Chapter 2 explains AIML in detail.
AIML systems store knowledge in files. Content compiled from the web needs maintenance if the underlying information changes (Madhumitha et al. 2015). Researchers have explored producing AIML from XML files (Macedo and Fusco 2014), text corpora (De Gasperis et al. 2013), and Twitter data (Yamaguchi et al. 2018). No-code tools can also generate AIML from flowcharts (G. S. Neo et al. 2023).
As in ELIZA, patterns can become complicated. Adding a single AIML category can be straightforward, but manually entering and maintaining many categories takes time (Madhumitha et al. 2015). In a text file, the connections between categories can also be difficult to trace. No-code authoring tools help users create and customize chatbots through an interface that does not require programming skills (Silva Neo et al. 2023).
An LLM-based chatbot generates language by predicting tokens given a context. Its neural network learns statistical regularities in language from large training collections. During generation, the model estimates a probability distribution for the next token, then uses a decoding strategy to select a token and repeat the process.
Models represent complex relationships in high-dimensional vectors. Those relationships help the model generalize across contexts and produce responses that explain, argue, or summarize. Deep learning, attention, and large text corpora make this approach flexible across domains and help sustain coherence over a conversation.
Fluency can make an incorrect or inconsistent response sound convincing. When evaluating a reply, distinguish its plausibility from whether its facts and reasoning hold up.