# Create flows and agents

import { Steps, TabItem, Tabs } from "@astrojs/starlight/components"

A **flow** is a deterministic sequence of steps you design on the canvas. An **agent** starts from a prompt and lets AI
choose how to reach a goal within your environment’s credentials and permissions. Both open in the same **designer**,
where you add steps, configure settings, and prepare a version to deploy.

## When to use

- You finished planning and credentials and are ready to create the automation in Studio.
- You need repeatable, step-by-step control—prefer a **flow**.
- You need flexible triage, classification, or unstructured input—prefer an **agent** (or add an **AI··Task** inside a
  flow later).
- Prefer [Plan before you build](/getting-started/plan-before-you-build/) when the scenario and credentials are not
  ready yet.
- Prefer [Use AI··Agent](/guides/build/use-ai-in-flows/use-ai-agent/) when you attach a Flowhook-based agent on an
  **AI··Task** **Agents** tab.
- Prefer [Manage versions and deployments](/guides/operate/manage-version-and-deployments/) when the design is ready to
  run in an environment.

Before you begin, confirm you can open **Flows** and that you are an **Owner** or **Operator** on the environment where
the flow or agent will run. Create that environment and its credentials first—see
[Create and manage environments](/getting-started/environments/) and
[Create and manage credentials](/getting-started/credentials/).

## Guide

### Create a flow or an agent

On **Flows**, **Create** offers two starters that match Studio’s menu copy. **Flow** builds an advanced automation from
scratch with full control (you can still add AI later). **Agent** starts from one prompt and seeds a graph you can grow
(webhook plus an **AI··Task**). Pick the starter that matches how much of the path you already know.

1. **Open Flows.** In the Studio sidebar, choose **Flows**. Use the table or cards layout when you want a denser list
   or a board-style scan.

   <div class="docs-screenshot-compact">

   ![Flows page in table layout with name, deployments, access, and last edition columns](./assets/flows-page-table-view.png)

   </div>

2. **Open Create.** In the page header, click **Create**.

   <div class="docs-screenshot-compact">

   ![Flows page with Create menu open showing Flow and Agent options](./assets/create-menu-flow-agent.png)

   </div>

3. **Choose Flow or Agent.** Select **Flow** to define the logic yourself, or **Agent** to begin from a prompt.

1. **Name the flow.** Enter a title that states the outcome—for example `Enrich phishing alerts`.
2. **Choose the environment.** Select the environment that holds the credentials this flow will use—for example
   **Docs**.
3. **Create.** Click **Next**, confirm access if prompted, then click **Create**. Studio opens the designer.

   <div class="docs-screenshot-compact">

   ![Create a new flow modal with Enrich phishing alerts and Docs environment](./assets/create-flow-wizard.png)

   </div>

1. **Name the agent.** Enter a title that states the job—for example `Triage phishing emails`.
2. **Choose the environment.** Select the environment whose credentials the agent may use—for example **Docs**.
3. **Create.** Click **Next**, confirm access if prompted, then click **Create**. Studio opens the designer with a
   webhook trigger and an **AI··Task** prompt step ready to edit.

   <div class="docs-screenshot-compact">

   ![Create a new simple agent modal with Triage phishing emails and Docs environment](./assets/create-agent-wizard.png)

   </div>

### Work in the designer

The designer is the visual canvas where you add steps, connect them, and configure behavior. Rename steps and fill
descriptions so the graph matches your scenario.

1. **Open the flow.** From **Flows**, select the flow or agent you created—or stay on the designer after **Create**.
2. **Add and rename steps.** Build the path your scenario needs. Give each step a clear title and description.

<div class="docs-screenshot-wide">

![Enrich phishing alerts designer with Receive phishing alert, Normalize alert fields, and Success](./assets/flow-designer-canvas.png)

</div>

#### Top toolbar

The floating bar at the top of the designer names the flow, shows which environment and version you are editing, and
exposes run, settings, more actions, and lock. Changelog, run logs, and **AI··Build** are on the
[right rail](#right-rail-history-and-aibuild)—not in this bar.

<div class="docs-screenshot-wide">

![Designer top toolbar with Enrich phishing alerts, Docs latest, Run, Settings, and Lock](./assets/designer-top-toolbar.png)

</div>

- **Name:** current flow name—click to rename (and change the icon). Use the star to favorite the flow.
- **Environment and version:** which environment and version are open (for example **Docs** / **latest**)—switch from
  the dropdown.
- **Run:** run this playbook from the designer.
- **Settings:** opens flow settings (**Timeout (seconds)**, email notifications, **Run logs**)—see
  [Configure flow settings](#configure-flow-settings).
- **More actions:** copy the flow and related actions.
- **Lock / Unlock:** prevent accidental edits (useful for production designs).

#### Right rail (history and AI··Build)

The vertical rail on the right opens side panels without leaving the canvas.

<div class="docs-screenshot-compact">

![Designer right rail with Browse updates, Open logs side panel, and AI··Build](./assets/designer-version-ai-build-controls.png)

</div>

- **Browse updates:** open the **Updates** changelog for this flow.
- **Open logs side panel:** open **Logs** for recent runs—see also
  [Manage versions and deployments](/guides/operate/manage-version-and-deployments/).
- **AI··Build:** open **AI Build** to draft or extend the flow with AI—see
  [AI··Build: Faster flow creation](/guides/build/design-your-flow/ai-build-faster-flow-creation/).

#### Bottom toolbar

The floating bar at the bottom of the canvas helps you rearrange and frame the graph while you edit.

<div class="docs-screenshot-compact">

![Designer bottom toolbar with Undo, Redo, auto-layout, and zoom controls](./assets/designer-bottom-toolbar.png)

</div>

- **Undo / Redo:** move through edit history.
- **Auto-layout:** rearrange steps into a readable layout.
- **Zoom in / Zoom out:** adjust canvas zoom.
- **Zoom to fit:** show the entire flow in view.

### Configure flow settings

Flow settings control how long a run may take, who gets email about outcomes, and how long Mindflow keeps run log data.
Open them from the designer gear before you rely on a deployment in production.

1. **Open Settings.** In the designer top toolbar, click the gear (**Settings**).
2. **Set Timeout (seconds).** Enter the maximum run duration (placeholder **300**). Mindflow stops the run when the
   limit is reached (status **Timed out**). The allowed range is **0**–**604800** seconds (one week).
3. **Choose email notifications.** Pick **No notifications**, or notify on failure, success, or both. Changes can take
   up to about **15 minutes** to apply on runs.
4. **Set Retention period.** Under **Run logs**, set the duration and unit (for example **1** / **weeks**), click
   **Save**, then optionally turn on **Redact run log data** when you need new runs to show `[Redacted]` in Studio.

   <div class="docs-screenshot-compact">

   ![Flow Settings with Timeout 300, No notifications, Retention period 1 weeks, Redact off](./assets/flow-settings-dialog.png)

   </div>

5. **Use the other tabs when needed.** **Logs** shows execution logs, **Variables** holds flow-scoped values,
   **Output** defines the value the flow returns, and **Info** holds description and time-saved metadata.

### Connect design to environments and deployments

A flow or agent is a **versioned** design. It becomes runnable when you **deploy** a version into an **environment**.
That deployment uses only the **integrations** and **credentials** available there. Design once, then deploy to as many
environments as you need—each with its own secrets and access.

:::note
Design the flow, **deploy a version** to an environment, and that deployment runs with the **integrations and
credentials** available in that environment.
:::

## Example

A SOC analyst creates **Enrich phishing alerts** in the **Docs** environment: a webhook receives the alert, a transform
normalizes fields, and **Success** ends the run. The same team later creates **Triage phishing emails** as an **Agent**
when they want a prompt-first path for unstructured mail.

1. **Create the flow.** On **Flows**, choose **Create** → **Flow**, name it `Enrich phishing alerts`, pick **Docs**,
   and create.
2. **Build the path.** Add a webhook (**Receive phishing alert**), a transform (**Normalize alert fields**), and a
   **Success** terminal. Fill descriptions on steps that support them so the canvas reads like the scenario.
3. **Tune settings.** Set **Timeout (seconds)** to **300**, leave **No notifications** while testing, set **Retention
   period** to **1** / **weeks**, and leave **Redact run log data** off unless you need it.
4. **Deploy when ready.** Deploy the version to **Docs** for tests, then to production with that environment’s
   credentials—see [Manage versions and deployments](/guides/operate/manage-version-and-deployments/).

## Keep in mind

- **Flow vs agent:** Use a flow when every branch should be explicit. Use an agent (or an **AI··Task** in a flow) when
  the path depends on interpretation.
- **Lock:** Lock production designs so accidental edits do not land on the wrong version.
- **Retention and privacy:** Shorter **Retention period** reduces stored run data; turn on **Redact run log data** when
  logs may contain secrets (applies to new runs).
- **Environment scope:** Credentials and integrations stay on the environment of the deployment—not on the design
  alone.

## Related

- [Plan before you build](/getting-started/plan-before-you-build/) — outline the scenario and credentials first.
- [Visual Mindflow language](/getting-started/visual-mindflow-language/) — transforms, loops, conditions, and waits.
- [AI··Task: A simple guide](/guides/build/use-ai-in-flows/ai-task-a-simple-guide/) — add AI inside a flow.
- [Manage versions and deployments](/guides/operate/manage-version-and-deployments/) — deploy a version into an
  environment.
