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.
| Property | Rule-Based Bot | AI-Powered Bot |
|---|---|---|
| How It Works | If-then rules | Language model generates response |
| Flexibility | Low, only predefined paths | High, understands freeform input |
| Predictability | Very high | Medium |
| Maintenance | Add new rules for new questions | Adjust system prompt |
| Cost | Low | Medium (hardware for local AI) |
| Best For | Structured processes, FAQs | Open 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:
- Model Server: Ollama provides the model and responds to requests via a REST API.
- Chat Interface: Open WebUI offers a ready-made web interface. Alternatively, build your own.
- System Prompt: Defines the bot’s role, behavior, and limits.
- Optional: RAG: If the bot needs company-specific knowledge, connect a vector database. See Local RAG.
- 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:
- Create an FAQ document: Collect your 20 most frequently asked questions and answers in a single document.
- Set up RAG: Load the FAQ document into a vector database like Chroma. See Local RAG.
- 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.”
- Build a chat interface: Use Open WebUI as the front end and Ollama as your model server.
- Test thoroughly: Ask the most common questions and verify that answers are accurate.
- 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
- Setting Up a Web Chatbot - Embed a chatbot into your website.
- Discord Bot Basics - Build a bot for Discord servers.
- Matrix Bots - Bots on the decentralized Matrix protocol.
- Chatbots Without Code - Tools for non-developers.
- Installing Ollama - Local model server setup.
- Setting Up Open WebUI - Chat interface for Ollama.
- Local RAG - Extend your chatbot with custom documents.
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?
What’s the difference between rule-based and AI-powered chatbots?
Can I run a chatbot with local AI?
Which model is best for a chatbot?
What platforms can I run a chatbot on?
Do I need RAG for my chatbot?
How do I prevent hallucinations in chatbots?
Can I build a chatbot without coding?
What does a chatbot with local AI cost?
When does a chatbot need human escalation?
Resources and Further Reading
- Ollama Documentation - Local model server.
- Open WebUI - Chat interface for Ollama.
- Discord Developer Portal - Discord bot API.
- Matrix SDK - Matrix bot development.
- LangChain Chatbot Tutorial - Chatbot framework.


