Flows

What are Flows?

Flows are multi-step AI workflows that chain together prompts, API calls, data transformations, and logic to build complex AI behaviors.

How Flows work

A Flow executes a sequence of steps in order. Each step performs a specific task—calling an AI model, fetching data from an API, transforming data, making decisions, or updating Records. The output of one step can feed into the next, creating powerful workflows.

Example Flow: Customer support escalation

  1. Prompt step: Analyze customer message for sentiment and intent

  2. Conditional step: If sentiment is negative, route to escalation

  3. Record step: Look up customer history from Records

  4. Prompt step: Generate personalized response using customer history

  5. API call step: Create ticket in support system if escalation needed

Example of a Flow in action

A SaaS company needs to moderate user-generated content in their platform—product reviews that users submit need to be checked for policy violations before publishing. Their small team can't manually review hundreds of submissions daily, but they need accuracy and want to avoid false positives that would reject legitimate reviews.

A developer on the team builds a content moderation Flow with these steps:

  1. Prompt step (analyze): Send the review text to GPT-4 with a prompt asking it to identify potential policy violations (spam, profanity, personal attacks, promotional content). The step outputs a structured JSON object with violation categories and confidence scores. Output variable: analysis.

  2. Transform Data step: Use JavaScript to check if any violation has a confidence score above 0.8. Output variable: needsReview.

  3. Conditional step: If {{needsReview}} is true, route to the manual review branch. If false, auto-approve.

  4. API call step (auto-approve branch): POST to the company's publishing API to make the review live with status: "approved".

  5. API call step (manual review branch): POST to their internal moderation queue API, including the original review text and {{analysis}} so moderators see the AI's reasoning.

During testing, the developer discovers the Flow flags too many borderline cases. They adjust the confidence threshold from 0.8 to 0.9 in the Transform Data step, rerun test cases using the Playground, and see the false positive rate drop without missing real violations.

After a week in production, 73% of reviews auto-approve, and the moderation team can focus their time on genuinely ambiguous cases. Because the Flow is deterministic—the same input produces the same output—they can easily debug edge cases and refine the logic.

Flows are ideal for multi-step processes where you need predictability and control. Unlike Agents that make autonomous decisions, Flows execute your exact logic every time, making them faster and easier to debug.

Available step types

Runtype provides 20+ step types. Common ones include:

  • Prompt — Call an AI model with a prompt

  • Transform Data — Manipulate data with JavaScript (sandboxed)

  • Conditional — Branch based on conditions

  • Fetch URL / API Call — Make HTTP requests

  • Upsert / Retrieve Record — Work with Runtype Records

  • Send Email — Send emails via SMTP

  • AI Search — Search the web with AI-powered tools

  • Wait Until — Pause execution until a condition is met

See Flow step types overview for the complete list.

Template variables

Pass data between steps using template variables.

Step outputs: Reference step outputs by the output variable name you set for that step. For example, if a step has output variable customerLookup, use {{customerLookup.tier}} or {{customerLookup.count}}. Each step defines an output variable; later steps use that name in template expressions.

Flow input: For API-triggered Flows, use the inputs field in your dispatch request and reference them as {{varName}} (e.g. {{customerName}}). For record-based execution, use record metadata: {{_record.metadata.fieldName}} (e.g. {{_record.metadata.email}}).

System variables like {{_flow.name}} and {{_execution.timestamp}} are also available. See Flow variables and templates for the full list.

Example prompt using variables:

Summarize this customer message and suggest a response:

Message: {{messageText}}
Customer tier: {{customerLookup.tier}}
Previous interactions: {{customerLookup.count}}

Flows vs Agents

Flows

Agents

Execute linearly through predefined steps

Run in a loop, iterating until task is complete

You define the steps

AI decides which tools to use

Predictable, controllable

Flexible, autonomous

Best for defined workflows

Best for long-running iterative tasks and turn-taking (e.g., chat agents)

Use Flows when you know the exact steps needed. Flows execute once through their steps and complete.

Use Agents when the AI should decide how to accomplish a goal through iteration. Agents run in a loop—reasoning, calling tools, and evaluating results—making them ideal for tasks requiring multiple rounds of decision-making or turn-taking interactions like chat.

Start with Flows for most use cases. They're easier to debug, more predictable, and faster to execute. Add Agents when you need autonomous decision-making or iterative, turn-taking interactions.

Next steps

Was this helpful?