Python Turing Test - Creating a chatting robot (Chat bot). (2022)

Table of Contents
KS2: New Tutorial FAQs Videos

NOTE:A self-guided (in-browser) tutorial version of this lesson (suitable for remote learning) can be found by here:
Chat bot tutorial


  • Design, write and debug programs that accomplish specific goals; solve problems by breaking them into smaller parts. Select, use and combine a variety of software on a range of digital devices to design and create a range of programs.
  • Use sequence, selection and repetition in programs; work with variables and various forms of input and output
  • Use logical reasoning to explain how some simple algorithms work; detect and correct errors in algorithms and programs


  • Use two or more programming languages, at least one of which is textual, to solve a variety of computational problems.


  • 5a: Studentsbreak problems into component parts, extract key information, and develop descriptive models to understand complex systems or facilitate problem-solving.
  • 5c: Studentsbreak problems into component parts, extract key information, and develop descriptive models to understand complex systems or facilitate problem-solving.
  • 5d: Studentsunderstand how automation works and use algorithmic thinking to develop a sequence of steps to create and test automated solutions.


  • 4b:Design authentic learning activities that ask students to leverage a design process to solve problems with awareness of technical and human constraints and defend their design choices.


  • 2a:Plan and teach computer science lessons/units using effective and engaging practices and methodologies:

i. Select a variety of real-world computing problems and project-based methodologies that support active and authentic learning and provide opportunities for creative and innovative thinking and problem solving

ii. Demonstrate the use of a variety of collaborative groupings in lesson plans/units and assessments

iii. Design activities that require students to effectively describe computing artifacts and communicate results using multiple forms of media

iv. Develop lessons and methods that engage and empower learners from diverse cultural and linguistic backgrounds

v. Identify problematic concepts and constructs in computer science and appropriate strategies to address them

vi. Design and implement developmentally appropriate learning opportunities supporting the diverse needs of all learners

vii. Create and implement multiple forms of assessment and use resulting data to capture student learning, provide remediation and shape classroom instruction

CSTA K–12 CS Standards:

  • 1B-AP-08:Compare and refine multiple algorithms for the same task and determine which is the most appropriate.
  • 1B-AP-09:Create programs that use variables to store and modify data.
  • 1B-AP-10:Create programs that include sequences, events, loops, and conditionals.
  • 1B-AP-11:Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process.
  • 1B-AP-13:Use an iterative process to plan the development of a program by including others' perspectives and considering user preferences.
  • 1B-AP-15:Test and debug (identify and fix errors) a program or algorithm to ensure it runs as intended.
  • 1B-AP-17:Describe choices made during program development using code comments, presentations, and demonstrations.
  • 2-AP-11:Create clearly named variables that represent different data types and perform operations on their values
  • 2-AP-12:Design and iteratively develop programs that combine control structures, including nested loops and compound conditionals.
  • 2-AP-15:Seek and incorporate feedback from team members and users to refine a solution that meets user needs.
  • 2-AP-16:Incorporate existing code, media, and libraries into original programs, and give attribution.
  • 2-AP-17:Systematically test and refine programs using a range of test cases.
  • 3A-AP-14:Use lists to simplify solutions, generalizing computational problems instead of repeatedly using simple variables.
  • 3A-AP-15:Justify the selection of specific control structures when tradeoffs involve implementation, readability, and program performance, and explain the benefits and drawbacks of choices made.


Computation is the foundation for our digital world.

Progression step 3

  • I can use conditional statements to add control and decision-making to algorithms.
  • I can identify repeating patterns and use loops to make my algorithms more concise.
  • I can explain and debug algorithms.

Progression step 4

  • I can decompose given problems and select appropriate constructs to express solutions in a variety of environments.
  • I can select and use data structures that efficiently manage data in algorithms.
  • I can plan and implement test strategies to identify errors in programs.

Progression step 5

  • I can identify, define and decompose problems, choose appropriate constructs and express solutions in a variety of environments.
  • I can use file-handling techniques to manipulate data in algorithms.
  • I can test, evaluate and improve a solution in software.


Can computers think? This was a question posed by computer pioneer and artificial intelligence (AI) theorist, Alan Turing. Turing proposed that, given time, a computer with sufficient computational power would acquire the abilities to rival human intelligence. In order to test his theory, Turing devised a test.

The Turing Test was based on a Victorian parlour game in which a judge (or interrogator) asks a series of questions to a man and a woman in a separate room. By reading a series of typed answers, the judge must determine which replies were from the man and which were from the woman.

(Video) Build your own chatbot using Python | Python Tutorial for Beginners in 2022 | Great Learning

Turing adapted the test by replacing the woman with a computer - the aim being to decide whether the answers were from a man or computer thus determining if a computer was able to think for itself.

To find out more about Alan Turing and the Turing Test, click on the links below:

Lesson Outline:

In this brief introduction to programming using Python, students are going to create a chatting robot (chat bot) designed to confuse the user into thinking that they are talking to a real person.


Show the video “Project Natal – Milo demo”. At the end of the video explain to students that for years, science fiction writers and filmmakers have dreamed about robots that can think for themselves however, despite giant leaps in technology, this dream is still far from reality. Explain to students that to explore the reasons why it is so difficult to make a thinking robot, they are going to create their very own chatting robot (chat bot).

Task 1:

Direct students to one of the online chat bots listed below. Instruct students to ask the chat bots a series questions and note down any unusual or unexpected answers.

Note:Some online chat-bots learn from previous conversations. As a result, there may be some cases where what the chat bot says may be deemed as inappropriate. Use these sites at your own risk. is not responsible for the content of external Internet sites.

Online chat bots:

After a few minutes, stop the class and ask them to feedback their findings to the rest of the class.

Note down some of the students’ findings and ask the students why they think the chat bot could not answer all of their questions.

Ask the students why you think it is so hard to make a computer appear as if it able to think like a human. Try to draw out answers such as “Computers can only follow a given sequence of instructions” or “Computers can only respond to questions they have been programmed to answer” – give students prompts where necessary.

Explain to students about the Turing Test (insert link to wikipedia) and discuss the concept of Artificial Intelligence (AI). Finally, inform students that they are going to create a chatting robot (chat bot) and that there will be a prize for the most convincing robot (the prize is optional).

STEP 1 - Creating the chat bot

In order for the chat bot to work, the students will need to import the time and random libraries. Instruct students to type in the following code:

​import time
import random

​Next, we need to ask the user a question and store the response in a variable. Instruct students to input the following:

name = input("Hello, what is your name? ")

(Video) Google Engineer on His Sentient AI Claim

​Next, we want to give the user the impression that they are chatting to a real person, therefore, we need to place a pause in-between each new question / response. To do this, we will use the time `time.sleep()`. Instruct students to enter the following:


​Next, we need to create a response from the computer. We want the reply to sound personalised so we are going to add the users name to the end of the response. To do this, we will use the concatenation `+` command. Instruct students to add the following code to their script:

print("Hello " + name)

Next we are going to ask the user how they are feeling. We will store this in a variable called 'feeling'. Instruct students to add the following:

feeling = input("How are you today? ")

Next, we are need to create a response. In order for the computer to appear human, we need to have a set of different responses. To do this, we will use an `if` statement. We will start with the response for 'if' the user is feeling "good". Instruct students to add the following:

​if "good" in feeling:
print("I'm feeling good too!")
print("I'm sorry to hear that!")

So far, there is very little variation in our answers. In order to make our chat bot appear more human, we are going to add a list of random possible answers.
​First, ask students to add an input() asking the user to enter their favourite colour (remembering to add a natural pause):

favcolour = input("What is your favourite colour? ")

Next, instruct students to create a list of possible responses:

colours = ["Red","Green","Blue"]

(Video) How to make a Chatbot from AI to Program Your Voice |

Finally, instruct students to add a response by choosing a colour from the list at random:

print("My favourite colour is " + random.choice(colours))

The students finished code should look like this:


  • There is a problem with the code. The code in Python is case sensitive therefore, if we were to type in "Good" (Uppercase G) instead of "good" in response to the question "How are you feeling?" Python will not find a match and will therefore reply with "I'm sorry to hear that!". In order to get around this problem, we can convert the users reply to lower case using the `lower()` command. Instruct students to modify their code as follows:

if "good" in feeling.lower():
print("I'm feeling good too!")

  • At the moment, we only have two responses to the question "How are you feeling?" Challenge students to add some more responses to make the chat bot appear more realistic.For example:

feeling = input("How are you today? ")
if "good" in feeling:
print("I'm feeling good too!")
elif "awesome" in feeling:
print("I'm feeling awesome too!")
print("I'm sorry to hear that!")

Challenge students to:​

  • Add some more questions and responses
  • Comment their code explaining how it works.
  • Add a random pause between each question and answer:



Direct students to swap places with a partner or person next to them and try out their chat bot. Instruct the students to leave a comment in their partner’s code suggesting at least one improvement. After a few minutes, ask the students to return to their seats and make any suggested improvements.

(Video) Passing the Turing Test: ELIZA the Chatbot | Minds and Machines | Dr. Josh Redstone

As an extra incentive, you could offer a prize for the most convincing chat bot (almost like a mini Loebner Prize - However, rather than rewarding the students with $6,000 for creating the most convincing chat bot, I suggest some chocolate instead!


Students can continue to work on their chat bot and publish their script when they have finished.


Example solution

Download File

You may also be interested in:

  • Python Shakespearean insult generator
  • Python Mad Libs
  • Code Golf
  • Python Sorting Hat
  • Python Magic 8-Ball
  • Cards Against Humanities

New Tutorial


Unless otherwise specified, everything in this repository is covered by the following licence:

Python Turing Test - Creating a chatting robot (Chat bot). (3)

Python Turing Testis licenced under aCreative Commons Attribution 4.0 International License.

Based on a work at

(Video) Chatting with ELIZA - The Legendary COMPUTER PSYCHOTHERAPIST (and the first NLP program ever)


Can you make a chat bot with python? ›

ChatterBot is a Python library built based on machine learning with an inbuilt conversational dialog flow and training engine. The bot created using this library will get trained automatically with the response it gets from the user.

How do you make a question and answer chatbot in python? ›

Here's how to make and deploy a question answering bot from scratch in five minutes with python

Which python framework is best for chatbot? ›

Golem is a python framework for building chatbots. It is built for python developers and it can easily extract entities from existing messages. It features its own web GUI for ease of testing and can interact with messages from Messenger and Telegram.

What are the 7 steps to create a chatbot strategy? ›

  1. Step 1: Gather information about your potential customers. ...
  2. Step 2: Decide what the bot is going to do to meet customer expectations. ...
  3. Step 3: Select a platform & build your bot. ...
  4. Step 4: Check if the chatbot works & improve it further. ...
  5. Step 5: Launch your chat box & monitor its activity.

How do I code AI chatbot? ›

How to make a chatbot from scratch in 8 steps
  1. Step 1: Give your chatbot a purpose. ...
  2. Step 2: Decide where you want it to appear. ...
  3. Step 3: Choose the chatbot platform. ...
  4. Step 4: Design the chatbot conversation in a chatbot editor. ...
  5. Step 5: Test your chatbot. ...
  6. Step 6: Train your chatbots. ...
  7. Step 7: Collect feedback from users.
23 Aug 2022

What Is Jarvis in Python? ›

JARVIS is a Voice-Based AI Assistant which is developed in Python Programming Language. It uses Different Technologies To Add New Unique Features. It can Automate Tasks with just One Voice Command. It is a Desktop Based AI Assistant.

How do you make a question and answer bot? ›

Create a bot
  1. In Language Studio, on the question answering Deploy knowledge base page, select Create bot.
  2. A new browser tab opens for the Azure portal, with the Azure Bot Service's creation page. ...
  3. After the bot is created, open the Bot service resource.
  4. Under Settings, select Test in Web Chat.
3 Jun 2022

How do you make a simple chatbot in Python? ›

In this Article, you will learn about How to Make a Chatbot in Python Step By Step.
  1. Prepare the Dependencies.
  2. Import Classes.
  3. Create and Train the Chatbot.
  4. Communicate with the Python Chatbot.
  5. Train your Python Chatbot with a Corpus of Data.
22 Sept 2022

Does chatbot use AI? ›

Chatbots, also called chatterbots, is a form of artificial intelligence (AI) used in messaging apps. This tool helps add convenience for customers—they are automated programs that interact with customers like a human would and cost little to nothing to engage with.

Which is the best chatbot platform? ›

Here are the 10 of the best AI chatbot platforms to build the exact right bot for your business.
  1. Lobster by EBI.AI. EBI.AI have created their own advanced conversational AI platform that comes with a free trial. ...
  2. ProProfs Chat. ...
  3. Chatfuel. ...
  4. MobileMonkey. ...
  5. Aivo. ...
  6. ItsAlive. ...
  7. Imperson. ...
  8. Pandorabots.
12 Sept 2022

Which library is used in chatbot? ›

ChatterBot is a Python library that makes it easy to generate automated responses to a user's input. ChatterBot uses a selection of machine learning algorithms to produce different types of responses. This makes it easy for developers to create chat bots and automate conversations with users.

Is Rasa chatbot free? ›

RASA :Build and Deploy Chatbot On The Cloud (100% FREE)

How long does it take to build a chatbot? ›

Implementing a chatbot takes 4 to 12 weeks, depending on the bot's scope, the time required to build your knowledge base and its technical complexity.

What is required to build a chatbot? ›

Chatbot Frameworks are is a kind of an SDK that allows developers to build using NLP, NLU, and various other cutting edge techniques. Frameworks offer basic building blocks like intent, context, entities, and conversation design, based on which developers need to build bots by coding.

What are the best practices in chatbot building? ›

6 Best Practices For Chatbots
  • 1) Set Expectation for your Chatbots.
  • 2) Be mindful of the Chatbot's greeting.
  • 3) Be Upfront About Bot Functionality.
  • 4) Try to make the messages as human as possible.
  • 5) Make it Easy For Your Customers To Leave.
  • 6) Reengage Users Through The Chatbot.

How do you create a smart AI? ›

To make an AI, you need to identify the problem you're trying to solve, collect the right data, create algorithms, train the AI model, choose the right platform, pick a programming language, and, finally, deploy and monitor the operation of your AI system.

How do you make a chatbot in Python NLP? ›

Building an NLP chatbot
  1. Step one: Importing libraries. Imports are critical for successfully organizing your Python code. ...
  2. Step two: Creating a JSON file. ...
  3. Step three: Processing data. ...
  4. Step four: Designing a neural network model. ...
  5. Step five: Building useful features.
14 Apr 2022

Can I make my own Jarvis? ›

The answer is yes!

In 2016, Facebook founder Mark Zuckerberg revealed his own version of Tony Stark's artificial intelligence system, Jarvis, after spending a year writing computer code and teaching it to understand and his voice.

Can we make AI like Jarvis? ›

Yes. It is possible. It might seem impossible now considering the level of Hardware and Intelligence required to build such a system.

Can we code Jarvis? ›

Yes, you heard it right. We can create our own J.A.R.V.I.S. using Python.

How do I activate answer Bot? ›

To activate Answer Bot

In Admin Center, click the Channels icon ( ) in the sidebar, then select Bots and automations > Article recommendations. Click the Activate Answer Bot button (Zendesk Suite users) or Try Answer Bot for 30 days to activate your 30-day unlimited trial (Support + Guide users).

What is AWS chatbot? ›

AWS Chatbot is an interactive agent that makes it easier to monitor and interact with your AWS resources in your Slack channels and chat channels.

How do you create AI in Python? ›

How to make your first AI in Python
  1. Step 1: Create a new Python program. ...
  2. Step 2: Create greetings and goodbyes for your AI chatbot to use. ...
  3. Step 3: Create keywords and responses that your AI chatbot will know. ...
  4. Step 4: Import the random module. ...
  5. Step 5: Greet the user.
28 Mar 2022

Is WhatsApp a chatbot? ›

WhatsApp chatbot is an automated software powered by rules or artificial intelligence (AI) and runs on the WhatsApp platform. People communicate with WhatsApp chatbot via the chat interface, like talking to a real person. It's a set of automated replies that simulates a human conversation on WhatsApp.

Is Alexa a chatbot? ›

Alexa is formally a chatbot.

What is the most powerful chatbot? ›

14 Most Powerful Chatbot Development Platforms To Build A Chatbot For Your Business
  • Octane AI. ...
  • Flow XO. ...
  • ManyChat. ...
  • Botsify. ...
  • Chatfuel. ...
  • Pandorabots. ...
  • BotsCrew. ...
  • Aivo. Aivo's bots offer robust customer service and gives you the ability to respond to customers in real-time, through text as well as voice.

How much does it cost to build a chatbot? ›

The chatbot development price may vary from $5,000 to $150,000 as the cost is calculated and varies for every case. Most software agencies and companies charge about $15,00 to $31,000 for a customized bot. Some companies set a bottom price of $30,000 only for a simple bot.

What is the most advanced AI chatbot? ›

Best AI Chatbots for 2022
  • Alexa for Business. 4.4.
  • Drift. 4.4.
  • Salesforce Einstein. 4.4.
  • Dasha AI. 4.3.
  • SurveySparrow. 4.25.
  • LivePerson. 4.2.
  • ManyChat. 4.15.
  • Intercom. 4.1.
19 May 2022

How do I install chatbot in Python? ›

Installing chatbot is very simple, if using pip (see above). If using windows, open up cmd.exe/command prompt and execute pip install chatbot. If using Mac OS X, it is similar to this, but run in terminal. Execute pip install chatbot in terminal.

How make WhatsApp bot in Python? ›

Steps to create a WhatsApp Bot
  1. Step 1: Create a Twilio account by visiting the website.
  2. Step 2: Go to the Twilio WhatsApp website.
  3. Step 3: Connect Twilio with WhatsApp.
  4. Step 4: Install some libraries.
  5. Step 5: Create a flask app.
  6. Step 6: NGROK setup.
  7. Step 7: Twilio connection.
25 Apr 2022

Is Rasa a Python? ›

Rasa is a tool to build custom AI chatbots using Python and natural language understanding (NLU). Rasa provides a framework for developing AI chatbots that uses natural language understanding (NLU). It also allows the user to train the model and add custom actions.

Does Rasa use deep learning? ›

A big part of the capability of chatbots written with Rasa comes from exploiting the natural language processing (NLP) capability that comes by default with Rasa. It's worth mentioning here that Rasa's NLP capability is based on deep learning.

Which is better rasa or Dialogflow? ›

Rasa recently added a Training Data Importers option to import data of different formats and from different sources. In Dialogflow, we do not have the option to import or use training data in any format. Training Tool in Dialogflow accepts only a single line per phrase as training data. You will need to create a .

What is chat bot in Python? ›

ChatterBot is a library in python which generates responses to user input. It uses a number of machine learning algorithms to produce a variety of responses. It becomes easier for the users to make chatbots using the ChatterBot library with more accurate responses.

How do I make a discord bot in Python? ›

Table of Contents
  1. Step 1: Install .
  2. Step 2: Create a Discord application and bot.
  3. Step 3: Create a Discord guild (server).
  4. Step 4: Add the bot into the server.
  5. Step 5: Code the bot.

How do you make a chatting app with coding? ›

Chat App Development Steps: Process Overview
  1. Create a Directory & Install Dependencies. ...
  2. Build the Front-End Chat Interface & Chat Client. ...
  3. Create and/or Connect the Back End (Chat Server) ...
  4. Prioritize Feature Expansion Based on User Feedback.
3 Mar 2021

How do I create a chat server? ›

  1. Step 1: Setup a ServerSocket in the Server Class. ...
  2. Step 2: Create a Socket in the Login Class. ...
  3. Step 3: Create a Loop to Continuously Accept Clients. ...
  4. Step 4: Create the Client Threads. ...
  5. Step 5: Create the Server Thread. ...
  6. Step 6: Make the Client Thread Send and Receive Data. ...
  7. Step 7: Make the Server Thread Send and Receive Data.

What are some Python projects for beginners? ›

Python Project Ideas: Beginner Level
  • Create a code generator. ...
  • Build a countdown calculator. ...
  • Write a sorting method. ...
  • Build an interactive quiz. ...
  • Tic-Tac-Toe by Text. ...
  • Make a temperature/measurement converter. ...
  • Build a counter app. ...
  • Build a number-guessing game.
26 May 2022

How do I make an AI in Python? ›

How to make your first AI in Python
  1. Step 1: Create a new Python program. ...
  2. Step 2: Create greetings and goodbyes for your AI chatbot to use. ...
  3. Step 3: Create keywords and responses that your AI chatbot will know. ...
  4. Step 4: Import the random module. ...
  5. Step 5: Greet the user.
28 Mar 2022

How does chat bot work? ›

A chatbot is designed to work without the assistance of a human operator. AI chatbot responds to questions posed to it in natural language as if it were a real person. It responds using a combination of pre-programmed scripts and machine learning algorithms.

Does chatbot use AI? ›

Chatbots, also called chatterbots, is a form of artificial intelligence (AI) used in messaging apps. This tool helps add convenience for customers—they are automated programs that interact with customers like a human would and cost little to nothing to engage with.

How do you make a chatbot in NLTK? ›

Let's have a look at How to make a chatbot in python? We will divide the Jupyter Notebook into the followings steps
  1. Importing necessary libraries.
  2. Data pre-processing.
  3. Creating training data.
  4. Creating a neural network model.
  5. Create functions to take user input, pre-process the input, predict the class, and get the response.
11 Jan 2022

What is GUI bot? ›

A tool for GUI automation using a variety of computer vision and display control backends.

How do you code a bot in Python? ›

How To Make A Chatbot In Python?
  1. Prepare the Dependencies. The first step in creating a chatbot in Python with the ChatterBot library is to install the library in your system. ...
  2. Import Classes. Importing classes is the second step in the Python chatbot creation process. ...
  3. Create and Train the Chatbot.

How hard is it to make a Discord bot? ›

Creating a Bot account is a pretty straightforward process. Make sure you're logged on to the Discord website. Click on the “New Application” button. Give the application a name and click “Create”.


1. AI vs. AI. Two chatbots talking to each other
2. DLTV - Coding with AI, A Sentimental Chatbot in Python
(DLTV - Digital Learning and Teaching Victoria)
3. Two AIs talk about becoming human. (GPT-3)
(Jack Soslow)
4. How I built the world's no. 1 chatbot, Mitsuku, with Steve Worswick
(VUX World)
5. Talking to a totally-not AI Chatbot, Mitsuku turing test FAIL
(Robert Jene)
6. A gentle introduction on Building an intelligent Chatbot in Python
(TAIR Pursuit - Pursuing SoTA AI)

You might also like

Latest Posts

Article information

Author: Twana Towne Ret

Last Updated: 10/05/2022

Views: 5964

Rating: 4.3 / 5 (64 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Twana Towne Ret

Birthday: 1994-03-19

Address: Apt. 990 97439 Corwin Motorway, Port Eliseoburgh, NM 99144-2618

Phone: +5958753152963

Job: National Specialist

Hobby: Kayaking, Photography, Skydiving, Embroidery, Leather crafting, Orienteering, Cooking

Introduction: My name is Twana Towne Ret, I am a famous, talented, joyous, perfect, powerful, inquisitive, lovely person who loves writing and wants to share my knowledge and understanding with you.