Workflow Overview
Core workflow concepts, lifecycle, and execution model
Workflow Overview
Workflows are the core building blocks of the Workflows API. This guide explains the fundamental concepts you need to understand when building automated processes.
What is a Workflow?
A workflow is a declarative automation that defines:
- When to run (the trigger)
- What to do (the steps)
- How to handle data (variables and templates)
Workflows enable you to:
- Connect systems - Integrate Stripe, Salesforce, HubSpot, QuickBooks, and more
- Transform data - Map and reshape data between different formats
- Make decisions - Branch logic based on conditions
- Wait for events - Pause for human approval or external events
- Handle errors - Automatic retries with configurable strategies
Workflow Lifecycle
Every workflow progresses through a defined set of states:
| State | Description | Can Execute? | Can Edit? |
|---|---|---|---|
draft | Initial state after creation | No | Yes |
active | Ready to receive triggers and execute | Yes | Yes (creates new version) |
paused | Temporarily disabled | No | Yes |
archived | Soft deleted | No | No |
State Transitions
Workflow Structure
A workflow is defined as a JSON object with these key components:
Triggers
Triggers define when a workflow executes. The Workflows API supports multiple trigger types:
| Type | Description | Use Case |
|---|---|---|
webhook | External system sends an event | Stripe payment, custom webhooks |
schedule | Time-based execution | Daily reports, weekly syncs |
api | Manual execution via API | On-demand processing, testing |
salesforce_event | Salesforce Platform Events or CDC | Record changes, custom events |
hubspot_event | HubSpot property changes | Contact/deal updates |
slack_event | Slack Events API | Messages, mentions, reactions |
slack_slash_command | Slack slash commands | /invoice, /approve |
slack_interactive | Slack interactive components | Button clicks, modal submissions |
gmail_event | Gmail Pub/Sub events | New emails, label changes |
Webhook Triggers
Webhook triggers listen for events from external providers:
Supported providers: stripe, salesforce, hubspot, quickbooks, pandadoc, netsuite, slack
See Webhook Triggers for provider-specific configuration.
Schedule Triggers
Schedule triggers use cron expressions for time-based execution:
See Schedule Triggers for cron syntax and examples.
API Triggers
API triggers allow manual workflow execution:
Steps
Steps define what a workflow does. Each step executes sequentially (unless using parallel execution).
Step Types
| Type | Description | Example |
|---|---|---|
action | Call an integration | Create Stripe invoice, update Salesforce record |
transform | Map and reshape data | Convert webhook payload to invoice format |
condition | Branch based on logic | If amount > $1000, require approval |
wait | Pause execution | Wait 24 hours, delay before retry |
parallel | Execute steps concurrently | Notify Slack AND send email |
loop | Iterate over a collection | Process each line item |
approval | Human-in-the-loop | Wait for manager approval |
agent | AI-powered processing | Extract invoice data, classify expense |
code | Custom JavaScript | Run sandboxed code for complex logic |
slack | Slack building block | Send message, open modal |
email | Email building block | Send templated email |
gmail | Gmail building block | Read/send Gmail messages |
Step Structure
Every step has this base structure:
See Steps Documentation for detailed configuration of each step type.
Template Variables
Template variables allow dynamic data access throughout your workflow using {{expression}} syntax.
Available Contexts
| Context | Syntax | Description |
|---|---|---|
| Input | {{input.field}} | Trigger payload data |
| Steps | {{steps.stepId.output.field}} | Previous step outputs |
| Variables | {{variables.name}} | Workflow-defined variables |
| Environment | {{env.VAR_NAME}} | Environment variables |
| System | {{now}}, {{runId}} | System-provided values |
Examples
Nested Access
Access nested properties using dot notation:
Conditional Expressions
Use Handlebars-style conditionals in templates:
Workflow Execution
When a workflow executes, it creates a run that tracks the execution state.
Run States
| State | Description |
|---|---|
pending | Run created, waiting to start |
running | Currently executing steps |
suspended | Paused for human approval or external event |
completed | All steps finished successfully |
failed | A step failed after all retries |
cancelled | Manually cancelled |
Viewing Run History
Error Handling
The Workflows API provides robust error handling at multiple levels.
Step-Level Retries
Configure automatic retries for transient failures using retryConfig:
| Option | Type | Description |
|---|---|---|
maxAttempts | number | Maximum retry attempts (1-10) |
initialDelayMs | number | Initial delay in milliseconds (min: 100) |
maxDelayMs | number | Maximum delay between retries (min: 1000) |
backoffMultiplier | number | Multiplier for exponential backoff (1-10) |
Error Strategies
Define how to handle step failures using errorHandling:
| Strategy | Behavior |
|---|---|
fail | Stop workflow, mark run as failed (default) |
continue | Log error, continue to next step |
retry | Retry with configured retryConfig settings |
The optional fallback object provides default output values when a step fails with continue strategy.
Timeout Configuration
Prevent steps from hanging indefinitely with timeoutMs:
Versioning
Workflows support version control to track changes over time.
How Versioning Works
- Create - Initial workflow is version 1
- Update - Each update to an active workflow creates a new version
- Execution - Running workflows complete with their started version
- Rollback - Revert to any previous version
Version API
Version States
| State | Description |
|---|---|
current | Active version used for new runs |
archived | Previous version, available for rollback |
rollback | Version restored from rollback operation |
Best Practices
Naming Conventions
- Use descriptive workflow names:
Invoice Customer on Deal Close - Use verb-noun step IDs:
transform-payment,send-notification - Include context in descriptions
Idempotency
Design workflows to be safely re-run:
Error Recovery
- Use appropriate retry counts for each integration
- Set reasonable timeouts
- Use
onError: continuefor non-critical steps
Testing
- Start with
draftstatus for development - Use API trigger for manual testing
- Check run history for debugging