Skip to main content
These recipes provide ready-to-use approval workflows for common business scenarios. Each recipe is designed with industry best practices and compliance requirements in mind.

Quick Implementation

Get started quickly by choosing a recipe and adapting it to your needs:
import { needsHumanApproval } from '@your-org/approvals'

// Example: Basic refund approval
const processRefund = needsHumanApproval({
  type: 'sync',
  title: 'Refund Request',
  ask: (args) => `Approve refund of $${args.amount}?`,
  autoApprove: async (args) => args.amount < 100
})

Common Patterns

Choose between blocking (sync) and non-blocking (async) approval flows based on your operational needs.
// Synchronous - waits for approval
const syncApproval = needsHumanApproval({
  type: 'sync',
  syncTimeout: 30000 // 30 second timeout
})

// Asynchronous - continues execution
const asyncApproval = needsHumanApproval({
  type: 'async'
})
Implement conditional auto-approvals based on business rules.
needsHumanApproval({
  autoApprove: async (args) => {
    return args.amount < 100 || 
           args.customerTier === 'VIP';
  }
})
Route approvals to different stakeholders based on criteria.
needsHumanApproval({
  approvers: (args) => {
    if (args.amount > 10000) {
      return [
        { name: 'Manager', email: '[email protected]' },
        { name: 'Finance', email: '[email protected]' }
      ];
    }
    return [{ name: 'Team Lead', email: '[email protected]' }];
  }
})

Industry Solutions

E-commerce

  • Order processing
  • Refund management
  • Customer support

Banking

  • Transaction approval
  • Account changes
  • Wire transfers

Insurance

  • Claims processing
  • Policy changes
  • Risk assessment

Custom Integration

All recipes can be customized to match your specific requirements. Use them as starting points and modify as needed.
// Example: Combining patterns
const customApproval = needsHumanApproval({
  type: 'sync',
  title: 'Custom Approval',
  ask: (args) => `Approve ${args.action}?`,
  // Custom auto-approval logic
  autoApprove: async (args) => {
    return await yourCustomLogic(args);
  },
  // Custom approval routing
  approvers: (args) => {
    return await getApproversFromSystem(args);
  },
  // Custom callbacks
  onApprovedCallbackUrl: 'https://your-system/approved',
  onRejectedCallbackUrl: 'https://your-system/rejected'
})

Next Steps