---
schema_version: "1"
id: 9ac991ee67bb39e7bfee91dc2d2bb68343112c0283921a431674a7a8a05daf36
title: Agentforce Workflows
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/salesforcedx/einsteinfordevs/guides/files/devagent-workflows.md
canonical_url: https://developer.salesforce.com/docs/platform/einstein-for-devs/guide/devagent-workflows.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: e4728579d44bc61dec848467d6cac52677cca2fb07abb0b9aa41cf0f37a915de
products:
  - Agentforce Vibes Developer Guide (Deprecated)
  - salesforcedx
---
# Agentforce Workflows

Workflows allow you to define a series of steps to guide Agentforce through repetitive Salesforce development tasks, such as deploying components, running tests, or creating releases. To invoke a workflow in your workspace, type `/[workflow-name.md]` in the chat. Workflows transform how you handle repetitive Salesforce development tasks by creating reusable, automated sequences. Instead of manually performing the same steps repeatedly, you can define workflows once and trigger them with a simple command.

**Key benefits:**

- **Automate repetitive tasks**: Deploy components, run tests, create releases with one command
- **Ensure consistency**: Follow the same process every time
- **Reduce errors**: Eliminate manual steps that can be forgotten or done incorrectly
- **Save time**: Turn multi-step processes into single commands
- **Share processes**: Team members can use the same proven workflows

**Common Salesforce workflow types:**

- **Deployment workflows**: Deploy and validate components across orgs
- **Testing workflows**: Run comprehensive test suites and analyze results
- **Release workflows**: Package and deploy releases with proper validation
- **Component workflows**: Create, test, and deploy new Lightning components
- **Integration workflows**: Set up and validate external integrations

## Create Workflows

Quickly create workflows through Agentforce's built-in interface.

1. **Access Workflow Tab**: Click the `⚖️`icon in the Agentforce chat interface.
2. **Choose Workflow Type**: Select either Global Workflows or Workspace Workflows.
3. **Create New Workflow**: Click `+` to create a new workflow.

Workspace workflows are stored in your project's `.a4drules/workflows` folder. The location of global workflows varies based on your operating system.

### Manage Workflows with the Interface

Agentforce provides a convenient popover interface that allows you to:

- **View Active Workflows**: See which global and workspace workflows are currently active.
- **Toggle Workflows**: Enable or disable specific workflows with a single click.
- **Add or Delete Workflows**: Quickly create or delete workflows.

The real power comes from how you structure your workflow files. You can:

- Leverage Agentforce's built-in tools like `ask_followup_question`, `read_file`, `search_files`, and `new_task`.
- Use command-line tools you already have installed like `sf` (Salesforce CLI) or `git`.
- Reference external MCP tool calls for integrations.
- Chain multiple actions together in a specific sequence.

## Example Salesforce Deployment Workflow

Create a file called `salesforce-deploy.md` and paste this content:

```
You have access to the `sf` terminal command for Salesforce CLI operations. Deploy the components I specify to the target org following this detailed process.
```

---

**1. Gather Deployment Information**

Ask the user which components to deploy and which org to target:

```xml
<ask_followup_question>
  <question>Which components would you like to deploy and to which org?</question>
  <options>["Specific files/folders", "All local changes", "Specific metadata types"]</options>
</ask_followup_question>
```

Validate the target org connection:

```bash
sf org display --target-org <target-org>
```

---

**2. Pre-Deployment Validation**

Check for local changes and potential conflicts:

```bash
sf project retrieve start --dry-run --target-org <target-org>
```

Run local tests if deploying Apex:

```bash
sf apex test run --code-coverage --result-format human
```

Validate deployment without actually deploying:

```bash
sf project deploy start --dry-run --target-org <target-org>
```

---

**3. Analyze and Confirm**

Review validation results and ask for confirmation:

```xml
<ask_followup_question>
  <question>Validation completed successfully. Here's what will be deployed:

  [List of components and validation results]

  Would you like me to proceed with the actual deployment?</question>
  <options>["Yes, deploy now", "No, I need to make changes first", "Show me more details"]</options>
</ask_followup_question>
```

---

**4. Execute Deployment**

Deploy to the target org:

```bash
sf project deploy start --target-org <target-org>
```

Monitor deployment status:

```bash
sf project deploy report --target-org <target-org>
```

---

**5. Post-Deployment Validation**

Run tests in the target org:

```bash
sf apex test run --target-org <target-org> --code-coverage --result-format human
```

Verify deployment success and provide summary:

```xml
<ask_followup_question>
  <question>Deployment completed successfully! Do you need a detailed deployment summary or test results?</question>
  <options>["Show summary", "Show detailed test results", "No, I'm done"]</options>
</ask_followup_question>
```

## Build Your Own Salesforce Workflows

Workflows are completely customizable to your Salesforce development needs. You can create workflows for all kinds of repetitive tasks.

| **Workflow**            | **Step / Action**                                             |
| ----------------------- | ------------------------------------------------------------- |
| **Release Management**  | Grab all merged changes from your feature branches            |
|                         | Build a changelog from commit messages and Jira tickets       |
|                         | Handle version bumps in your `sfdx-project.json` file         |
|                         | Create release packages and validate them across environments |
| **New Component Setup** | Create the component folder structure                         |
|                         | Generate boilerplate HTML, JS, and CSS files                  |
|                         | Set up Jest test files with basic test cases                  |
|                         | Configure component metadata and permissions                  |
|                         | Deploy to development org for initial testing                 |
| **Integration Testing** | Validate Named Credentials and Connected Apps                 |
|                         | Test API endpoints with sample data                           |
|                         | Check error handling and retry logic                          |
|                         | Generate integration test reports                             |
|                         | Update monitoring dashboards                                  |
| **Code Quality**        | Run PMD static analysis on Apex classes                       |
|                         | Check Lightning component accessibility compliance            |
|                         | Validate naming conventions across metadata                   |
|                         | Generate code quality reports                                 |
|                         | Create tickets for issues found                               |

## Common Salesforce CLI Commands for Workflows

| **Basic Org Commands**  | **Command**                               |
| ----------------------- | ----------------------------------------- |
| List authorized orgs    | `sf org list`                             |
| Display org information | `sf org display --target-org <org-alias>` |
| Set default org         | `sf config set target-org <org-alias>`    |

| **Deployment Commands**     | **Command**                                                  |
| --------------------------- | ------------------------------------------------------------ |
| Deploy source to org        | `sf project deploy start --target-org <org-alias>`           |
| Deploy with validation only | `sf project deploy start --dry-run --target-org <org-alias>` |
| Check deployment status     | `sf project deploy report --target-org <org-alias>`          |
| Retrieve metadata from org  | `sf project retrieve start --target-org <org-alias>`         |

| **Testing Commands**      | **Command**                                                                         |
| ------------------------- | ----------------------------------------------------------------------------------- |
| Run all Apex tests        | `sf apex test run --target-org <org-alias> --code-coverage --result-format human`   |
| Run specific test classes | `sf apex test run --class-names "AccountTest,ContactTest" --target-org <org-alias>` |
| Get test results          | `sf apex test report --target-org <org-alias>`                                      |

| **Data Commands** | **Command**                                                                              |
| ----------------- | ---------------------------------------------------------------------------------------- |
| Query data        | `sf data query --query "SELECT Id, Name FROM Account LIMIT 10" --target-org <org-alias>` |
| Import data       | `sf data import tree --plan data/sample-data-plan.json --target-org <org-alias>`         |
| Export data       | `sf data export tree --query "SELECT Id, Name FROM Account" --target-org <org-alias>`    |

```

```
