Build Your First AI Chatbot0% done
← PrevNext →
Lesson 2 of 6~2 min read

Lesson 1 — How Chatbots Actually Work

Before writing a single line, you need the mental model. Most people skip this and wonder why their bots feel random and inconsistent.

Lesson 1 — How Chatbots Actually Work

Before writing a single line, you need the mental model. Most people skip this and wonder why their bots feel random and inconsistent.

Every conversation with an AI has three layers:

  • **System prompt** — The hidden instructions that set the bot's personality, knowledge, rules, and constraints. The user never sees this. This is where you do most of your work.
  • **Conversation history** — Every message the user sends and every reply the bot gives is passed back to the model on each turn. The model has no memory — it's stateless. You're giving it the full transcript every time.
  • **User message** — What the person just typed.
  • The model reads all three layers together and generates the next response. That's it. The entire art of building a chatbot is writing a great system prompt and managing the conversation history correctly.

    What makes a system prompt great:

  • Role: Who is this bot? ("You are Maya, a friendly onboarding assistant for Acme Software.")
  • Tone: How does it speak? ("Keep responses under 3 sentences. Be warm but professional.")
  • Knowledge: What does it know? ("Here are the top 10 FAQs about our product: [paste them in]")
  • Limits: What won't it do? ("Never discuss competitors. If asked about pricing, send them to /pricing.")
  • Escalation: What happens when it can't help? ("If unsure, say 'Let me connect you with a human — one moment.'")
  • Write a system prompt with all five elements and your bot will behave consistently every single time.

    ← PREVIOUSWhat You'll BuildNEXT →Lesson 2 — Getting Your API Key