AI chatbot: How to create your own AI chatbot on Ubuntu – simple Python guide

How to Build Your Own AI on Ubuntu – AI Chatbot Simple Guide

How to Create Your Own Chatbot on Ubuntu
AI Chatbot Simple Guide

Artificial Intelligence is no longer just for big companies or scientists. Thanks to the open-source nature of Ubuntu, you ca

AI Chatbot Ubuntu python

How to create your first chatbot in Python

Artificial intelligence is no longer just for big companies or researchers. Thanks to Ubuntu and Python, anyone can create their own chatbot today. This simple project runs directly on your computer — no expensive servers or API connections required.

What We’ll Need

Before we start, prepare the following:

  • A computer with Ubuntu (recommended version 20.04 or higher)
  • Internet connection
  • Python 3 installed
  • The nltk (Natural Language Toolkit) library — for text processing
  • Any text editor or Jupyter Notebook

If you don’t have the nltk library yet, install it easily with:

pip3 install nltk

💻 Creating a Simple Chatbot

Open a new Python file, for example chatbot.py, and paste the following code:

import random
import nltk

# Download necessary data for the first time
nltk.download('punkt')

# Predefined chatbot responses
responses = {
    "hello": ["Hello!", "Hi there!", "Hey!"],
    "how are you": ["I’m fine, thank you!", "Great, and you?"],
    "what can you do": ["I can chat with you.", "I’m a simple chatbot, but I’m learning!"],
    "who created you": ["I was created by Balli!", "I’m the work of a skilled creator."],
    "default": ["Sorry, I don’t understand that yet.", "Can you say it differently?"]
}

# Chatbot logic
def chatbot(question):
    question = question.lower()
    for key in responses.keys():
        if key in question:
            return random.choice(responses[key])
    return random.choice(responses["default"])

print("🤖 Chatbot: Hello, I’m your personal chatbot. Type 'exit' to quit.")

while True:
    user_input = input("You: ")
    if user_input.lower() == "exit":
        print("🤖 Chatbot: Have a great day! 👋")
        break
    reply = chatbot(user_input)
    print("🤖 Chatbot:", reply)

How to Run the Chatbot

In the terminal, navigate to the folder where you saved chatbot.py and type:

python3 chatbot.py

The chatbot will start and respond to basic questions, for example:

💬 “Hello”
💬 “How are you?”
💬 “What can you do?”
💬 “Who created you?”

Type exit to quit.

How to Expand Your Chatbot

Once the basic version works, you can improve the chatbot as you like. Here are some ideas:

  • Add more responses and keywords
  • Connect it to a microphone and speech recognition
  • Save conversation history
  • Integrate it with the OpenAI API to create a smart assistant
  • Teach it to work with a database

How the Chatbot Works

This simple chatbot works by looking for keywords in the text you provide.
For example, if you type “Hello, how are you?”, it detects the word “hello” and responds based on a predefined set of responses.

If you want the chatbot to understand more complex sentences, you can later add natural language processing (NLP).

 

Creating your own chatbot on Ubuntu is surprisingly simple.
All you need is Python, the nltk library, and a few lines of code.

With this project, you’ll learn:

  • How AI communicates with users
  • How to work with text in Python
  • How to gradually build your own intelligent application

Next, you can enhance your chatbot by connecting it to OpenAI — we’ll cover that in the next article.

 

Help:Creating a bot

 

 

 

 

Easy VPN for Linux – no complicated setup

If you don’t want to create your own VPN or you’re struggling to configure everything on Linux, here’s a simple solution. Try a ready-to-use VPN for Linux with a clean graphical interface – fast, secure, and hassle-free.

View deals on Amazon →

Tip: Quick installation, user-friendly GUI, no unnecessary complexity.

Posted in EN - Linux Community ☺ and tagged .

Leave a Reply

Your email address will not be published. Required fields are marked *