> ## Documentation Index
> Fetch the complete documentation index at: https://helpcenter.magure.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Workflow overview

> Build and run AI workflows that orchestrate agents, tools, and logic to accomplish complex tasks

## What is a Use Case?

In MagOneAI, a **Use Case** is a workflow — a sequence of activities that orchestrate AI agents, tools, and logic to accomplish a task. Each Use Case is defined visually on the canvas, stored as portable JSON, and executed durably by Temporal.

Think of a Use Case as a blueprint for how your AI agents, tools, and decision logic work together. You define the steps, connect them together, and MagOneAI handles the orchestration, execution, and state management.

<Info>
  MagOneAI uses the term "Use Case" for what other platforms call workflows or pipelines. Each Use Case contains **Activities** — the individual steps that make up the workflow.
</Info>

## Visual canvas builder

Build workflows visually using the drag-and-drop canvas in MagOneAI Studio. The canvas provides an intuitive way to design complex orchestration logic without writing code.

### Building on the canvas

<Steps>
  <Step title="Add activities">
    Drag activity nodes from the sidebar onto the canvas. Each node represents a step in your workflow.
  </Step>

  <Step title="Connect the flow">
    Draw connections between nodes to define the execution order. Data flows through these connections.
  </Step>

  <Step title="Configure each node">
    Click any node to configure its settings, input mapping, and output handling.
  </Step>

  <Step title="Test and deploy">
    Test your workflow with sample data, then deploy it for production use.
  </Step>
</Steps>

### Available node types

<CardGroup cols={2}>
  <Card title="Agent" icon="robot" href="/workflows/agent-node">
    Execute an AI agent with reasoning, tools, knowledge bases, and structured output via DSPy
  </Card>

  <Card title="Tool" icon="wrench" href="/workflows/tool-node">
    Call an MCP tool directly with specific parameters
  </Card>

  <Card title="API" icon="globe" href="/workflows/api-node">
    Call any external HTTP API as a deterministic step, with built-in auth and SSRF protection
  </Card>

  <Card title="Respond" icon="reply" href="/workflows/respond-node">
    Format a response with a template or generate typed structured output with an LLM
  </Card>

  <Card title="Parallel" icon="code-branch" href="/workflows/parallel-node">
    Run multiple branches simultaneously with configurable merge strategies
  </Card>

  <Card title="Condition" icon="code-branch" href="/workflows/condition-node">
    Route execution based on conditional logic (LLM-based or expression-based)
  </Card>

  <Card title="Human Task" icon="user-check" href="/workflows/human-task-node">
    Pause for human approval or input before continuing
  </Card>

  <Card title="Sub Use Case" icon="diagram-nested" href="/workflows/sub-usecase-node">
    Call another workflow as a reusable component with input/output mapping
  </Card>

  <Card title="ForEach" icon="repeat" href="/workflows/foreach-node">
    Iterate over collections, executing a child use case for each item in concurrent batches
  </Card>

  <Card title="Code" icon="code" href="/workflows/code-node">
    Run your own Python in an isolated sandbox for custom logic, data transforms, and file generation
  </Card>
</CardGroup>

Every workflow also includes automatic **Start** and **End** boundary nodes that mark the entry and exit points of execution. The Start node receives the trigger input; the End node formats and returns the final output.

## End node output

The **End node** is the exit point of every workflow. It decides the shape of the value returned to the caller through its `output_format`, which is one of three options:

<Tabs>
  <Tab title="json (default)">
    Returns structured data. Map output fields to their source paths with `inputs`. Set `strict_output: true` to restrict the returned object to only the keys you declare in `inputs`; the default (`false`) preserves the implicitly chained variable store.

    ```json theme={null}
    {
      "id": "_end",
      "type": "end",
      "config": {
        "output_format": "json",
        "inputs": { "result": "respond.summary" }
      }
    }
    ```

    An optional `output_schema` (JSON Schema) can validate the output.
  </Tab>

  <Tab title="string">
    Returns a single templated string. `string_template` is required for this format.

    ```json theme={null}
    {
      "id": "_end",
      "type": "end",
      "config": {
        "output_format": "string",
        "string_template": "Result: {{respond.summary}}"
      }
    }
    ```
  </Tab>

  <Tab title="dashboard">
    Returns a titled dashboard assembled from `sections`. A `dashboard` config is required. Each section has a `title`, a `data_path` pointing at the data in the variable store, and a `format`: `table` (default), `list`, `chart`, or `text`.

    ```json theme={null}
    {
      "id": "_end",
      "type": "end",
      "config": {
        "output_format": "dashboard",
        "dashboard": {
          "title": "Analysis results",
          "sections": [
            { "title": "Line items", "data_path": "results.items", "format": "table" },
            { "title": "Summary", "data_path": "respond.summary", "format": "text" }
          ]
        }
      }
    }
    ```
  </Tab>
</Tabs>

<Note>
  For chat-triggered use cases, the chat layer reads `_final["response"]` in `json` format or the whole string in `string` format. To control the assistant's reply, set `inputs = { "response": "<source.path>" }` (json) or use `output_format: "string"` with a `string_template`. No other field name is searched.
</Note>

## Workflow as JSON

Every canvas workflow has an equivalent JSON definition. This portable format enables:

* **Version control** — Track changes to workflows in Git
* **Import/export** — Share workflows across projects and teams
* **Programmatic generation** — Build workflows dynamically
* **Backup and migration** — Move workflows between environments

The JSON definition captures everything: activity types, configurations, connections, input/output mappings, and conditional logic. You can switch between visual and JSON editing at any time.

## Execution lifecycle

When you trigger a workflow, MagOneAI orchestrates a series of steps to execute your Use Case reliably and durably.

<Steps>
  <Step title="Trigger fires">
    The workflow starts from a trigger — an API call, schedule, manual execution, or chat message. The trigger provides initial input data.
  </Step>

  <Step title="Temporal workflow starts">
    MagOneAI creates a Temporal workflow execution. This ensures durable execution with automatic recovery and retry capabilities.
  </Step>

  <Step title="Activities execute in sequence">
    Each activity in your workflow runs in order, respecting parallel branches and conditional logic. Activities execute one at a time unless you use Parallel nodes.
  </Step>

  <Step title="Activity processing">
    Each activity receives input from the variable store, performs its work (agent reasoning, tool execution, etc.), and produces output.
  </Step>

  <Step title="Variable store updates">
    After each activity completes, its output is stored in the variable store. Subsequent activities can access this data through variable references.
  </Step>

  <Step title="Workflow completes">
    When all activities finish, the workflow completes. The final output is returned to the caller and stored in execution history.
  </Step>
</Steps>

### Data flow through the workflow

Data flows through your workflow via the **variable store** — a key-value store scoped to each execution:

1. **Trigger input** enters the variable store
2. **Activity outputs** are written to the variable store
3. **Downstream activities** read from the variable store using variable references like `{{previous_activity.field}}`
4. **Final output** is assembled from variable store contents

Learn more about the variable store in the [Memory and variable store](/workflows/memory) guide.

## Temporal durable execution

MagOneAI leverages Temporal to provide robust, reliable workflow execution with enterprise-grade durability guarantees.

### What Temporal provides

<CardGroup cols={2}>
  <Card title="Crash recovery" icon="shield-check">
    If a server crashes mid-execution, the workflow automatically resumes from the last checkpoint
  </Card>

  <Card title="Automatic retries" icon="rotate">
    Failed activities are automatically retried according to your retry policy
  </Card>

  <Card title="Long-running execution" icon="clock">
    Workflows can run for minutes, hours, or even days without losing state
  </Card>

  <Card title="Full observability" icon="eye">
    Complete execution history with activity-level logs, timing, and state transitions
  </Card>
</CardGroup>

### How checkpointing works

Every workflow step is checkpointed to durable storage:

* **Before each activity** — Temporal records the execution state
* **After each activity** — Results are persisted before moving to the next step
* **On failure** — The workflow can resume from the last successful checkpoint
* **Across restarts** — Server restarts don't interrupt execution

This means your workflows are resilient to infrastructure failures, deployment updates, and transient errors. Execution state is never lost.

### Benefits for AI workflows

Durable execution is especially valuable for AI workflows:

* **Long LLM calls** — Agents can take minutes to reason and execute tools
* **Human-in-the-loop** — Workflows can wait hours or days for human approval
* **Batch processing** — Process thousands of items without worrying about failures
* **Cost optimization** — No compute resources consumed while waiting for external events

<Tip>
  Temporal's durable execution means you can design workflows with confidence. Don't worry about crashes, timeouts, or lost state — focus on the logic and let MagOneAI handle the reliability.
</Tip>

## Next steps

<CardGroup cols={2}>
  <Card title="Agent node" icon="robot" href="/workflows/agent-node">
    Learn how to use AI agents as workflow activities
  </Card>

  <Card title="Parallel execution" icon="code-branch" href="/workflows/parallel-node">
    Run multiple branches simultaneously for complex orchestration
  </Card>

  <Card title="Memory system" icon="database" href="/workflows/memory">
    Understand how data flows through your workflows
  </Card>

  <Card title="Triggers and execution" icon="play" href="/workflows/triggers-and-execution">
    Start and monitor your workflow executions
  </Card>
</CardGroup>
