Home > Javascript games > Chatback

Chatback: Javascript artificial intelligence (AI) simulator bot

Experiment with artificial intelligence using this Javascript chatbot. It won't pass the Turing Test, but it's a fun Javascript game!

Cartoon of Seaneyesmouth
Sean's quote goes here!

Your reply:

How do I chat with this artificial intelligence (AI) bot?

Chat with Virtual Sean by typing what you want to say into the box and then clicking the 'Say it' button. He recognises a few select words and phrases, has some random replies too, and learns new phrases that you type in. He can recommend some other pages on this website too (say 'yes' to follow his recommendation and be redirected there).

This program uses HTML5 speech if it supported by your browser. You can tick the box beside "Silence" to avoid audible output. The voice used will be your system's default voice. Using Chrome on a PC, it's a female voice, and on my iPad it's a male voice.

For best results when playing with this artificial intelligence simulation, type in short sentences, and use pronouns (it, they, he, she etc) where appropriate, so that Virtual Sean is more likely to make sense when he reuses your phrases.

Have fun chatting with Virtual Sean! You can send me suggested additions to his vocabulary.

What is artificial intelligence (AI)?

Artificial intelligence (AI) is all about getting software to do things that emulate human intelligence. There is a famous test for artificial intelligence, the "Turing test", which involves a computer-based chat. The computer is said to have passed the test when a human can't tell whether he or she is chatting with the computer or another person. Although artificial intelligence is demonstrated most powerfully in contexts like these (and in films starring robots!), the concepts of AI are often used in everyday applications such as search engines and customer service chatbots (which attempt to understand what you're looking for). AI has seen a resurgence in recent years, with the growth of deep learning, which uses neural networks to recognise training without needing as much explicit programming as early AI programs did.

How did you make this Artificial Intelligence chatbot demo?

Scan of the article from Internet MagazineI created this AI demo way back in the year 2000, as part of an Internet Magazine article (pictured). This program uses Javascript in this way:

  • It checks for certain "trigger" words that spark a preprogrammed response, which can make the program appear to understand you.
  • In some cases, it will offer to take you to a relevant web page. You can accept the offer by typing in "yes".
  • If it doesn't understand you (which, to be fair, is usually the case), it picks a random response and says that. It then replaces its random response with what you typed in. Over time, it learns to speak like you do.

So I admit it's not that intelligent, really, especially when compared with the state of the art today. But you can have fun with it, and work with it to create a fun conversation. For best results, enter complete sentences, and use pronouns a lot (it, he, she etc). That will mean what you type in is more likely to make some kind of sense when the program randomly says it back to you.

I created a version of this program in Python for the book Raspberry Pi For Dummies. You can download that Python program to experiment with it at the book's webpage, too.

Code and animation by Sean McManus. Images made with South Park Studio by Janina Norn


© Sean McManus. All rights reserved.

Visit www.sean.co.uk for free chapters from Sean's coding books (including Mission Python, Scratch Programming in Easy Steps and Coder Academy) and more!

Discover my latest books

Coding Compendium

Coding Compendium

A free 100-page ebook collecting my projects and tutorials for Raspberry Pi, micro:bit, Scratch and Python. Simply join my newsletter to download it.

Web Design in Easy Steps

Web Design IES

Web Design in Easy Steps, now in its 7th Edition, shows you how to make effective websites that work on any device.

100 Top Tips: Microsoft Excel

100 Top Tips: Microsoft Excel

Power up your Microsoft Excel skills with this powerful pocket-sized book of tips that will save you time and help you learn more from your spreadsheets.

Scratch Programming in Easy Steps

Scratch Programming IES

This book, now fully updated for Scratch 3, will take you from the basics of the Scratch language into the depths of its more advanced features. A great way to start programming.

Mission Python book

Mission Python

Code a space adventure game in this Python programming book published by No Starch Press.

Cool Scratch Projects in Easy Steps book

Cool Scratch Projects in Easy Steps

Discover how to make 3D games, create mazes, build a drum machine, make a game with cartoon animals and more!

Walking astronaut from Mission Python book Top | Search | Help | Privacy | Access Keys | Contact me
Home | Newsletter | Blog | Copywriting Services | Books | Free book chapters | Articles | Music | Photos | Games | Shop | About