Primitives.org.ai

approve

Get yes/no approval from a human

Pause execution and wait for human approval. Returns true if approved, false if rejected.

Import

import { approve } from 'ai-functions'

Syntax

approve`request description`
approve`request`(options)

Examples

// Simple approval
const ok = await approve`Deploy to production?`

if (ok) {
  await deploy()
}

// With details
const approved = await approve`
  Expense Report

  Amount: $${expense.amount}
  Category: ${expense.category}
  Description: ${expense.description}
  Requester: ${expense.submittedBy}
`

// With options
const result = await approve`${request}`({
  assignTo: { role: 'manager' },
  timeout: '48h',
  escalateTo: 'director',
})

Options

OptionTypeDescription
assignToAssignmentWho should approve
channelstringNotification channel
timeoutstringHow long to wait
escalateTostringWho to escalate to on timeout
requireReasonbooleanRequire reason for rejection

Returns

Returns boolean - true if approved, false if rejected.

When to Use

  • Financial approvals
  • Deployment gates
  • Access requests
  • Any binary yes/no decision
Was this page helpful?

On this page