Building a Chatbot
Build an Oalo chatbot end to end: pick a starting persona, give it knowledge, tune how it retrieves, guard what it says, and choose its model.
A chatbot is one of the things you build in Oalo (see what-is-oalo.md).
It has a persona (who it is and how it talks), a knowledge base (what it
knows), and a set of controls for how it retrieves that knowledge, what it is
allowed to say, and which AI model runs it. You build and tune all of this in the
bot's config panel. The same bot can run inside your app and on external channels
like WhatsApp, Instagram and SMS.
This guide walks the pieces in the order you usually set them.
1. Start from a persona preset
When you create a bot you pick a preset. A preset is a starting point, not a cage: it fills in a sensible persona and, for some presets, the fields the bot should collect. You then edit everything freely.
The presets:
- Blank. An empty bot. You write the whole persona yourself.
- Friendly intake assistant. Onboards and qualifies a lead, asking for the basics one question at a time (name, email, phone, interest, timeline).
- Product concierge. Answers catalog questions and helps a customer buy,
using your product data and checkout. Pairs with
commerce.md. - Socratic tutor. Teaches by asking guiding questions instead of handing over the answer.
- Motivational interviewer. Coaches with open questions, affirmations, reflections, and summaries.
- Direct expert. Answers domain questions directly and cites sources, no hedging.
- Supportive coach. Wellness, fitness, and habit work, empathy first.
- Triage agent. Works out what the person needs and routes or hands off.
- Sales qualifier. Qualifies a B2B lead on budget, authority, need, and timeline.
- Customer support agent. Resolves issues and escalates cleanly.
2. The persona
The persona is what makes the bot itself. It has:
- Instructions. The prompt that defines the bot's job, rules, and voice. This is the main thing you write.
- Opening message. The first thing the bot says when a conversation starts.
- Tone. A short qualifier (warm, direct, patient, calm) that colors the voice.
Some presets also define fields to collect (for example an intake bot collects name, email, and interest). The bot gathers these naturally over the conversation, and you can add, remove, or change them.
Write the persona as if it is an expert that already knows its material. Telling it what it must never say belongs in the frame and guardrails below, not buried in the instructions, because those are enforced more reliably than prose rules.
3. The frame: always-on rules
The frame is a separate block of rules that applies to every reply, regardless of what the bot retrieves. Use it for governance that must always hold: brand rules, a scope boundary ("only answer questions about X"), or a standing instruction. Unlike a knowledge document, the frame is never optional context. It is always in front of the model. For rules that must be enforced even when the model ignores its instructions, add a guardrail (section 7).
4. Give it a knowledge base
A bot answers from knowledge you give it. Add knowledge as:
- Uploaded documents. PDF, Markdown, plain text, and HTML files. Oalo extracts the text, splits it into passages, and indexes them so the bot can search them.
- Web pages. A URL Oalo fetches and indexes.
- Pasted text. Content you type or paste directly.
Each source is indexed in the background and shows a status (indexing, then ready). If a source fails, the status says so. Updating a source re-indexes it.
Uploaded knowledge stays private to your bot.
5. How the bot uses its knowledge
Two settings control retrieval. They are independent.
Retrieval mode trades cost against depth:
- Fast (the default). Small passages, a few hits per turn, cheapest. Good for FAQ-style bots.
- Deep. Larger passages, more hits, and a re-ranking pass that pushes the best matches to the top. Good when answers depend on longer, system-level context.
Because passage size is set when the knowledge is indexed, switching modes re-indexes the bot's knowledge base.
Retrieval strategy controls when knowledge reaches the model:
- Hybrid (the default). Every turn, the bot is given the most relevant passages up front and can also search for more on its own. The safest choice.
- Preload. Relevant passages are injected every turn, but the bot cannot search for more. Predictable and cheap.
- Adhoc. The bot is given search tools and pulls knowledge only when it decides it needs to.
- None. No knowledge retrieval. The bot runs on its persona alone.
The persona and the frame always load. These settings only govern the knowledge base.
6. The knowledge graph
Behind the knowledge base, Oalo builds a knowledge graph: a map of your knowledge where each section is a point and links connect related sections and their parents. It lets the bot pull not just a passage that matches the question but the surrounding context that governs it, so answers stay consistent with your source material.
A bot has no graph until you build one (the bot's Graph tab, Build graph, or
oalo bots graph <bot> --build). After that, each document you add or change
keeps it current. You can also shape it:
- Curate. Add, edit, or remove points and the links between them by hand, when you want to state a relationship the automatic build would not find. A rebuild never overwrites what you curated or imported.
- Import and export. Move a graph in or out as a file. An exported graph re-imports cleanly, so you can back it up or move it between bots.
- Rebuild. Regenerate the automatic part of the graph from the current knowledge base, or refresh a single source.
- Mark importance. Give the points you add by hand an authority (canon, axiom, locked or mode) so the bot treats them as authoritative. A section from a document gets one when its heading or first line has CANON, AXIOM, LOCKED or MODE as a word.
- Label the links. With Classify edges (AI) on, a small AI model reads each pair of similar sections after a rebuild and says how they relate (one depends on the other, defines it, or is related), so a match can bring in what it depends on. It uses some AI credit, only for the pairs whose text changed.
You can also set how far the bot reaches through the graph: follow the full hierarchy, use only close matches, or turn graph retrieval off and rely on plain search.
From the CLI, oalo bots graph <bot> shows the graph's size and whether links
are labeled, --build builds or rebuilds it, and --reset --yes deletes it.
How answers use it is set in the bot settings: oalo bots settings <bot> set graph_retrieval=hierarchical ancestor_preload_depth=3 graph_classify_edges=on.
Why did the bot say that
The bot's Context tab shows what it reads before it answers. Type what the customer said, pick them under Member if their own data matters, and click Preview context. You see the frame, the persona and the passages retrieved for that message, each with its size. What the graph adds shows at the end of the retrieved knowledge: Governing context (the parent topics of a match) and Related sections (sections linked to it). It runs the bot's real assembly and stops before the model, so no reply is written.
It leaves out what every turn also sends, and says how much: the bot's tool definitions and Oalo's instructions for them, the date, and the conversation so far. On a later turn the bot searches with its last reply plus the new message, so paste both to match. A hybrid bot can also search on its own during the turn; those searches show as steps in the chat preview, not here.
What loads every turn, and what is searched
Each turn's context has two parts. Some loads every turn whatever was asked:
the frame, the persona, and any graph topics you make resident. The rest
is found for this turn: retrieved passages, and the parts of semantic
topics that match the question. Resident is for rules that must always bind;
semantic keeps a large topic from filling every turn. Resident and semantic
topics need a graph strategy (context.strategy graph_resolver or
graph_focused); the default strategy loads the frame and persona, and searches
for the rest.
Context fill (in the Context Inspector) sets the size. Fixed amounts, the default, retrieves a set number of passages. Fit to the model's window gives each turn a budget: a share of the model's window (50% by default), at most a cap in tokens (400k by default). What loads every turn goes in first, then recent history (at most half of what's left), then retrieved knowledge fills the rest. A bigger share means more knowledge each turn, at more cost.
From the CLI, oalo bots settings <bot> set context.frame_segments="THE RULES=resident; THE MAP=semantic"
picks resident or semantic per topic, and context.budget.policy=fit context.budget.share=60 context.budget.cap=200000 sets the size.
7. Guardrails: protecting what the bot says
Guardrails are checks that run on the bot's reply before it reaches the person. They are stackable, and each one separates what it detects from what it does about it.
The actions:
- Flag. Record the problem, send the reply unchanged. Good for monitoring.
- Redact. Blank out the offending part of the reply.
- Regenerate. Ask the model to rewrite the reply without the problem, then fall back to redacting if it still fails.
The guardrail types:
- Canon verbatim leak. Catches the bot quoting your own source material word for word. Use it to stop your paid or proprietary content from being reproduced in full.
- Forbidden terms. Blocks specific words or phrases from ever reaching the person. Use it for internal vocabulary the bot must never disclose.
- Forbidden patterns. Blocks anything matching a pattern you define, for structured leaks like internal ids or codes that a fixed word list cannot catch.
There is also a one-switch option, protect canon, that turns on verbatim protection: after each reply, Oalo removes any long stretch copied word for word from the exact source passages used that turn. It guarantees the bot will not reproduce protected material verbatim even if the prompt alone asks it to. Guardrails are structural. Prefer them over writing "never reveal X" in the persona, which the model can ignore.
With a guardrail on, the reply is checked before anyone sees it, so it arrives
whole instead of word by word. Text to send (guarded_reply) decides which
part of it is sent when the bot used a tool partway through:
- After the last step only (the default). A lead-in written before a tool call, like "let me check your plan", is dropped, and the person gets the answer the bot wrote after it.
- All of it. Every step's text is kept. Use it for a bot that answers, shows cards, then asks a question, so the answer isn't lost.
8. Choosing the model
Every bot runs on an AI model. Rather than memorize model names, pick a tier:
- Cheap. The fastest, lowest-cost model. Good for simple, high-volume bots.
- Balanced (the usual default). A strong general model for most bots.
- Max. The most capable model, for the hardest reasoning.
A tier maps to a concrete model that Oalo keeps current, so you get upgrades without changing your bot. If you need a fixed model, you can pin a specific one instead of a tier.
You also choose a provider. The default is Anthropic (Claude). You can switch to other providers (such as OpenAI, Gemini, DeepSeek and GLM) through the model picker. The bot keeps its tools on every provider: knowledge search, collected fields, flows and the tools you add. On other providers a chat turn runs in a locked-down mode that can use only the bot's own tools, never shell commands, files or the web. Some behavior differs by provider (output formats, thinking first, long replies, time limits and retries). See AI steps and providers.
9. Remembering people and pulling in their data
Three optional features make a bot personal to each member:
- Member learning. The bot can remember a person across conversations: their recurring interests, how their situation changes over time, and a long-term memory it can draw on. It can also bias what it retrieves toward what that person cares about. Each part is a separate switch.
- User context sources. Point the bot at data already in your app (a member's profile, their orders, their plan) so the conversation can use those values. This is how a bot greets someone by name or answers "what did I buy" without asking.
- Ambient uploads. Let people attach files in the chat. The bot can take those files as part of the message, which is useful for intake ("send me a photo of the label") and for flows that act on an upload.
Draft and published data
A draft (unpublished) bot searches the staging (dev) copy of your data tables
and books against staging booking data. A published bot uses the live (prod)
copy. If a draft bot can't find rows you loaded live, put them in staging too
(see data-models.md), or publish the bot. Booking types and hours added with
booking:types:create and booking:availability:add go to the live copy
unless you pass "env": "dev", so to test booking with a draft bot, add them
with "env": "dev" too. This holds in test conversations as well: testing a
published bot reads and writes live data. Dev and prod says
which copy every part of Oalo uses.
Where the bot runs
A finished bot runs inside your app and on the channels you connect. WhatsApp is
covered in whatsapp.md, Instagram in instagram.md, email in email.md, and a
chat bubble on any web page in chat-widget.md. To script a specific conversation path (ask this, then
branch, then collect that), use a chat flow. To automate follow-up around the
bot, use loops and recipes (see loops-and-recipes.md).
Your own Base, with every feature, from $99 a month.