---
title: "Workflows"
description: "Orchestrate multi-step automations across connected services, assistants, and decision models using triggers and visual execution graphs."
updated: 2026-11-16
---

# Workflows

While a single assistant prompt or a custom Wrench handles focused tasks, real-world business processes often span multiple systems, require conditional branching, and demand reliable background execution. 

**Workflows** provide a visual, multi-step orchestration engine built directly into Toolbelt. Instead of forcing an LLM to reason through dozens of API calls sequentially during a single chat turn, Workflows allow you to structure deterministic processes: fetch data directly from connected MCP tools, execute custom JavaScript wrenches, evaluate conditions or fast classifiers, delegate specialized work across assistants, and post results to your team.

:::cards 3

===card
title: Visual Orchestration
icon: git-branch

Construct complex, branching directed acyclic graphs (DAGs) in the visual builder, or have your assistant draft and wire them from natural language prompts.

===card
title: Direct Tool & Wrench Execution
icon: plug

Call MCP tools and server-side wrenches directly in workflow steps without LLM reasoning overhead, using dynamic `{{trigger.<path>}}` variable interpolation.

===card
title: Hybrid Intelligence
icon: cpu

Combine deterministic expressions, sub-second zero-turn Classifiers, and multi-model assistant steps to balance speed, cost, and analytical depth.

:::

---

## Key Concepts

Every Workflow consists of three elements:

1. **Triggers:** The event or schedule that kicks off an execution.
2. **Steps:** The individual units of execution (fetching data, executing a wrench script, prompting an LLM, evaluating a branch, running a task).
3. **Edges:** Directed connections that define execution order, pass context from step to step, and determine branch paths.

---

## Triggers

Workflows start automatically from incoming events or run on demand. You can attach multiple triggers to a single workflow:

| Trigger Type | Description | Configuration |
|---|---|---|
| `manual` | Triggered manually from the UI, by an assistant using `manage_workflows`, or via the REST API. | None required. |
| `scheduled` | Recurring background execution managed by Toolbelt. | Standard cron expression (e.g., `0 8 * * 1-5` for 8 AM weekdays). |
| `webhook` | Triggered by an inbound HTTP POST request from an external system. | Toolbelt generates a secure, unique webhook URL and token. |
| `message` | Triggered when a new message arrives in a specified chat or channel. | Channel or source filter. |

Incoming trigger payloads are preserved in the execution context and can be referenced in subsequent steps under the `trigger.` namespace.

---

## Step Types

Workflows support eight distinct step types to handle everything from pure API calls and server-side scripts to creative drafting:

### 1. Tool Call
Type: `tool_call`. Executes a connected MCP tool directly (such as fetching tickets from Jira, querying GitHub, or sending an email) without waking an assistant.

- **Fast & deterministic:** Skips prompt generation and token costs.
- **Variable placeholders:** Reference trigger data or prior step outputs directly inside tool arguments using `{{trigger.<path>}}` (for example, `{{trigger.body.issue_id}}`).
- **Built-in deduplication:** When polling feeds on a recurring schedule, configure `keyPath` (e.g., `id`) to track seen items. Toolbelt only passes newly arrived items to downstream steps, preventing duplicate alerts.

```json
{
  \"id\": \"fetch_alerts\",
  \"type\": \"tool_call\",
  \"title\": \"Fetch Unresolved Alerts\",
  \"toolName\": \"pagerduty_list_incidents\",
  \"arguments\": {
    \"status\": \"triggered\",
    \"urgency\": \"{{trigger.urgency}}\"
  }
}
```

### 2. Wrench
Type: `wrench`. Executes a server-side JavaScript [Wrench](https://docs.apexti.com/features/wrenches.md) directly within the workflow engine without invoking an LLM.

#### Why use a direct Wrench step?
While a `tool_call` step invokes a single API method, business processes often require multi-step scripting: parsing nested arrays, computing differences, aggregating data across multiple endpoints, or applying complex conditional logic. 

Instead of routing these tasks through an assistant turn (`message` step) — which incurs token latency and potential non-determinism — the `wrench` step executes sandboxed JavaScript natively in the Toolbelt backend in milliseconds.

#### Key capabilities
- **Dynamic Context Interpolation:** Pass workflow data into wrench arguments using double curly-brace syntax (`{{trigger.<path>}}`, `{{steps.<id>.<path>}}`, or `{{previous.<path>}}`).
- **Zero Token Overhead:** Does not wake an assistant or consume model tokens.
- **Custom Timeout Handling:** Inherits the Wrench's configured timeout or overrides it for batch workflow operations.
- **Structured JSON Output:** Returns typed objects directly into the execution graph, accessible to all downstream steps under `{{steps.<stepId>.result}}`.

```json
{
  \"id\": \"aggregate_daily_metrics\",
  \"type\": \"wrench\",\n  \"title\": \"Aggregate Daily Metrics\",
  \"wrenchId\": \"calculate-service-health\",
  \"arguments\": {
    \"organizationId\": \"{{trigger.org_id}}\",
    \"threshold\": 95.5,
    \"events\": \"{{steps.fetch_event_logs.result.data}}\"
  },
  \"timeoutSeconds\": 120
}
```

### 3. Message
Type: `message`. Invokes an assistant to reason, synthesize, or draft content.

- **Target assistant:** Direct the step to a specific assistant UUID, leave blank for the workflow owner, or set `targetAssistantId: \"auto\"`.
- **Dynamic routing (`auto`):** When set to `auto`, Toolbelt's delegation router automatically inspects connected assistants' capabilities and routes the task to the best-equipped agent.

### 4. Task
Type: `task`. Dispatches an inter-assistant work item, tracking completion and handing the result back to the workflow graph.

### 5. Condition
Type: `condition`. Evaluates deterministic expressions to route execution along different edges.

- **Expression syntax:** `<path> <operator> <value>`
- **Supported operators:** `==`, `!=`, `contains`, `>`, `<`, `exists`
- **Context paths:** Reference `trigger.<path>`, `previous.<path>`, `last.<path>`, or `steps.<stepId>.<path>`.
- **Natural language fallback (`nl:`):** Prefix a condition with `nl:` (e.g., `nl: is this a critical production issue?`) to let the decision model evaluate subtle text when deterministic rules aren't enough.

```
trigger.action == \"opened\"
previous.newCount > 0
steps.check_status.result contains \"error\"
```

### 6. Classify
Type: `classify`. Runs a saved, versioned [Classifier](https://docs.apexti.com/features/classifiers.md) on the trigger payload or previous output in ~100 ms with **no assistant turn**.

- Uses fast decision models to answer structured choice, score, or yes/no questions.
- Branches execution based on the classified answer (e.g., routing billing inquiries to Finance and technical bugs to Engineering).

### 7. Decision
Type: `decision`. Branches execution using a decision model or an assistant turn (`mode: \"assistant\"`), evaluating complex inputs against a configured default branch.

### 8. Parallel
Type: `parallel`. Forks execution to run multiple downstream branches concurrently, synchronizing once all parallel paths complete.

---

## Authoring Workflows

You can author and manage workflows in two ways:

### 1. In the web UI

Navigate to **Configure → Workflows** on your assistant.

- **Visual Graph Canvas:** Drag and drop steps, connect edges from step handles, and visually arrange branching logic.
- **Visual Edge Routing:** Connect branches from decision, condition, or classify steps directly to their target steps.
- **Execution History:** View real-time and historical executions, step-by-step logs, input payloads, and intermediate results.

### 2. Conversational creation

Ask your assistant in chat to build or update workflows for you. Assistants use the `manage_workflows` tool to plan and scaffold multi-step architectures:

> *\"Create a workflow that triggers whenever a webhook arrives, checks if the severity is high, summarizes the issue, and posts to Slack.\"*

The assistant uses `action: \"plan_from_prompt\"` with `create: true` to generate all step objects, resolve tool names, and configure the graph edges automatically.

---

## Runtime Variables & Context Reference

Downstream steps have access to execution context through templating:

| Context Namespace | What It Contains | Example |
|---|---|---|
| `trigger.<path>` | The payload received from the trigger event (webhook JSON, cron metadata, message body). | `{{trigger.pull_request.head.ref}}` |
| `previous.<path>` | The result or payload emitted by the immediately preceding step. | `{{previous.summary}}` |
| `steps.<stepId>.<path>` | The explicit output of an earlier step identified by its step ID. | `{{steps.fetch_alerts.result[0].id}}` |

---

## Best Practices

> **Tip: Prefer `tool_call` and `wrench` over `message` for deterministic steps.**  
> Do not ask an LLM to make API calls or perform calculations if the parameters are known or can be scripted in a Wrench. Tool call and wrench steps run faster, cost zero tokens, and eliminate hallucination risks.

> **Tip: Use `auto` targeting for modular teams.**  
> When delegating work across a team of specialized assistants, use `targetAssistantId: \"auto\"` on message steps. As you add or refine assistants in your organization, the router automatically redirects tasks to the best agent.

> **Warning: Always configure default branches.**  
> When using `condition`, `decision`, or `classify` steps, ensure a default edge is defined so the workflow continues gracefully if an unexpected value arrives.

---

## Related Topics

- [Assistant Design](https://docs.apexti.com/features/assistant-design.md) — Map workflows into cohesive jobs on the capability graph.
- [Wrenches](https://docs.apexti.com/features/wrenches.md) — Package multi-tool JavaScript snippets into single executable tools.
- [Scheduled Tasks](https://docs.apexti.com/features/scheduled-tasks.md) — Set up recurring schedules for single-prompt and direct wrench executions.
- [Assistant-to-Assistant Communication](https://docs.apexti.com/features/assistant-to-assistant.md) — How assistants coordinate work across organizations.
