KYC Customer Onboarding

Agent-as-orchestrator pattern. Unlike the matching-first templates, this one starts with an AI agent that coordinates multiple verification workflows, synthesizes results across them, and escalates when signals conflict.

What Gets Automated

Identity verification, sanctions screening, adverse media scanning, and risk scoring — run as separate sub-workflows coordinated by an orchestrator agent. The agent synthesizes pass/fail/flag signals across all checks, identifies conflicts, and makes an onboarding recommendation.

What Humans Still Own

Final approval on flagged or conflicted cases. Enhanced due diligence investigations. Policy exception decisions for high-profile applicants.

Pipeline

flowchart TD A[Input: Applicant Data] --> B[Orchestrator Agent] B --> C[run_workflow: Identity Verification] B --> D[run_workflow: Sanctions Screening] B --> E[run_workflow: Adverse Media Scan] C -->|pass / fail / flag| F[Agent Synthesizes Results] D -->|pass / fail / flag| F E -->|pass / fail / flag| F F -->|All pass| G[Auto-Approve] F -->|Conflict detected| H{Agent Resolves} F -->|Hard fail| I[Auto-Deny] H -->|Resolved| J[Approve with Note] H -->|Unresolvable| K[pause_for_human: Compliance Review] K -->|Approved| L[Provision Account] K -->|Denied| M[Reject with Reason] K -->|EDD required| N[run_workflow: Enhanced Due Diligence] N --> K G --> O[Custom Table: Onboarding Log] J --> O L --> O M --> O I --> O style B fill:#4ade80,color:#09090b,stroke:none style K fill:#60a5fa,color:#09090b,stroke:none style C fill:#e8a84c,color:#09090b,stroke:none style D fill:#e8a84c,color:#09090b,stroke:none style E fill:#e8a84c,color:#09090b,stroke:none

This template demonstrates Pattern C: Agent as Orchestrator. The agent coordinates multiple sub-workflows using __run_workflow__ and synthesizes their results to make a decision.

## Workflow Definition
json
{
  "name": "kyc_customer_onboarding",
  "definition": {
    "actions": [
      {
        "type": "loop",
        "properties": {
          "mode": "react",
          "objective": "Onboard applicant {{input.applicant_name}} ({{input.applicant_id}}). Execute verification sequence: 1) Run identity verification workflow, 2) Run sanctions screening workflow, 3) Run adverse media scan workflow, 4) Synthesize results — if all pass, approve with risk score. If any conflict (e.g., identity passes but sanctions flags a partial name match), investigate the discrepancy. If confidence below 0.8, pause for human compliance review with full context and reasoning. 5) Provide final recommendation with risk level (low/medium/high).",
          "tools": [
            { "type": "workflow", "id": "wf_identity_verification" },
            { "type": "workflow", "id": "wf_sanctions_screening" },
            { "type": "workflow", "id": "wf_adverse_media_scan" }
          ],
          "max_iterations": 15,
          "timeout_ms": 300000,
          "on_stuck": {
            "iterations": 4,
            "action": "escalate"
          },
          "result_key": "onboarding_decision"
        }
      },
      {
        "type": "loop",
        "filter": {
          "condition": {
            "equal": ["@onboarding_decision.answer.decision", "approved"]
          }
        },
        "properties": {
          "mode": "react",
          "objective": "Provision account for approved applicant {{input.applicant_id}}. Create account, assign tier based on risk score, and trigger welcome sequence.",
          "tools": [
            { "type": "action", "name": "create_customer_account" },
            { "type": "action", "name": "assign_account_tier" },
            { "type": "workflow", "id": "wf_welcome_sequence" }
          ],
          "max_iterations": 5,
          "result_key": "provisioning_result"
        }
      },
      {
        "type": "gmail_send",
        "filter": {
          "condition": {
            "equal": ["@onboarding_decision.answer.decision", "approved"]
          }
        },
        "properties": {
          "__oauth_account__": "[email protected]",
          "to": "@input.applicant_email",
          "subject": "Welcome — your account is ready",
          "body": "Your account has been verified and provisioned."
        },
        "onFalse": {
          "type": "gmail_send",
          "properties": {
            "__oauth_account__": "[email protected]",
            "to": "@input.applicant_email",
            "subject": "Application update",
            "body": "We were unable to complete your application. A team member will follow up within 2 business days."
          }
        }
      },
      {
        "type": "custom-table",
        "properties": {
          "table": "onboarding_log",
          "operation": "write",
          "keys": ["applicant_id"],
          "values": ["@input.applicant_id"],
          "fields": {
            "decision": "@onboarding_decision.answer.decision",
            "risk_score": "@onboarding_decision.answer.risk_level",
            "confidence": "@onboarding_decision.confidence",
            "run_id": "@__run_id",
            "completed_at": "@now"
          }
        }
      }
    ]
  }
}

Required Workflows

These workflows are triggered by the orchestrator agent via __run_workflow__:

Workflow Purpose
identity_verification Document verification, liveness check, PII validation
sanctions_screening OFAC, EU, UN sanctions list matching
adverse_media_scan News and media screening for negative coverage
enhanced_due_diligence Deep investigation for flagged applicants

Required Registered Actions

Action Kind Purpose
create_customer_account http Provision account in your system
assign_account_tier http Set account tier based on risk assessment

Customization Notes

Confidence threshold. The 0.8 confidence threshold in the objective controls when the agent escalates to a human. Lower to 0.7 for a more cautious approach; raise to 0.9 if you trust the verification workflows and want fewer escalations.

Timeout. 300 seconds (5 minutes) covers the round-trip time for multiple sub-workflow executions. Extend if your verification providers have slow response times.

Iterations. 15 iterations is higher than other templates because the orchestrator needs to run multiple workflows, store intermediate results, synthesize, and potentially escalate. Don't reduce below 10.

Sub-workflows. Each verification workflow (identity_verification, sanctions_screening, etc.) must be created separately in Hyphen before running this template. They can be simple HTTP-action workflows that call your verification providers.