# Workflows 

AI Workflows allow you to chain multiple [Agents](/docs/dashboard/ai/agents) together to complete complex operations that previously required entire teams. Define a workflow once, and run it on-demand or on a schedule.

### What Are Workflows?

Workflows orchestrate multiple AI agents (Content, Code, Computer Use, and Team Agents) to execute complex, multi-step operations autonomously. Each step in a workflow passes context to the next: content feeds into code, code deploys, Computer Use tests and records demos, and Team Agents run with their own tools (including API requests).

### How Workflows Work

1. **Define Your Workflow**: Choose a template or build custom. Chain Content, Code, Computer Use, and Team Agents in any sequence. Set triggers: manual, scheduled, or event-driven.

2. **Execute Automatically**: Agents work sequentially or in parallel. Each step passes context to the next, maintaining continuity throughout the workflow.

3. **Monitor in Real-Time**: Watch progress live with step-by-step updates. See token usage, costs, and duration. Pause for approval gates when human review is needed.

4. **Review & Iterate**: Get complete execution summaries. View all created content, code changes, and recordings. Clone successful workflows for future projects.

5. **Rerun Anytime**: Run workflows on-demand or schedule them to run automatically. Your automation runs 24/7 without intervention.

### Workflow Use Cases

#### Full-Stack Product Launch

**Time: 20 minutes vs 2-3 weeks**

Content Agent creates your product catalog, Code Agent builds the storefront, Computer Use Agent tests and records a demo video. Complete e-commerce site, deployed.

**Workflow steps:** Content Generation → Code Development → Deploy & Test

#### Automated Content Optimization

**Schedule: Runs every Monday at 2 AM**

Automatically analyze 500+ articles for outdated content, validate links, capture fresh screenshots, and update flagged articles. Always-fresh content, zero manual work.

**Workflow steps:** Analyze Content → Validate Links → Auto-Update

#### Multi-Market Launch

**Time: 90 minutes vs 16 weeks**

Launch in 12+ markets simultaneously. Localized content, market-specific websites, compliance validation, and demo videos—all running in parallel.

**Workflow steps:** Localize Content → Deploy Sites → Validate Compliance

#### Auto-Documentation

**Trigger: On every deploy**

Code deploys to production, agents analyze changes, test new features, capture demo videos, write documentation, and create sales materials. Docs ship with features.

**Workflow steps:** Analyze Code → Test Features → Generate Docs

### Creating a Workflow

1. Open your project and click **AI Studio** in the project sidebar, then choose **Workflows**
2. Click **"Create Workflow"**
3. Add steps by selecting agent types (Content, Code, Computer Use, or Team Agent)
4. Configure each step with specific instructions
5. Set execution order (sequential or parallel)
6. (Optional) Add approval gates for human review
7. (Optional) Set a schedule or trigger for automatic execution

### Team Agent Steps

A **Team Agent** step runs one of your existing team agents as a workflow step. Instead of configuring a one-off agent inline, you pick a team agent from a dropdown, and the step runs that agent with its own saved prompt, model, and capabilities.

This is the way to give a workflow step access to the full team-agent toolset, including **API requests** (`api_request`), notifications, and any pre-configured API endpoints. Regular Content, Code, and Computer Use steps run with a limited toolset, so when you need a step to call an external API or use a team agent's tools, use a Team Agent step.

**How it works:**
- Select an active team agent for the step. The step stores a live reference to that agent (its `agent_id`), so changes you make to the agent later apply to the workflow automatically.
- Add optional **Instructions for this step**. If provided, they are passed to the agent as the run prompt; otherwise the agent uses its own saved prompt.
- The previous step's output is passed along as context, and the agent's reply becomes this step's output for the next step.
- Each run uses a fresh conversation, so workflow runs do not pollute the agent's chat history. Open the step in the execution detail view to see the full conversation.

**Notes:**
- Team Agent steps do not support interactive approvals. If the agent requires approval to act, turn that off on the agent or add a separate Approval Gate step.
- A team agent referenced by a workflow step still counts once against your team-agent limit; the step itself does not consume an additional automation slot.

### Workflow Features

- **Sequential or Parallel Execution**: Run steps one after another or simultaneously
- **Context Passing**: Each step receives output from previous steps
- **Approval Gates**: Pause workflow for human review when needed
- **Scheduling**: Run workflows on a schedule (hourly, daily, weekly, monthly)
- **Event Triggers**: Automatically trigger workflows on specific events
- **Real-Time Monitoring**: Watch progress with live updates
- **Execution History**: Review past runs with complete logs and outputs
- **Templates**: Start with pre-built workflow templates for common use cases

### Event-Triggered Workflows

Workflows can be configured to run automatically when content events occur, enabling powerful automation scenarios.

**Available Events:**
- **Object Created**: Run workflow when new content is added
- **Object Edited**: Run workflow when content is modified
- **Object Deleted**: Run workflow when content is removed
- **Object Published**: Run workflow when content goes live
- **Object Unpublished**: Run workflow when content is taken offline

**Event Context Data:**

When an event triggers your workflow, the following data is automatically included in the prompt context for all workflow steps:
- **Event Type**: The action that triggered the workflow
- **Object Type**: The content type that was affected
- **Object ID**: The unique identifier of the object
- **Object Data**: Title, slug, status, locale, and all metadata fields

**Using Event Data for Conditional Logic:**

Each step in your workflow can reference the event data to make decisions:
```
Step 1 (Content Agent):
"If the triggered object's status is 'draft', generate SEO metadata.
 If the object is 'published', create social media posts instead."

Step 2 (Code Agent):
"If the object type is 'products' and the price field changed,
 update the pricing display component."

```
**Example Event-Triggered Workflows:**

**Auto-SEO on Publish:**
```
Trigger: Object Published (blog-posts)
Step 1: Generate meta description and keywords from content
Step 2: Create Open Graph image using AI image generation
Step 3: Update object with SEO metadata

```
**Content Localization Pipeline:**
```
Trigger: Object Created (articles)
Step 1: If locale is 'en-US', translate to Spanish, French, German
Step 2: Create localized versions as new objects
Step 3: Send notification with translation summary

```
**Product Update Automation:**
```
Trigger: Object Edited (products)
Step 1: If price changed, update all related promotional content
Step 2: Regenerate product comparison charts
Step 3: Notify sales team via email

```
### Workflow Examples

**Research-to-Publication Pipeline:**
```
Step 1 (Content Agent): Research topic from specified sources
Step 2 (Content Agent): Write article draft with citations
Step 3 (Code Agent): Create landing page for article
Step 4 (Computer Use Agent): Record demo video and screenshots
Step 5 (Content Agent): Publish with all media assets

```
**Code Review and Documentation:**
```
Step 1 (Code Agent): Implement feature from requirements
Step 2 (Code Agent): Write unit tests
Step 3 (Computer Use Agent): Test in browser and record demo
Step 4 (Content Agent): Generate documentation from code changes
Step 5 (Code Agent): Open PR with docs and demo video

```
### Best Practices

- **Start Simple**: Begin with 2-3 step workflows and add complexity as needed
- **Use Approval Gates**: Add human review steps for critical operations
- **Test First**: Run workflows manually before scheduling
- **Monitor Costs**: Watch token usage across workflow steps
- **Clone Successful Workflows**: Reuse working workflows as templates for new projects

## Execution Retention 

Agent and workflow executions are automatically cleaned up after a retention period to manage storage and keep your dashboard performant.

### Retention Policy

- **Retention Period**: 90 days
- **Affected Executions**: Completed, failed, and cancelled executions
- **Protected Executions**: Running and active executions are never automatically deleted

### What Gets Deleted

When an execution exceeds the retention period, the following data is removed:
- Execution logs and message history
- Step-by-step results and outputs
- Token usage records for that execution
- Associated metadata (commits, file changes for code agents)

### What's Preserved

- **Agent and Workflow configurations** are never deleted by retention policies
- **Running executions** remain until they complete
- **Content created by agents** (CMS objects, media) persists independently
- **Code changes** committed to your repository remain in Git history
- **Pull requests** created by code agents remain in GitHub

### Best Practices

- Export important execution logs before the 90-day retention period if you need long-term records
- Use the execution detail view to review results while they're available
- Agent configurations store your prompts and settings permanently—only execution history expires