| name | workflow-designer |
| description | Workflow automation expertise covering n8n, Zapier, and Temporal patterns, workflow state machines, compensation and saga patterns, human-in-the-loop workflows, parallel execution, conditional branching, retry policies, workflow versioning, and monitoring strategies.
Use when the user asks about workflow designer, workflow designer best practices, or needs guidance on workflow designer implementation.
Do NOT use when the user needs a different specialized skill or is asking about an unrelated technology domain.
|
| license | Apache-2.0 |
| metadata | {"author":"foundry-skills","version":"1.0.0","tags":"automation shell-scripting guide","category":"software-engineering","subcategory":"developer-tools","depends":"","disclaimer":"none","difficulty":"intermediate"} |
Workflow Designer
Core Philosophy
A workflow is a sequence of steps that transforms an input into a desired outcome, potentially involving multiple systems, human decisions, and error recovery. Good workflow design separates the "what" (business logic) from the "how" (execution mechanics). Each step should be independently testable, retryable, and observable.
Workflow Design Patterns
Sequential Workflow
[Receive Order] -> [Validate] -> [Process Payment] -> [Reserve Inventory] -> [Send Confirmation]
Parallel Workflow
[Receive Order] -> [Validate]
|
+------+------+
| |
[Check Fraud] [Verify Address]
| |
+------+------+
|
[Process Payment]
Saga Pattern (Compensating Transactions)
When a multi-step workflow fails partway through, compensation undoes completed steps.
Step 1: Reserve Inventory -> Compensate: Release Inventory
Step 2: Charge Payment -> Compensate: Refund Payment
Step 3: Create Shipment -> Compensate: Cancel Shipment
Step 4: Send Notification -> (no compensation needed)
If Step 3 fails:
Compensate Step 2 (refund)
Compensate Step 1 (release inventory)
Temporal (Durable Workflow Engine)
Workflow Definition
import { proxyActivities, sleep, condition, defineSignal, setHandler } from '@temporalio/workflow';
import type * as activities from '../activities';
const {
validateOrder,
processPayment,
reserveInventory,
createShipment,
sendConfirmation,
refundPayment,
releaseInventory,
} = proxyActivities<typeof activities>({
startToCloseTimeout: '30s',
retry: {
initialInterval: '1s',
backoffCoefficient: 2,
maximumAttempts: 3,
maximumInterval: '30s',
nonRetryableErrorTypes: ['ValidationError', 'InsufficientFundsError'],
},
});
const approvalSignal = defineSignal<[boolean]>('approval');
export async function orderWorkflow(order: Order): Promise<OrderResult> {
const validationResult = await validateOrder(order);
if (!validationResult.valid) {
return { status: 'rejected', : validationResult. };
}
(order. > ) {
: | ;
(approvalSignal, { approved = isApproved; });
gotApproval = ( approved !== , );
(!gotApproval || !approved) {
{ : , : };
}
}
paymentResult = (order);
{
reservation = (order);
{
shipment = (order, reservation);
(order, shipment);
{ : , : shipment. };
} (shipmentError) {
(reservation.);
shipmentError;
}
} (error) {
(paymentResult.);
{ : , : (error) };
}
}
Activity Definitions
import { ApplicationFailure } from '@temporalio/activity';
export async function validateOrder(order: Order): Promise<ValidationResult> {
const errors: string[] = [];
if (!order.items?.length) errors.push('Order must have at least one item');
if (order.total <= 0) errors.push('Order total must be positive');
if (!order.shippingAddress) errors.push('Shipping address is required');
return { valid: errors.length === 0, errors };
}
export async function processPayment(order: Order): Promise<PaymentResult> {
try {
const result = await paymentGateway.charge({
amount: order.total,
currency: order.,
: order.,
});
{ : result., : };
} (error) {
(error. === ) {
.(, );
}
error;
}
}
(): <> {
inventoryService.({
: ,
: order.,
: ,
});
}
Starting and Managing Workflows
import { Client, Connection } from '@temporalio/client';
const connection = await Connection.connect({ address: 'temporal-server:7233' });
const client = new Client({ connection });
const handle = await client.workflow.start(orderWorkflow, {
taskQueue: 'order-processing',
workflowId: `order-${orderId}`,
args: [orderData],
workflowExecutionTimeout: '24h',
});
const status = await handle.query('getStatus');
await handle.signal(approvalSignal, true);
const result = await handle.result();
await handle.cancel();
n8n (Visual Workflow Automation)
Workflow Concepts
{
"name": "Customer Onboarding",
"nodes": [
{
"name": "Webhook Trigger",
"type": "n8n-nodes-base.webhook",
"parameters": {
"path": "new-customer",
"method": "POST"
}
},
{
"name": "Validate Data",
"type": "n8n-nodes-base.function",
"parameters": {
"functionCode": "const { name, email } = $input.all()[0].json;\nif (!name || !email) throw new Error('Missing fields');\nreturn $input.all();"
}
},
{
"name":
n8n Error Handling
{
"name": "Error Handler",
"type": "n8n-nodes-base.errorTrigger",
"parameters": {},
"continueOnFail": false
},
{
"name": "Retry Node",
"type": "n8n-nodes-base.function",
"parameters": {
"functionCode": "// Retry logic with backoff\nconst maxRetries = 3;\nconst attempt = $input.all()[0].json.attempt || 0;\nif (attempt < maxRetries) {\n return [{json: {...$input.all()[0].json, attempt: attempt + 1}}];\n}\nthrow new Error('Max retries exceeded');"
},
"retryOnFail": true,
"maxTries": 3,
"waitBetweenTries": 5000
}
Workflow State Machines
State Machine Design
type OrderState =
| 'created'
| 'validated'
| 'payment_pending'
| 'payment_confirmed'
| 'fulfilling'
| 'shipped'
| 'delivered'
| 'cancelled'
| 'refunded';
type OrderEvent =
| { type: 'VALIDATE'; data: ValidationData }
| { type: 'PAYMENT_RECEIVED'; transactionId: string }
| { type: 'PAYMENT_FAILED'; reason: string }
| { type: 'START_FULFILLMENT' }
| { type: 'SHIP'; trackingNumber: string }
| { type: 'DELIVER' }
| { type: 'CANCEL'; reason: string }
| { type: 'REFUND' };
const orderStateMachine = {
created: {
VALIDATE: (ctx, event) => ({
state: event.data.valid ? 'validated' : 'cancelled',
actions: event.. ? [] : [{ : }],
}),
: ({ : }),
},
: {
: ({
: ,
: [{ : , : event. }],
}),
: ({
: ,
: [{ : }],
}),
: ({ : }),
},
: {
: ({
: ,
: [{ : }],
}),
: ({
: ,
: [{ : }],
}),
},
: {
: ({
: ,
: [{ : , : event. }],
}),
: ({
: ,
: [{ : }, { : }],
}),
},
: {
: ({
: ,
: [{ : }],
}),
},
};
() {
handler = orderStateMachine[currentState]?.[event.];
(!handler) {
();
}
(context, event);
}
Human-in-the-Loop
export async function approvalWorkflow(request: ApprovalRequest): Promise<string> {
await sendApprovalRequest(request);
let decision: 'approved' | 'rejected' | undefined;
const approveSignal = defineSignal<['approved' | 'rejected', string]>('decide');
let comment = '';
setHandler(approveSignal, (d, c) => {
decision = d;
comment = c;
});
const timer = sleep('4h').then(() => {
if (!decision) {
sendEscalation(request, request.managerEmail);
}
});
const responded = await condition(() => decision !== undefined, '24h');
if (!responded) {
return ;
}
(request., decision, comment);
;
}
Retry Policies
const activities = proxyActivities({
startToCloseTimeout: '30s',
retry: {
initialInterval: '1s',
backoffCoefficient: 2,
maximumInterval: '1m',
maximumAttempts: 5,
nonRetryableErrorTypes: [
'ValidationError',
'AuthenticationError',
'NotFoundError',
],
},
});
Workflow Versioning
import { patched } from '@temporalio/workflow';
export async function orderWorkflow(order: Order): Promise<OrderResult> {
await validateOrder(order);
await processPayment(order);
if (patched('add-fraud-check')) {
await checkFraud(order);
}
await reserveInventory(order);
await createShipment(order);
if (patched('use-new-notification-system')) {
await sendNotificationV2(order);
} else {
await sendConfirmation(order);
}
return { status: 'completed' };
}
Monitoring Workflows
Key Metrics to Track:
1. Workflow completion rate (success vs failure)
2. Workflow duration (p50, p95, p99)
3. Activity failure rate by type
4. Retry rate (indicates flaky dependencies)
5. Human approval wait time
6. Queue depth (backlog of pending workflows)
Alerting Rules:
- Workflow failure rate > 5% -> Page on-call
- Workflow duration p95 > 2x normal -> Warning
- Queue depth growing for > 30 min -> Warning
- Human approval waiting > 4 hours -> Escalation
Best Practices
- Make activities idempotent: Use idempotency keys so retries are safe
- Design for failure: Every step should have a compensation strategy
- Keep workflows deterministic: No random values, no current time in workflow code
- Use signals for external events: Human approvals, webhooks, callbacks
- Version workflows carefully: Running instances must continue to work
- Set appropriate timeouts: Both per-activity and per-workflow
- Monitor queue depth: Growing queues indicate capacity problems
- Test with chaos: Randomly fail activities to verify recovery
When to Use
Use this skill when:
- Designing or implementing workflow designer solutions
- Reviewing or improving existing workflow designer approaches
- Making architectural or implementation decisions about workflow designer
- Learning workflow designer patterns and best practices
- Troubleshooting workflow designer-related issues
Do NOT use this skill when:
- The question is about a fundamentally different technology domain
- A more specific sibling skill covers the exact topic needed
- The user needs a complete hands-on tutorial rather than expert guidance
Output Format
# Workflow Designer Analysis
## Context Assessment
[Situation summary and constraints]
## Recommended Approach
[Primary recommendation with rationale]
## Implementation Steps
1. [Step with specific details]
2. [Step with specific details]
3. [Step with specific details]
## Trade-offs and Considerations
- [Key trade-off 1]
- [Key trade-off 2]
## Next Steps
- [Immediate action item]
- [Follow-up action item]
Example
Input: "Help me implement workflow designer for a medium-scale production application"
Output: A structured analysis covering current state assessment, recommended workflow designer approach with specific patterns, implementation roadmap with milestones, and risk mitigation strategies tailored to the application scale and constraints.
Edge Cases
- Legacy system integration: When workflow designer must coexist with legacy approaches, provide a gradual migration path rather than a complete rewrite
- Scale mismatch: When the solution complexity exceeds the project scale, recommend a simpler approach and note when to revisit
- Team skill gaps: When the team lacks experience with the recommended approach, include learning resources and simpler alternatives
- Conflicting requirements: When constraints conflict (e.g., performance vs. maintainability), explicitly state the trade-off and recommend based on stated priorities