Skip to Content
GuidesWorkflows

Workflows

Workflows are configurable processing pipelines. Define a sequence of steps such as capture, OCR, extraction, validation, checks, enrichment, risk, review, and output, then run them against uploaded documents or accumulated case data.

Creating a Workflow

import { KoralaClient } from '@korala/api-client'; const korala = new KoralaClient({ apiKeyId: 'your-api-key-id', apiSecret: 'your-api-secret', }); const workflow = await korala.workflows.create({ name: 'ID Document Extraction', slug: 'id-document', steps: [ { type: 'capture', config: { acceptedTypes: ['application/pdf', 'image/png', 'image/jpeg'], maxSizeMb: 10 } }, { type: 'ocr', config: { provider: 'auto' } }, { type: 'extract', config: { prompt: 'inline', schema: 'inline', inlineSystemPrompt: '...', inlineOutputSchema: { ... } } }, { type: 'validate', config: { schema: 'inline', aiValidation: { prompt: '...', fields: ['document_number'], failOnInvalid: false } } }, { type: 'output', config: { format: 'json', includeMetadata: true } }, ], });

Step Types

StepDescription
captureAccept document upload (PDF, images)
ocrExtract text from document via OCR
extractAI-powered structured data extraction
validateAssertions over already-known data, extracted fields, or prior outputs
enrichTransforms or data augmentation that do not create first-class findings
checkProvider-backed or specialized verification that emits findings, scores, and review signals
riskAggregate scoring across evidence, history, and prior steps
reviewHuman-in-the-loop pause point
webhookFire-and-forget HTTP POST
outputFormat and return results

Use check when the step calls an external or specialized verification source and you want to persist first-class findings such as PEP, sanctions, adverse media, or business registry results. Keep validate for deterministic assertions over data you already have.

Running a Workflow

// 1. Start a run and get upload URL const run = await korala.workflows.startRun('id-document', { inputData: { customField: 'value' }, }); // 2. Upload the document await fetch(run.uploadUrl, { method: 'PUT', body: documentFile, headers: { 'Content-Type': documentFile.type }, }); // 3. Confirm upload to start processing await korala.workflows.confirmUpload(run.runId); // 4. Poll for results const result = await korala.workflows.getRun(run.runId); // result.status: 'completed' | 'running' | 'failed' // result.outputData: extracted data

Workflow Webhooks

Subscribe to these events for real-time notifications:

EventDescription
workflow_run_completedWorkflow run finished successfully
workflow_run_failedWorkflow run failed

Human Review

If a workflow includes a review step, it pauses for human review:

// Approve and continue await korala.workflows.submitReview(runId, { action: 'approve', editedData: { correctedField: 'new value' }, }); // Or reject await korala.workflows.submitReview(runId, { action: 'reject', reason: 'Document is unreadable', });
Last updated on