Workflow Registration

Define and register multi-step automated workflows.

Overview

The hyperfold workflow register command creates automated workflows that respond to events, execute actions, and coordinate between agents and external systems.

Workflows are powered by Google Cloud Workflows, providing reliable execution, automatic retries, and detailed audit trails.

Workflow Definition

Define workflows in YAML with triggers, steps, and conditions:

yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# post-purchase-workflow.yaml
name: post_purchase_flow
description: "Automated post-purchase sequence"
version: "1.0"
trigger:
event: order.completed
conditions:
- "order.total >= 50"
steps:
- id: send_confirmation
type: action
action: notifications.send_email
params:
template: order_confirmation
to: "{{order.customer.email}}"
data:
order_id: "{{order.id}}"
items: "{{order.items}}"
total: "{{order.total}}"
- id: update_crm
type: action
action: salesforce.update_opportunity
params:
opportunity_id: "{{order.metadata.sf_opportunity_id}}"
stage: "Closed Won"
amount: "{{order.total}}"
depends_on: [send_confirmation]
- id: check_loyalty
type: condition
condition: "order.customer.total_orders >= 10"
on_true: upgrade_tier
on_false: send_survey
- id: upgrade_tier
type: action
action: customer.upgrade_tier
params:
customer_id: "{{order.customer.id}}"
new_tier: gold
- id: send_survey
type: action
action: notifications.send_email
params:
template: feedback_survey
to: "{{order.customer.email}}"
delay: "3d"
- id: schedule_followup
type: action
action: agent.schedule_outreach
params:
agent: recommender-01
customer_id: "{{order.customer.id}}"
delay: "7d"
context:
last_purchase: "{{order.items}}"
depends_on: [check_loyalty]

Register Workflow

Register workflows and manage their lifecycle:

bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Register a workflow from YAML file
$ hyperfold workflow register ./post-purchase-workflow.yaml
> [Parse] Reading workflow definition...
> [Validate] Checking step dependencies...
> [Validate] Verifying action permissions...
> [Register] Creating workflow in Firestore...
> [Trigger] Setting up event trigger...
✓ Workflow registered: post_purchase_flow
ID: wf_abc123
Version: 1.0
Steps: 6
Trigger: order.completed (conditional)
Status: active
# List registered workflows
$ hyperfold workflow list
WORKFLOWS (4 total)
NAME TRIGGER STEPS STATUS LAST RUN
post_purchase_flow order.completed 6 active 2 min ago
abandoned_cart cart.abandoned 3 active 15 min ago
inventory_alert inventory.low 2 active 1 hour ago
daily_report schedule: 0 9 * * * 4 active 9:00 AM
# View workflow details
$ hyperfold workflow get post_purchase_flow
WORKFLOW: post_purchase_flow
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ID: wf_abc123
Version: 1.0
Description: Automated post-purchase sequence
Status: active
Created: 2025-12-15T10:00:00Z
TRIGGER:
Event: order.completed
Conditions: order.total >= 50
STEPS:
1. send_confirmation → notifications.send_email
2. update_crm → salesforce.update_opportunity
3. check_loyalty → condition
4. upgrade_tier → customer.upgrade_tier (conditional)
5. send_survey → notifications.send_email (conditional)
6. schedule_followup → agent.schedule_outreach
EXECUTION STATS (7 days):
Triggered: 127 times
Completed: 124
Failed: 3
Avg Duration: 4.2s

Workflow Steps

Available step types for building workflows:

yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Available step types
STEP TYPES:
action Execute a registered action
condition Branch based on condition
parallel Execute multiple steps simultaneously
wait Pause for specified duration
approval Wait for human approval
agent Invoke an agent for a task
# Action step
- id: send_email
type: action
action: notifications.send_email
params:
to: "{{customer.email}}"
template: welcome
retry:
max_attempts: 3
backoff: exponential
# Condition step
- id: check_vip
type: condition
condition: "customer.lifetime_value > 1000"
on_true: vip_treatment
on_false: standard_treatment
# Parallel step
- id: parallel_notifications
type: parallel
steps:
- action: notifications.send_email
- action: notifications.send_sms
- action: slack.post_message
# Wait step
- id: delay_followup
type: wait
duration: "3d"
# Or absolute time
# until: "{{order.delivery_date}}"
# Approval step
- id: require_approval
type: approval
approvers:
- role: manager
- user: admin@company.com
timeout: "24h"
on_timeout: auto_approve # or reject, escalate
# Agent step
- id: personalized_recommendation
type: agent
agent: recommender-01
task: "Generate personalized recommendations"
context:
customer: "{{customer}}"
recent_purchases: "{{order.items}}"

Step Types

TypeDescription
actionExecute a registered action or API call
conditionBranch workflow based on expression
parallelExecute multiple steps simultaneously
waitPause for duration or until time
approvalRequire human approval to continue
agentInvoke an agent for a specific task

Triggers

Configure when workflows execute:

yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Event-based triggers
trigger:
event: order.completed
# Available events:
# - order.completed
# - order.cancelled
# - cart.abandoned
# - inventory.low
# - customer.created
# - agent.session_ended
# - payment.failed
# Conditional triggers
trigger:
event: order.completed
conditions:
- "order.total >= 100"
- "order.customer.tier == 'premium'"
- "order.items.length > 3"
# Schedule-based triggers
trigger:
schedule: "0 9 * * *" # Daily at 9 AM
# Cron format: minute hour day month weekday
# Schedule examples
trigger:
schedule: "0 9 * * 1" # Every Monday at 9 AM
schedule: "0 */4 * * *" # Every 4 hours
schedule: "0 0 1 * *" # First day of each month
# Webhook triggers
trigger:
webhook: true
# Accessible at: /api/workflows/{workflow_id}/trigger
auth:
type: api_key
header: X-Webhook-Key
# Manual triggers (CLI or API)
$ hyperfold workflow trigger post_purchase_flow \
--data='{"order": {"id": "order_123", "total": 150}}'
See Workflow API for programmatic workflow management.