These recipes provide ready-to-use approval workflows for financial operations, designed with compliance and security in mind.
- Refund Processing
- Wire Transfers
- Payment Processing
- Credit Limit Changes
Refund Processing
Enable safe refund processing with automatic approvals for small amounts and required oversight for larger refunds.const processRefund = needsHumanApproval({
type: 'sync',
title: 'Refund Request',
ask: (args) => `Approve refund of $${args.amount} for order ${args.orderId}?`,
autoApprove: async (args) => args.amount < 100
})
// Usage
await processRefund({
orderId: '1234',
amount: 150,
reason: 'Defective product'
})
const processRefund = needsHumanApproval({
type: 'sync',
title: 'Refund Request',
ask: (args) => {
const urgent = args.customerTier === 'VIP' ? '🔔 URGENT: ' : '';
return `${urgent}Approve refund of $${args.amount} for order ${args.orderId}?`;
},
// Auto-approve based on multiple conditions
autoApprove: async (args) => {
return args.amount < 100 ||
args.customerTier === 'VIP' ||
args.reason === 'Damaged in shipping';
},
approvalArguments: {
amount: {
type: 'number',
value: args.amount,
label: 'Refund Amount',
editable: true
},
reason: {
type: 'string',
value: args.reason,
label: 'Refund Reason',
editable: true
},
customerTier: {
type: 'string',
value: args.customerTier,
label: 'Customer Tier',
editable: false
},
notes: {
type: 'longString',
value: '',
label: 'Approval Notes',
editable: true
}
}
})
When to use this
When to use this
- Customer refund requests
- Order cancellations
- Service credits
- Complaint resolutions
Best practices
Best practices
- Set appropriate auto-approval thresholds
- Include order context
- Maintain audit trail
- Consider customer history
Wire Transfers
Secure wire transfer processing with multi-approver requirements and business hour restrictions.const processWireTransfer = needsHumanApproval({
type: 'sync',
title: 'Wire Transfer',
ask: (args) => `Approve wire transfer of $${args.amount} to ${args.recipient}?`,
// Require approval outside business hours
shouldSeekApprovals: async (args) => {
const hour = new Date().getHours();
return hour < 9 || hour > 17;
}
})
const processWireTransfer = needsHumanApproval({
type: 'sync',
title: 'Wire Transfer',
ask: (args) => `Approve wire transfer of $${args.amount} to ${args.recipient}?`,
// Multiple approvers for large amounts
approvers: (args) => {
if (args.amount > 50000) {
return [
{ name: 'Financial Controller', email: 'controller@company.com' },
{ name: 'Treasury Manager', email: 'treasury@company.com' }
];
}
return [{ name: 'Finance Manager', email: 'finance@company.com' }];
},
approvalArguments: {
amount: {
type: 'number',
value: args.amount,
label: 'Transfer Amount',
editable: true
},
recipient: {
type: 'string',
value: args.recipient,
label: 'Recipient',
editable: true
},
recipientBank: {
type: 'string',
value: args.bankDetails,
label: 'Bank Details',
editable: false
},
purpose: {
type: 'string',
value: args.purpose,
label: 'Transfer Purpose',
editable: true
}
}
})
For wire transfers over $50,000, approvals from both Financial Controller and Treasury Manager are required.
Payment Processing
Handle high-value payment approvals with fraud detection integration.const processPayment = needsHumanApproval({
type: 'sync',
title: 'Payment Processing',
ask: (args) => {
const fraudAlert = args.fraudScore > 70 ? '⚠️ HIGH RISK: ' : '';
return `${fraudAlert}Approve payment of $${args.amount} for transaction ${args.transactionId}`;
},
approvalArguments: {
amount: {
type: 'number',
value: args.amount,
label: 'Payment Amount',
editable: false
},
fraudScore: {
type: 'number',
value: args.fraudScore,
label: 'Fraud Risk Score',
editable: false
},
paymentMethod: {
type: 'string',
value: args.paymentMethod,
label: 'Payment Method',
editable: false
},
customerHistory: {
type: 'longString',
value: args.transactionHistory,
label: 'Customer Transaction History',
editable: false
}
},
// Require approval for high-risk transactions
shouldSeekApprovals: async (args) => {
return args.fraudScore > 50 || args.amount > 10000;
}
})
Risk Factors
Risk Factors
- Fraud score above threshold
- Unusual transaction amount
- New payment method
- Geographic location
Credit Limit Changes
Manage credit limit modifications with risk assessment.const modifyCreditLimit = needsHumanApproval({
type: 'async',
title: 'Credit Limit Modification',
ask: (args) => `Review credit limit change for account ${args.accountId}`,
approvalArguments: {
currentLimit: {
type: 'number',
value: args.currentLimit,
label: 'Current Limit',
editable: false
},
proposedLimit: {
type: 'number',
value: args.proposedLimit,
label: 'Proposed Limit',
editable: true
},
creditScore: {
type: 'number',
value: args.creditScore,
label: 'Credit Score',
editable: false
},
paymentHistory: {
type: 'longString',
value: args.paymentHistory,
label: 'Payment History',
editable: false
}
},
// Auto-approve small increases for good customers
autoApprove: async (args) => {
const increasePercent = (args.proposedLimit - args.currentLimit) / args.currentLimit * 100;
return increasePercent <= 10 && args.creditScore > 700;
}
})
Next Steps
Legal Recipes
Explore approval workflows for legal operations