Skip to content

What's actually inside a customer-service chatbot?

I built a store's support chatbot the laziest way. It asked me which store I bought from. One addition fixed it, and the whole thing is 12 lines.

Bassically · Applied AI series, level 1 of 7. I ran this on a real model. Every reply quoted here is the model's own, and the code is in the repo.

Short answer: an AI model that is handed the store's rules with every message. It does not know the store. It reads the rules each time, then writes a reply.

What I tested

  • The store: Toko Nusa, a made-up electronics store. Returns within 14 days, laptop warranty 24 months.
  • The question: "Hi, I bought a laptop 5 days ago. Can I return it?"
  • Two chatbots: the same code and the same model, once without the store's rules and once with them.
  • The model: gpt-6-luna, called through an OpenAI-compatible API.

The result

Without the rules, it asked me which store I bought from

  • What happened: a 610-character answer that starts with "Possibly" and ends with "If you tell me your country, retailer, and whether you bought it online or in-store, I can give you a more specific answer."
  • Why: nobody told the model which store it works for. It answered like a general assistant, because that is all it was.

The store's own chatbot, asking which store.

With the rules, it answered in one sentence

  • What happened: "Yes—if it’s unused and still in its original packaging, you can request a return within 14 days of delivery." 191 characters.
  • Why: the store's rules were sent along with the question, as plain text. That text is called a system prompt.

Same question, same model. The only change is a page of rules.

The whole chatbot sends two things

  • What happened: every time a customer writes, the code sends the AI model two things: the store's rules and the customer's message. The model reads both and writes the reply.
  • Why it matters: the model remembers nothing between messages. Take the rules away and it is a general assistant again.

Rules and message in, reply out.

This is the whole chatbot. Read it from the top: the rules, then one request that sends the rules and the customer's message together. The rules are shortened here to fit the page.

from openai import OpenAI

RULES = """You are customer service for Toko Nusa, an online electronics store.
Answer only from the store rules below.

Store rules:
- Returns: within 14 days of delivery, unused, with original packaging.
- Warranty: laptops 24 months, smartphones 12 months.
- Cash on delivery: only for orders up to Rp2,000,000.
"""

client = OpenAI()  # reads your key from the environment


def reply(message):
    response = client.chat.completions.create(
        model="gpt-6-luna",
        messages=[
            {"role": "system", "content": RULES},   # the store's rules
            {"role": "user", "content": message},   # what the customer wrote
        ],
    )
    return response.choices[0].message.content


print(reply("I bought a laptop 5 days ago. Can I return it?"))
  • RULES is the page of rules. It is ordinary text, written by a person.
  • "system" is where the rules go. "user" is where the customer's message goes.
  • Whatever comes back is the reply.

Run it yourself: github.com/haryarrahman14/applied-ai-series. The file there is this same program with the store's full rules.

What is really sent: the rules as system, the customer's chat as user.

It is 12 lines, and a reply takes about 2.3 seconds

Without rulesWith rules
median time per reply4.2 s2.3 s
fastest2.6 s1.1 s
slowest37.0 s31.7 s
replies over 10 s3 of 154 of 15
median length171 characters85 characters
  • What happened: 12 lines of code, not counting the rules text and the line that runs it. With the rules the answers are half as long and come back faster.
  • Why faster: a shorter answer takes less time to write.
  • Why some replies took over 10 seconds: not measured. It happened in both modes, so it is not the rules.

So what is inside?

  1. An AI model that can write, and knows nothing about your store.
  2. A page of rules the code sends with every message.
  3. A few lines of code that put the two together.

That is level 1. It replies, and that is all it does.

Limits

  • One model, one provider, 15 replies per mode. The timing table is from the same five questions asked in Indonesian.
  • The rules fit on one page. A real store's rules do not.
  • It cannot look anything up. Asked "where is my order?", it said it could not check from here.
  • It forgets the previous message.

Next

Level 1 again, one step further: how does a chatbot remember what you said a minute ago?

Setup

  • Python 3.14.6 with the openai SDK 3.60.0
  • Model: gpt-6-luna through an OpenAI-compatible API, 2026-11-30
  • Each question asked three times per mode; the table shows medians
  • Code and raw replies: github.com/haryarrahman14/applied-ai-series, folder 01-reply-to-chats

Follow