Skip to main content

Section 25.8 Making a Chatbot

Chatbots are programs that are designed to have conversations with people. Many chatbots are designed for the amusement of people playing a game or interacting with others in an online forum. However, they also are increasingly used as digital assistants - Google developed a technology called Duplex that uses AI to call restaurants and make reservations by talking to the host
Making a full-fledged AI that can respond to unexpected responses and questions is a profoundly complex task. But if our goals are more limited, we can try to make a program that seems smart by forcing the conversation. If we ask questions that require specific answers and count on the user to respond logically, basic conditional code can handle generating our responses. A forced conversation might go like this:
Computer: Hello, what is your name?
User: Greg
Computer: Hello Greg. Nice to meet you. Where do you go to school?
User: Chemeketa
We would test to see if the input has "Chemeketa" in it, if so give this message:
Computer: That is where I live!
Otherwise, we would have the computer say something like:
Computer: Huh, never heard of it.
Then we would continue, and in this case we might just ignore what the user says but answer as though it made sense:
Computer: What is your favorite movie?
User: I like "Rushmore"?
Computer: Oh, that is a pretty good one. I like "The Matrix",
          I just wish it had a happy ending.
Write a chatbot that asks the user at least three questions and then uses the user’s input to build its answer or make a decision about what to say. (You can add extra questions like the last one where the computer asks a question but then does not look at the response, but those do not count towards the three-question minimum.) Try to come up with your own questions instead of just copying the samples above!
You have attempted of activities on this page.