How a request finds its flow

What a flow is, how an operation code leads a request to it, and the states a flow goes through from its first draft to the archive.

4 min read

A flow is the spending policy of one kind of request. Your application names the kind by an operation code, and Slen walks the flow bound to that code: its nodes check budgets and policies, look in the cache, call a model and return an answer or a refusal. This page is about a flow as a whole — how a request reaches it and the states it goes through. How a flow is built is about what is inside.

Create a flow

Flows are created on AI Flows. Press New flow and give the flow a name. It opens in the builder with an empty canvas. A flow can also start from a template: on Templates, Create draft makes the flow and opens it in the builder.

A new flow belongs to the project you are in. It has a draft from the start, and it runs nothing until a version of it is published. Creating, editing and publishing flows needs the flows:write permission — Organizations, projects and roles says which roles have it.

The operation code

A request never names a flow. It names an operation code, such as generate_email, and the code decides which flow runs.

Open the flow, then its Settings tab. Under Operation binding type the code into Operation code and press Save binding. An empty code takes the binding off.

  • A flow answers to one code, and a code belongs to one flow of the project.

  • A code that another flow of the project has is refused with 409 and the code operation_already_bound. The flow keeps the code it had.

  • Another code given to the flow takes the old one off at once. The next request under the old code is answered 404 with the code flow_not_found, and the old code is free for another flow.

  • A code is at most 120 characters.

The list of flows marks a flow without a code with No operation bound.

When a request runs the flow

A request runs the flow when three things hold: its code is bound to the flow, the flow has a published version, and the flow is not archived. Otherwise the request is answered 404 with the code flow_not_found, and nothing is created — no execution and no reservation.

The request runs the active version of the flow: the version published last, or the one a rollback went back to. An execution keeps the version it started on — a publish or a rollback changes what the next request runs, not one that is running or waiting.

The states of a flow

The list of flows shows the state of each.

The list showsWhat it means
DraftThe flow has never been published. A request to its code is answered flow_not_found
Published and a version numberA version is active, and requests to the code run it. A line under it says when a newer draft is not published yet
ArchivedThe flow is stopped. A request to its code is answered flow_not_found

A flow is archived and brought back over the API: PATCH /v1/flows/{id} with status set to archived, or to active. The console shows the state and has no button for it.

  • An archived flow keeps its code and its active version. Brought back, it runs as it did before.

  • An execution that was waiting when the flow was archived still finishes, on its own version.

  • A publish makes an archived flow active again.

Where the executions are

Open the flow, then its Executions tab. It lists the executions of the flow, the newest first. Open one to see the path it took, node by node.

Where to go next