Chat Flows

How to script a chatbot conversation with a flow. The node types, how a flow starts, how steps pass data and branch, and how to check and repair one.

A chat flow is a scripted, multi-step path a chatbot follows, built as a graph of steps. Normal chat is driven by the bot's persona: the person types, the bot answers from its instructions and knowledge (see building-a-chatbot.md). A flow is different. It runs a deterministic sequence you laid out: ask this, look that up, branch on the answer, collect a form, then finish. Use a flow when a part of the conversation needs to happen a specific way every time.

A bot can have many flows, each for a different job (an intake, a booking, a troubleshooting path). You build them in the flow editor, the same visual graph editor used for automations.

What a flow is made of

A flow is a graph with three parts:

  • Nodes, the steps. Each node has a type (below) and its own settings.
  • Edges, the links from one step to the next. An edge can carry a condition.
  • An entry, the step the flow starts on. A flow will not run without one.

How a flow starts

Every flow has a trigger that decides when it fires. There are three:

  • When the AI decides (the default). The flow becomes a tool the bot's AI can choose to start when the moment fits. You describe when to use it in the flow's trigger instructions, and the AI reads that to decide.
  • Manual. The flow does not fire on its own. It runs only when you start it from the test panel, or when your backend names it on the Conversations API. To start it on a live message, send that message with a flow field set to the flow's name (POST /api/v1/chat/conversations/:id/messages with {"text": "...", "flow": "<flow name>"}). The flow then processes that message (offered as Conversation › The message that started the flow wherever a step can use a value), keeps the conversation's context and history, and its output replaces the bot's ordinary reply for that turn. Any enabled flow can be started this way, not only Manual ones.
  • On file upload. The flow runs when the person sends a file. A bot can have only one of these, and it always begins with the file-handling step below.

An "AI decides" flow can also be marked auto-start when the chat opens, so it runs the moment a conversation begins and the bot leads instead of waiting. It applies only where the bot speaks first: on user-first channels like WhatsApp and Instagram a flow never auto-fires (the person always messages first), so there the AI offers or starts it at its own discretion instead.

Only enabled flows fire. A flow also has a cost cap (a dollar limit per run). If a run exceeds it, the run halts instead of spending more.

How the conversation moves through a flow

After a step runs, the flow follows its outgoing edges to the next step:

  • No outgoing edge: the flow ends there.
  • One outgoing edge: it always follows that edge.
  • Two or more: each edge can have a condition, and the first one that matches wins. An edge with no condition is the fallback if nothing else matches.

Conditions are simple expressions written against the step's own output, with no prefix. For example total > 1000, role == "premium", or _ok == false. This is how a flow branches: a step produces a value, and the edges decide where to go based on it.

Passing data between steps

A flow keeps a shared bag of values as it runs. Each step stores its result under its own name, and any later step can use it.

In the editor you never type a reference. Wherever a step can use a value, you pick it:

  • Text with values (a message, an AI step's instructions, a knowledge search): type as usual, and use Insert a value from an earlier step under the box to put a value at the cursor. It shows as «Step › field», for example «Photo of the label › First › url», and is filled in when the flow runs.
  • A single value (an image to look at, a list to go through, a tool's input): pick it from the dropdown, grouped by step.
  • Named values (what a widget, a called flow or a tool receives): one row per name, each with text, a value, or both.

The picker offers every earlier step's output, named the way you named the step (or by its kind, such as "Upload"), plus values every flow has:

  • Conversation › Channel: where the conversation is happening (web, WhatsApp, SMS).
  • Conversation › The message that started the flow.
  • The person · <source> › <field>: the person's data from the bot's user context sources (see Building a chatbot), so a flow can greet someone by name or use their plan.

When a field holds exactly one value, the real value is passed on, not turned into text: a number stays a number, and a list or an object (map) is passed whole. This is what lets one computation step hand another step's entire answer to a tool, for example a resolver tool that takes the whole set of answers a collect step gathered.

The agent and the API write the same values as references in the flow's JSON, {{<step>.<field>}} (see Flows and loops as JSON). The older {{state.<step>.<field>}} form still works. The editor shows those by name too.

Some steps can also run once per item in a list, so you can loop a lookup or a message over many values.

The node types

Group them by what they do.

Talk to the person:

  • message. Sends an interim message, with values from earlier steps filled in. The flow keeps going.
  • output. The final step. Sends the closing message and ends the flow.
  • agent_prompt. An AI step you write. It can narrate a reply, pull structured facts out of the conversation, or make a judgment the flow then branches on. You set the prompt, optionally an output format (below), whether it uses the bot's persona, and any media to look at. It runs on the bot's model unless you pick one for the step. If the step attaches images or frames and the bot's model can't read images, it runs on Claude instead, and the step's model note says so.

Collect input from the person:

  • collect ("Ask the customer"). Gathers a set of fields and pauses until it has them. Its web setting picks how the web chat asks: form (the default) renders the fields as an inline form, a set of inputs and selects submitted at once; widget shows a custom widget from the bot's widget library (use it only for a real custom widget, like a product picker); chat asks one question at a time, as on WhatsApp. On WhatsApp, Instagram or SMS it always asks in chat, one at a time, unless off web is set to link, which sends a link to the widget. The fields can be fixed, built at runtime (see "Dynamic collect fields" below), or, for a widget, the widget's own. When every required field is already known (from a handoff, the contact, or an earlier answer) the step is skipped; turn skip known off to always ask.
  • The answer is the same on every channel. It lands under the step's id as a {field: value} map of the step's fields only: a select holds one of its options, a number field a number, and a field left blank is missing. A custom widget on the web can send other keys too, and those are kept as sent, but no other channel sends them, so an edge condition should only test the step's fields (lint warns otherwise). When the step has fields, its answer fires collection.completed and is saved on the contact, once, whatever the channel.
  • widget_prompt. The older name for a collect step with a widget. It still runs: it shows the widget on web and, on channels that cannot show a widget, asks for the widget's fields in chat or sends a link. It is never skipped. New steps use collect.
  • request_upload. Asks the person to attach one or more files and waits. You set the allowed types and how many.
  • auth_gate. Requires the person be signed in (optionally with an email) before the flow continues. It can pause to a login step.

Logic and data:

  • computation. Runs one of your tools, or a built-in one, with inputs filled from earlier steps, and stores the result. This is how a flow looks something up or does a calculation deterministically.
  • branch. A pure decision point. It has no logic of its own. It forwards the value it receives so its outgoing edges' conditions do the routing.
  • call_other_flow. Runs another flow on the same bot, either waiting for it to finish and taking its result, or firing it off in the background.
  • remote_step ("On your machine"). Runs one handler on the business's own computer, through oalo serve, and waits for its answer: a script over a local spreadsheet, a folder search, anything the machine declares. You pick the handler and fill its input from earlier steps; the answer becomes the step's output. The flow waits without holding anything open, so a restart loses nothing. If the machine is offline when the step starts, the step waits for it until its time runs out (optionally saying a hold message), hands the conversation to a teammate, or takes the error route, as you choose. Any failure (offline, too slow, the script's error) gives _ok: false, so give the step an edge with the condition _ok == false. Turn on customer facing to say the answer's text to the person, through the same checks as any flow message. Setting up the machine: Answer from your own data.

Media and vision:

  • inspect_video. Sends a video or image to AI vision for analysis, and can return structured fields. It has a failure path you can branch on.
  • extract_frames. Splits a video into evenly spaced still frames for a later vision step.
  • media_received. The fixed first step of an on-file-upload flow. It hands the uploaded files to the rest of the flow.

Dynamic collect fields

A collect step usually has a fixed list of fields. But it can also build its form at runtime from an earlier step's output, so one flow handles many shapes without a branch per shape. Instead of a fields list, give the collect step a fields_from reference pointing at a prior step's output, e.g. fields_from: "variants.variants". The referenced value can be either:

  • a list of field specs ({key, label, type, options?, required?}), used as-is, or
  • a {attribute: [option, ...]} map, where each key becomes a select whose choices are the listed options (the key is humanized into the label).

This is the pattern for catalog-style flows where the options are not known when you author the flow. A typical chain: a computation step calls a lookup tool that returns a product's variant map, then a collect step with fields_from pointing at that output renders the right form at runtime, then another computation step resolves the choice. Because a field holding just the collect step's answers passes the whole object, the resolver tool can take its entire answer map as one input (see "Passing data between steps"). The collect step's fixed fields are ignored while fields_from is set.

Collecting by conversation

On WhatsApp, Instagram and SMS, and on any collect step whose web setting is chat, the bot asks for the fields in conversation instead of showing a form.

  • Anything they give is kept. A detail for any of the step's fields is recorded as soon as the person mentions it, also when it isn't what the bot just asked. What they say now wins over what they said before.
  • Optional fields are asked once. The person can skip them.
  • The step finishes when every field has a value, or every required field has one and the person skipped the rest, or the person declines to go on. It never finishes with a required field empty just because the AI thought it was done.
  • Choices. A field with options keeps one of its options. "5", "la 5" or the option's name without its number all pick the option they name. An answer that fits more than one option, or none, isn't recorded, and the bot asks again.
  • The conversation remembers. What the person answers in a collect step or picks in a picker, and what a tool reports, is kept for the whole conversation, so the bot's later replies know it ("What we know so far"). When they change an answer, the bot goes by the new one. The bot's Advanced settings have What the conversation knows: Automatic shows it to the AI when there is something, Off keeps it out of the AI's prompt (it is still kept).
  • Automatic, and read every message. The third choice of that setting. Each message the person sends is read on its own for the bot's fields (the fields of its collect steps and its data fields), also when no step is asking, so a size or a name given early is kept. A collect step whose required fields are already known is skipped, and one that's partly known asks only for the rest. A step that comes round again in the same flow asks again, and a choice from a list the flow builds as it runs (search results) only counts if it was made during that flow. Inside a collect step, the person's latest message decides the answer: an earlier choice in the conversation doesn't come back.

Structured output and branching

An agent_prompt step normally just says something in the chat. But if you give it an output format (a description of the fields you want), it instead returns those fields as data, stays silent in the chat, and lets the following edges branch on the values. This is the core pattern for making an AI step drive a decision: have it classify or extract into fields, then branch on them with a branch step. The same output format works on inspect_video to get structured answers about a video.

How exactly a format is held, and what thinking first, long replies and time limits do, depends on the step's model. See AI steps and providers.

When the person types during a paused step

A flow often pauses on a step that waits for the person: a widget or product gallery (widget_prompt), an inline collect form, or a file request_upload. On the web the person can tap the widget, but they can also just type instead. That typed message is handled by the bot's AI, not a fixed rule, so the bot stays flexible while the picker is on screen. The AI can see what is open (the picker's options and the product) and decides what the message means:

  • A choice ("the blue one", "the second one", "the big one"). It submits the open picker for them and the flow continues.
  • A question ("what does the blue one look like?", "how big is it?"). It answers using its knowledge and catalog access, and the picker stays on screen. Asking about an option is not the same as choosing it.
  • A different product. It restarts the flow for the new product, so the gallery updates instead of getting stuck on the old one.
  • Wanting to stop. It cancels the flow and the picker is dismissed, then the conversation continues as a normal chat.
  • Changing an earlier answer. It reopens the previous step so they can pick again.

These controls (submit the open picker, cancel the flow, go back a step, start or switch a flow) are available to the AI only while a flow is in progress, so it is never tempted to use them otherwise. Nothing here needs configuring; it is how a paused flow behaves.

Contact details in a collect step

When a collect step asks for contact details, it uses what the bot already knows about the person:

  • Prefill. Any field the bot can already fill is filled in for them: on a WhatsApp to web handoff the phone comes prefilled, and the name too when it is known. Only fields with a known value are prefilled; the rest are left blank. It matches fields by meaning (a "Teléfono / WhatsApp" field gets the phone, a "Nombre" field the name) and by exact field key for custom details.
  • Protected from autofill. A prefilled field is shielded from the browser's own autofill so it cannot wipe or overwrite the known value; empty fields keep normal autofill convenience.
  • Saved back. When the form is submitted, any new details are written to the person's contact record automatically (for example a delivery zone they typed), so next time they are remembered and prefilled. The bot can also save details it learns in ordinary conversation.
  • Known name. Because the bot knows the person's name, it can address them by name in the conversation.

The contact record is the single place this data lives (see crm.md), shared across every channel, so what is learned on WhatsApp prefills on the web and vice versa. It resolves for a signed-in person, a WhatsApp/handoff contact, and an API-identified person (whose details may have been pushed via the Conversations API).

Building, checking, and repairing a flow

You build a flow in the visual editor by dropping nodes, linking them, and setting each node's fields and each edge's condition. A flow is saved as a graph and uses safe concurrent editing, so if two people save at once the later one is told to reload rather than overwrite.

Two tools help keep a flow correct:

  • The linter checks the flow and flags problems: a vision step with no failure path, a computation whose tool is not on the bot's allowlist or is missing a required input, an AI step that ignores an earlier lookup, or a step nothing can reach. Findings are listed worst first.
  • Flow Doctor proposes automatic fixes for those findings (wire a missing edge, set a missing input, allowlist a tool) that you review and apply.

In the flow editor both are under More › Check this flow. The check lists the findings, each tied to a step with what to do; click one to jump to that step. It also catches a step that reads an answer the collect step never asks for, such as {{ask.first_name}} when the step asks name, which would otherwise reach the customer as an empty gap ("Thanks , ..."). From the CLI, oalo lint <file> runs the same check on a pulled flow file.

Repair with AI asks a model for edits from a fixed list: change a step's setting, set a tool input, add an edge, allowlist a tool, or rewrite a code tool's source. It can't change or remove an edge that is already there, rename or delete a step, or change what kind a step is, so fix those by hand. You see the whole list before anything is saved, and Apply saves all of it, then checks the flow again. Read the list first: a proposal can add a branch you didn't ask for, and its summary can say more than the edits do. The re-check afterwards is the honest view.

Run history (under More) is every recent run of the bot's flows, newest first (up to 100): its status, the flow's trigger setting, and its cost. Click a run for each step's input and output, its status, and for AI and collect steps the model, tokens and cost. A run that failed, or has a step that failed, shows Diagnose flow, which opens the same check. A run that finished counts as a success even when a message read wrong, so read the outputs. Agents and the CLI get the same view from oalo_flow_runs (MCP) or oalo call chat:flows:list_runs '{"bot_id": "bot_..."}'.

Run history is not version history. A flow has one copy, and a save is live at once. To be able to go back, keep the pulled flow file in git, then put the old file back and push it with oalo push <file> --force.

To actually run a flow end to end and see what it does, drive a real conversation with the bot: send a message, read the reply, answer whatever the flow asks, and watch it advance node by node until it finishes. This is the only way to confirm runtime behavior a static check can't: that a dynamic collect renders the right fields for a given input, that a resolver returns the right result, that the closing message reads correctly. Testing one tool in isolation is not the same as running the flow that chains them.

A collect step's fields may be written with key or with name for each field. Both are accepted (the value is read back at <step>.<that name>). key is the documented spelling; name works as an alias.

Flows compared to loops

A flow and a loop are both graphs built in the same editor, but they run in different places. A flow scripts a conversation inside a chat, in front of the person. A loop is a background automation that runs on a schedule or an event, with no one watching (see loops-and-recipes.md). Reach for a flow to shape what the bot does in the conversation. Reach for a loop to do work around it.

Start with Oalo

Your own Base, with every feature, from $99 a month.

get started