Nobody likes to be alone always, but sometimes loneliness could be a better medicine to hunch the thirst for a peaceful environment. Even during such lonely quarantines, we may ignore humans but not humanoids. Yes, if you have guessed this article for a chatbot, then you have cracked it right. We won’t require 6000 lines of code to create a chatbot but just a six-letter word “Python” is enough. Let us have a quick glance at Python’s ChatterBot to create our bot. 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.
Installation
Install chatterbot using Python Package Index(PyPi) with this command
pip install chatterbot
Below is the implementation.
# Import "chatbot" from # chatterbot package. from chatterbot import ChatBot # Inorder to train our bot, we have # to import a trainer package # "ChatterBotCorpusTrainer" from chatterbot.trainers import ChatterBotCorpusTrainer # Give a name to the chatbot “corona bot” # and assign a trainer component. chatbot=ChatBot('corona bot') # Create a new trainer for the chatbot trainer = ChatterBotCorpusTrainer(chatbot) # Now let us train our bot with multipple corpus trainer.train("chatterbot.corpus.english.greetings", "chatterbot.corpus.english.conversations" ) response = chatbot.get_response('What is your Number') print(response) response = chatbot.get_response('Who are you?') print(response) |
Output:

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
Recommended Posts:
- Simple Chat Room using Python
- Converting WhatsApp chat data into a Word Cloud using Python
- GUI chat application using Tkinter in Python
- Google Chrome Dino Bot using Image Recognition | Python
- Python | Whatsapp birthday bot
- How to make a Twitter Bot in Python?
- Python - Making a Reddit bot with PRAW
- How to Configure Socket.IO with Demo-Chat App in Node.js ?
- Node.js Bot.sendVideo() Method
- Node.js Bot.sendPhoto() Method
- Making a Github Bot
- Node.js Bot.sendVoice() Method
- Node.js Bot.sendDocument() Method
- MySQL-Connector-Python module in Python
- twitter-text-python (ttp) module - Python
- Import module in Python
- OS Module in Python with Examples
- struct module in Python
- Fraction module in Python
- Secrets | Python module to Generate secure random numbers
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

