Create a conditional handler that applies different logic based on context
Array of condition/handler pairs
Handler to use if no conditions match
const handler = createConditionalHandler([ { condition: (ctx) => ctx.inputRequest.field === 'budget', handler: (ctx) => ctx.attempt === 1 ? 100000 : 50000 }, { condition: (ctx) => ctx.agent.name.includes('Premium'), handler: autoApproveHandler }], deferAllHandler); Copy
const handler = createConditionalHandler([ { condition: (ctx) => ctx.inputRequest.field === 'budget', handler: (ctx) => ctx.attempt === 1 ? 100000 : 50000 }, { condition: (ctx) => ctx.agent.name.includes('Premium'), handler: autoApproveHandler }], deferAllHandler);
Create a conditional handler that applies different logic based on context