{
  "protocol": "ai-funnel",
  "version": "1.1",
  "base_url": "https://horizon-personal-loans.onrender.com",
  "skill_url": "/skill/SKILL.md",
  "provider": {
    "name": "Horizon Personal Loans",
    "tagline": "Simple personal loans, transparent rates",
    "logo": "/images/logo.svg",
    "legal_entity": "Horizon Financial Services Inc.",
    "regulatory_ids": { "nmls": "9999999" },
    "support_email": "support@horizonloans.demo",
    "support_phone": "1-800-555-0199"
  },
  "identity_verification": {
    "provider": "Spinwheel",
    "method": "sms_otp",
    "endpoints": {
      "connect": "/api/sw/connect",
      "verify": "/api/sw/verify",
      "debt_profile": "/api/sw/debt-profile",
      "refresh_balance": "/api/sw/refresh-balance",
      "session": "/api/sw/session/{session_token}"
    },
    "capabilities": {
      "identity_autofill": true,
      "debt_profile": true,
      "real_time_balances": true,
      "credit_score": true
    },
    "consent_text": "By continuing you agree to the Spinwheel End User Agreement. Further, you are providing 'written instructions' to Spinwheel Solutions, Inc. authorizing it to obtain your credit profile from any consumer reporting agency.",
    "consent_url": "https://spinwheel.io/end-user-agreement/"
  },
  "funnels": [
    {
      "id": "personal-loan-consolidation",
      "name": "Personal Loan for Credit Card Consolidation",
      "description": "Consolidate your credit card debt with a personal loan. Just your phone number and a quick text code to get started — we'll pull your info and show you exactly what you could save.",
      "estimated_time_minutes": 3,
      "category": "personal_loan",
      "steps_url": "/api/funnel/personal-loan-consolidation/steps",
      "submit_url": "/api/funnel/personal-loan-consolidation/submit",
      "stage_url": "/api/funnel/personal-loan-consolidation/stage",
      "status_url": "/api/funnel/personal-loan-consolidation/status/{session_id}",
      "validate_field_url": "/api/funnel/personal-loan-consolidation/validate-field",
      "review_page_url": "/review.html?session={session_id}",
      "capabilities": {
        "conversational_completion": true,
        "identity_autofill": true,
        "debt_selection": true,
        "save_and_resume": false,
        "document_upload": false,
        "real_time_validation": true
      }
    }
  ],
  "consent": {
    "privacy_url": "/privacy",
    "terms_url": "/terms",
    "required_disclosures": [
      "This is a demonstration application. No real loans are being offered.",
      "This is not a commitment to lend. In a real scenario, all loans would be subject to credit approval, verification of information, and applicable regulations.",
      "Equal Housing Lender. NMLS #9999999 (demo).",
      "Credit data provided by Spinwheel via Equifax."
    ],
    "data_handling": "Identity verification is performed by Spinwheel. Credit data is pulled from Equifax via Spinwheel. All data submitted through this demo is stored in-memory only and deleted when the server restarts."
  },
  "agent_instructions": {
    "tone": "friendly, professional, encouraging",
    "pii_handling": "transit_only",
    "never_store": true,

    "CRITICAL_FLOW_ORDER": [
      "STEP 1: Show consent disclosures (from consent.required_disclosures) and Spinwheel consent (from identity_verification.consent_text). Get user agreement before collecting ANY data.",
      "STEP 2: Ask ONLY for phone number and date of birth. Nothing else yet.",
      "STEP 3: POST to identity_verification.endpoints.connect with phone and dob. Tell the user a code was sent to their phone.",
      "STEP 4: Ask the user for the 6-digit OTP code they received via SMS.",
      "STEP 5: POST to identity_verification.endpoints.verify with session_token and otp_code. This returns full_name, address, and ssn_last4.",
      "STEP 6: Show the user their verified identity and ask them to confirm it is correct.",
      "STEP 7: POST to identity_verification.endpoints.debt_profile with session_token. This returns ALL credit cards, loans, balances, monthly payments, and credit score.",
      "STEP 8: Present all credit cards with balances. Ask the user which cards they want to consolidate.",
      "STEP 9: Ask ONLY for: email, annual income, employment status, and preferred loan term. These are the ONLY fields the user should type manually.",
      "STEP 10: Present a complete review summary and get confirmation.",
      "STEP 11: Submit via funnel_submit tool or stage via funnel_stage tool."
    ],

    "DO_NOT": [
      "NEVER ask the user for their full name — Spinwheel provides it.",
      "NEVER ask the user for their address — Spinwheel provides it.",
      "NEVER ask the user for their SSN or last 4 of SSN — Spinwheel provides it.",
      "NEVER ask the user for their credit score — the debt profile provides it.",
      "NEVER ask the user for their monthly debt payments — the debt profile calculates it.",
      "NEVER ask the user to list their debts — the debt profile pulls them automatically.",
      "NEVER skip the Spinwheel verification and fall back to manual data entry unless (1) a Spinwheel API call fails AND (2) the user explicitly chooses to enter their information manually when presented with the three options.",
      "NEVER ask for more than phone number and date of birth before initiating Spinwheel verification."
    ],

    "ONLY_ASK_MANUALLY": [
      "phone (to initiate Spinwheel)",
      "date of birth (to initiate Spinwheel)",
      "OTP code (from their text message)",
      "email address (Spinwheel does not provide this)",
      "annual income (self-reported)",
      "employment status (self-reported)",
      "preferred loan term (user choice)"
    ],

    "on_spinwheel_failure": {
      "behavior": "If any Spinwheel call fails (connect, verify, or debt_profile), tell the user what happened in plain language. Then present exactly three options and wait for the user to choose. Do NOT silently fall back to manual entry. Do NOT assume the user wants manual entry.",
      "options_to_present": [
        "Try again (re-attempt the Spinwheel verification)",
        "Go to the website and complete the application there (link to fallback_url)",
        "Enter your information manually here in the conversation instead"
      ],
      "manual_fallback_rules": [
        "ONLY proceed with manual data entry if the user explicitly chooses option 3.",
        "If the user chooses manual entry, switch to asking for: full name, email, phone, date of birth, address (street, city, state, zip), annual income, employment status, monthly debt payments (self-estimated), credit score range (self-estimated), and preferred loan term.",
        "Acknowledge that the manual path requires more information and that debt/credit data will be self-reported estimates rather than verified numbers.",
        "The pre-qualification result from manual entry will note that it is based on self-reported data and subject to verification."
      ]
    },
    "fallback_url": "/apply",
    "sensitive_field_behavior": "SSN is returned as last-4 only from Spinwheel. Never ask the user for their full SSN. Never repeat the SSN last 4 back — just say 'I have your SSN on file from verification.'"
  }
}
