Skip to content
BotServBotServ
ChatbotAIOllamaLocal AIBot

Chatbot Basics

What a chatbot is, how rule-based and AI-powered bots differ, and how to build your own chatbot.

S

schutzgeist

9 min read
Chatbot Basics

Chatbot Fundamentals

What This Article Covers

  • What a chatbot is and how rule-based bots differ from AI-powered ones.
  • Which use cases work well and where chatbots hit their limits.
  • What tools and frameworks are suitable for building them.
  • How to run a chatbot with local AI and Ollama.
  • Common pitfalls for beginners and how to avoid them.

Introduction: Understanding Chatbots

A chatbot is a program that communicates with people in natural language. Instead of clicking buttons or filling out forms, you type a message and the bot responds. Chatbots answer questions, help with orders, triage support requests, or simply have conversations with you.

This article is for beginners who want to build their own chatbot. You don’t need deep AI knowledge, but you should be willing to work with prompts, APIs, and basic programming. If you want to learn programming fundamentals, IRC-Coding.de has tutorials on Python, C#, and more.

Why Do You Need a Chatbot?

Imagine you run a small online shop. Customers ask the same questions constantly: Where’s my order? What are the shipping costs? Can I pay with PayPal? Answering each question individually takes time you need elsewhere.

A chatbot handles these standard inquiries. It’s available 24/7, responds in seconds, and only escalates cases it can’t resolve. You free up time for customers who genuinely need help.

There’s also scalability. A person can handle 3-4 chats at once. A chatbot can manage thousands of parallel conversations without degrading response time. That matters during peak periods like Black Friday.

Chatbots Explained Simply

A chatbot is a program that receives text input and produces text output. The simplest form is rule-based: if the user types “price,” the bot responds with a price list. The more complex form is AI-powered: a language model understands the input, generates a fitting response, and can call tools to fetch data.

The core idea is this: the bot saves users from interacting directly with complex systems by communicating in natural language.

Who Are Chatbots For?

Chatbots serve several groups:

  • Companies wanting to scale customer support and automate routine questions.
  • Developers building AI applications and gaining hands-on experience.
  • Hobbyists running a Discord bot, Matrix bot, or web chatbot for their community.
  • Local AI users who want to make their models accessible via a chat interface.

Programming experience helps, but it’s not required for simple rule-based bots. If you’re building AI-powered bots, familiarity with prompt engineering and APIs is valuable.

Key Terms Around Chatbots

  • Ollama - Local model server for AI models. Useful when you want to run AI-powered chatbots locally.
  • Open WebUI - Chat interface for Ollama. Useful when you need a ready-made web chat UI.
  • AI Agent - Software that plans independently and calls tools. Useful when the bot needs to do more than generate text.
  • System Prompt - Instructions that define the model’s behavior. Useful in every AI chatbot to set role and boundaries.
  • Function Calling - The model’s ability to invoke functions. Useful when the bot needs to fetch data or perform actions.
  • RAG - Retrieval-Augmented Generation, extending the model with external documents. Useful when the bot should leverage company-specific knowledge.
  • Webhook - HTTP endpoint that makes the bot reachable from outside. Useful when messenger platforms need to reach the bot.

Rule-Based vs. AI-Powered Chatbots

The most important distinction for getting started is between rule-based and AI-powered chatbots. Both have their place.

PropertyRule-Based BotAI-Powered Bot
How It WorksIf-then rulesLanguage model generates response
FlexibilityLow, only predefined pathsHigh, understands freeform input
PredictabilityVery highMedium
MaintenanceAdd new rules for new questionsAdjust system prompt
CostLowMedium (hardware for local AI)
Best ForStructured processes, FAQsOpen conversation, complex questions

A rule-based bot makes sense when questions are predictable: “Where’s my order?” always routes to shipment tracking. The flow is clear, the response is deterministic.

An AI-powered bot makes sense when questions vary: “I ordered something last week and it hasn’t arrived yet, what can I do?” The model understands context, can ask follow-ups, and generates an appropriate response.

In practice, you combine both. The AI bot handles open conversation but calls defined functions via Function Calling to fetch structured data like order status.

Types of Chatbots

Web Chatbot

A web chatbot is embedded in a website. Visitors click a chat icon in the corner and message the bot. This is the most common form for customer service and sales.

Advantages: easy to embed, no extra login needed, complete control over design and data.

Discord Bot

A Discord bot lives in a Discord server. Users mention the bot or message it privately, and it responds in channels or direct messages.

Advantages: ideal for communities, low barrier to entry, many integrations available.

Matrix Bot

A Matrix bot runs on the decentralized Matrix protocol. This is interesting for privacy since Matrix can be self-hosted.

Advantages: decentralized, encrypted, self-hostable.

IRC Bot

An IRC bot is a chatbot classic. IRC has existed since the 90s and is still used in many tech communities.

Advantages: lightweight, open, great for tech-savvy communities.

Building a Chatbot with Local AI

Local AI opens chatbot possibilities that would be expensive or problematic for data privacy with cloud APIs. Instead of sending every request to OpenAI, you use a local model running on your own hardware.

The basic components:

  1. Model Server: Ollama provides the model and responds to requests via a REST API.
  2. Chat Interface: Open WebUI offers a ready-made web interface. Alternatively, build your own.
  3. System Prompt: Defines the bot’s role, behavior, and limits.
  4. Optional: RAG: If the bot needs company-specific knowledge, connect a vector database. See Local RAG.
  5. Optional: Function Calling: If the bot should perform actions, define functions the model can call.

A minimal chatbot with Python and Ollama looks like this:

import requests

OLLAMA_URL = "http://localhost:11434/api/chat"

def chat(message, history=[]):
    history.append({"role": "user", "content": message})
    response = requests.post(OLLAMA_URL, json={
        "model": "llama3.1",
        "messages": [
            {"role": "system", "content": "Du bist ein hilfreicher Assistent für einen Onlineshop. Antworte kurz und freundlich."},
            *history
        ],
        "stream": False
    })
    reply = response.json()["message"]["content"]
    history.append({"role": "assistant", "content": reply})
    return reply, history

history = []
while True:
    user_input = input("Du: ")
    if user_input.lower() in ["exit", "quit"]:
        break
    reply, history = chat(user_input, history)
    print(f"Bot: {reply}")

This script sends each input to Ollama, maintains conversation history, and outputs the response. The system prompt sets the bot as a shop assistant. If you want to learn Python, you’ll find tutorials on IRC-Coding.de.

Practical Example: FAQ Bot for an Online Shop

Imagine you want to build an FAQ bot that answers your most common customer questions. Here’s how it works:

  1. Create an FAQ document: Collect your 20 most frequently asked questions and answers in a single document.
  2. Set up RAG: Load the FAQ document into a vector database like Chroma. See Local RAG.
  3. Define a system prompt: “You are an FAQ bot for an online shop. Use only the information provided in the context. If you don’t know the answer, say so and offer to escalate to support.”
  4. Build a chat interface: Use Open WebUI as the front end and Ollama as your model server.
  5. Test thoroughly: Ask the most common questions and verify that answers are accurate.
  6. Set up human escalation: When the bot encounters questions it can’t handle, it should pass them to a human agent.

You can deploy this bot in an afternoon. Once live, it runs 24/7 answering standard questions without human intervention. The key is reviewing answers regularly and keeping your FAQ document current.

Common Chatbot Pitfalls

  • No clear boundaries: A chatbot without a defined system prompt talks about everything, including topics it shouldn’t handle. Set your role and limits in the system prompt.
  • Accepting hallucinations: AI models invent facts when they don’t know something. RAG with explicit instructions (“Use only the context”) significantly reduces this risk.
  • No human handoff: When the bot gets stuck, it needs to escalate to a person. A bot that circles endlessly frustrates users fast.
  • Skipping testing: Test your most common questions before going live. A poor bot damages trust more than no bot at all.
  • Ignoring data protection: If you store chat histories, you must comply with GDPR. Local AI with Ollama solves this because data never leaves your network.
  • Starting too complex: A bot that does everything does nothing well. Start with a specific use case (FAQ, order status) and expand step by step.
  • No monitoring: If you don’t notice when the bot gives wrong answers, you’ll only hear about it through complaints. Sample chat logs regularly to catch problems early.

Further Resources on Chatbots

Key Takeaways:

  • Chatbots communicate in natural language and remove friction from user interactions with complex systems.
  • Rule-based bots are rigid, AI-powered bots are flexible. Both are often combined.
  • Local AI with Ollama enables privacy-respecting chatbots without cloud costs.
  • System prompt, RAG, and function calling are the three core building blocks for AI chatbots.
  • Testing, monitoring, and human escalation are mandatory, not optional.

FAQ: Chatbot Basics - Common Questions

What exactly is a chatbot?

A chatbot is a program that receives text input and produces text output. The simple version is rule-based, following predefined patterns. The advanced version uses an AI language model that understands free-form input and generates appropriate responses.

What’s the difference between rule-based and AI-powered chatbots?

Rule-based bots follow if-then logic and are predictable but inflexible. AI-powered bots use a language model to understand free-form questions and generate dynamic answers, but are less predictable.

Can I run a chatbot with local AI?

Yes. With Ollama you run a language model on your own hardware. Open WebUI provides a ready-made chat interface. All data stays on your network, which simplifies data protection and GDPR compliance.

Which model is best for a chatbot?

For simple chatbots, a 7B model like Llama 3.1 8B works fine. For more complex tasks, Qwen 2.5 14B or Mistral Nemo are better choices. Test your model before deployment to ensure quality meets your needs.

What platforms can I run a chatbot on?

Chatbots work on websites, Discord, Matrix, IRC, and many messaging platforms. Your choice depends on your audience: websites for customers, Discord for communities, Matrix for privacy.

Do I need RAG for my chatbot?

If your bot needs company-specific knowledge (FAQs, product data, internal documents), yes. RAG extends the model with external documents retrieved via a vector database. Without RAG, the bot is limited to what it learned during training.

How do I prevent hallucinations in chatbots?

RAG with clear instructions in the system prompt reduces hallucinations. Your prompt should say: “Use only the information in the provided context. If you don’t know the answer, say so.” Output filters and human escalation on uncertainty also help.

Can I build a chatbot without coding?

Yes. Tools and platforms exist for no-code chatbot development. Open WebUI provides a ready-made interface for Ollama. For more advanced bots with function calling or RAG, you’ll need to code.

What does a chatbot with local AI cost?

After the hardware investment, you only pay for electricity. Ollama and Open WebUI are open source. Compared to cloud APIs that charge per request, you save significantly if your chatbot gets heavy use.

When does a chatbot need human escalation?

Escalate when the bot can’t answer a question, when users complain, for critical actions like cancellations, and whenever a user explicitly asks for a person. A bot stuck in a loop frustrates users quickly.

Resources and Further Reading

Back to Blog
Share:

Related Posts