How to create a simple chatbot
creating a simple chatbot can be done in a few steps here’s how you can do it using python and the chatterBot libary.
1. Install Dependencies
First, make sure you have Python installed. Then, install ChatterBot and its training corpus:
pip install chatterbot chatterbot_corpus
2. Write the Chatbot Code
Create a file called chatbot.py and add the following code:
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
# Create the chatbot
chatbot = ChatBot("SimpleBot")
# Train the chatbot using French language data (you can change it to English)
trainer = ChatterBotCorpusTrainer(chatbot)
trainer.train(“chatterbot.corpus.english”)
# Start the conversation
print(“Chatbot is ready! Type ‘quit’ to exit.”)
while True:
user_input = input(“You: “)
if user_input.lower() == “quit”:
print(“Goodbye!”)
break
response = chatbot.get_response(user_input)
print(f”Bot: {response}“)
3. Run the Chatbot
Open a terminal and run:
python chatbot.py
Now, you can chat with your bot!
4. Customize Your Chatbot
You can:
✅ Add custom responses by training the bot with your own dataset.
✅ Create a graphical interface using Tkinter or a web version with Flask.
✅ Integrate the chatbot into Telegram, WhatsApp, or a website.