Scale your operations by automatically approving low-risk actions while maintaining oversight for high-risk decisions.
// Simple auto-approval configuration
hitl({
id: "expense-approval",
autoApproval: {
enabled: true,
// Simple threshold-based rules
rules: [
{
name: "small-expenses",
condition: (ctx) => ctx.data.amount < 100,
action: "approve"
},
{
name: "trusted-vendors",
condition: (ctx) => ctx.data.vendor.trusted === true,
action: "approve"
},
{
name: "recurring-expenses",
condition: (ctx) => ctx.data.isRecurring && ctx.data.previouslyApproved,
action: "approve"
}
],
// Logging
logAutoApprovals: true,
auditTrail: true
}
})// Advanced auto-approval with multiple conditions
hitl({
id: "content-approval",
autoApproval: {
enabled: true,
rules: [
{
name: "low-risk-content",
// Multiple conditions (AND)
conditions: {
all: [
{ field: "riskScore", operator: "lt", value: 30 },
{ field: "contentType", operator: "in", value: ["blog", "social"] },
{ field: "hasExternalLinks", operator: "eq", value: false }
]
},
action: "approve"
},
{
name: "trusted-author-medium-risk",
// Combination of AND/OR
conditions: {
all: [
{ field: "riskScore", operator: "lt", value: 60 },
{
any: [
{ field: "author.trustLevel", operator: "gte", value: 8 },
{ field: "author.approvalRate", operator: "gte", value: 0.95 }
]
}
]
},
action: "approve"
},
{
name: "high-confidence-ai",
conditions: {
all: [
{ field: "aiConfidenceScore", operator: "gte", value: 0.95 },
{ field: "similarContentApproved", operator: "gte", value: 5 },
{ field: "flaggedByModeration", operator: "eq", value: false }
]
},
action: "approve"
}
]
}
})// Auto-approve after timeout
hitl({
id: "routine-update",
autoApproval: {
// Auto-approve if no response after delay
timeout: {
enabled: true,
after: "4h",
// Only auto-approve if conditions met
conditions: {
all: [
{ field: "riskScore", operator: "lt", value: 50 },
{ field: "changes.length", operator: "lt", value: 10 }
]
},
// Notify when auto-approved
notify: ["requester", "approvers"],
reason: "Auto-approved: No response within 4 hours"
}
}
})
// Business hours aware timeout
hitl({
id: "business-approval",
autoApproval: {
timeout: {
enabled: true,
after: "8h",
businessHoursOnly: true, // Only count business hours
timezone: "America/New_York",
businessHours: {
start: "09:00",
end: "17:00",
days: ["Mon", "Tue", "Wed", "Thu", "Fri"]
}
}
}
})Let the system learn from past approval decisions to automatically approve similar requests.
// ML-powered auto-approval
hitl({
id: "support-response-approval",
autoApproval: {
learning: {
enabled: true,
// Train on historical approvals
trainingData: {
source: "approval_history",
minSamples: 100, // Need at least 100 examples
maxAge: "90d" // Only use recent decisions
},
// Features to learn from
features: [
"response.sentiment",
"response.length",
"response.hasLinks",
"customer.tier",
"issue.category",
"agent.trustScore"
],
// Confidence threshold for auto-approval
confidenceThreshold: 0.92,
// Gradual rollout
rollout: {
initial: 0.1, // Start with 10% auto-approval
increment: 0.1, // Increase by 10%
maxRate: 0.8, // Never exceed 80%
evaluationPeriod: "7d"
},
// Safety checks
safety: {
// Always require human review for these
neverAutoApprove: [
{ field: "customer.tier", operator: "eq", value: "enterprise" },
{ field: "issue.category", operator: "in", value: ["legal", "security"] }
],
// Pause learning if error rate exceeds threshold
pauseOnErrorRate: 0.05,
alertOnAnomaly: true
}
}
}
})// Guardrails for auto-approval
hitl({
id: "payment-approval",
autoApproval: {
enabled: true,
rules: [...],
guardrails: {
// Daily limits
limits: {
perDay: {
count: 100, // Max 100 auto-approvals per day
amount: 50000 // Max $50k auto-approved per day
},
perHour: {
count: 20
}
},
// Velocity checks
velocity: {
// Alert if auto-approval rate spikes
alertOnSpike: {
threshold: 2.0, // 2x normal rate
window: "1h"
},
// Pause if too many in short time
pauseOnBurst: {
count: 50,
window: "5m"
}
},
// Random sampling for audit
sampling: {
enabled: true,
rate: 0.05, // Sample 5% of auto-approvals for human review
alertOnRejection: true // Alert if sampled item would have been rejected
},
// Never auto-approve these
exclusions: [
{ field: "amount", operator: "gte", value: 10000 },
{ field: "isNewVendor", operator: "eq", value: true },
{ field: "flagged", operator: "eq", value: true }
]
}
}
})// Monitoring and analytics
const autoApprovalStats = await hitl.getAutoApprovalStats({
workflowId: "expense-approval",
period: "30d"
})
// Returns:
{
total: 2500,
autoApproved: 1800,
humanApproved: 600,
rejected: 100,
autoApprovalRate: 0.72,
byRule: {
"small-expenses": { count: 1200, accuracy: 0.99 },
"trusted-vendors": { count: 400, accuracy: 0.97 },
"recurring-expenses": { count: 200, accuracy: 0.98 }
},
falsePositives: 3, // Auto-approved but should have been rejected
falseNegatives: 15, // Sent to human but could have been auto-approved
timeSaved: "156 hours", // Estimated time saved
avgResponseTime: {
autoApproved: "0.2s",
humanApproved: "4.2h"
}
}