{
  "name": "Financial Counselling: Verified Research",
  "version": "1.0.0",
  "description": "Perplexity-powered research pipeline with citation validation - finds current hardship programs, support services, and legal protections with verified sources",
  "category": "solutions",
  "tags": ["financial-counselling", "research", "perplexity", "citations", "zero-hallucination"],
  "input_schema": {
    "type": "object",
    "properties": {
      "state": {
        "type": "string",
        "description": "Australian state (VIC, NSW, QLD, SA, WA, TAS, NT, ACT)",
        "default": "VIC"
      },
      "suburb": {
        "type": "string",
        "description": "Client's suburb for local service search"
      },
      "creditors": {
        "type": "array",
        "items": { "type": "string" },
        "description": "List of banks/lenders to research"
      },
      "specific_needs": {
        "type": "array",
        "items": { "type": "string" },
        "description": "Specific areas to research (e.g., 'rental assistance', 'utility hardship')"
      }
    },
    "required": ["state"]
  },
  "output_schema": {
    "type": "object",
    "properties": {
      "hardship_programs": { "type": "object" },
      "local_services": { "type": "object" },
      "legal_protections": { "type": "object" },
      "creditor_policies": { "type": "object" },
      "all_citations": { "type": "array" },
      "verification_summary": { "type": "object" }
    }
  },
  "stages": [
    {
      "id": "research-hardship",
      "name": "Research Hardship Programs",
      "component_type": "generator",
      "config": {
        "provider": "perplexity",
        "model": "sonar-pro",
        "temperature": 0.1,
        "system_prompt": "You are a research assistant finding hardship programs. CRITICAL: Every program MUST include a citation URL. If no verifiable source, do not include.\n\nReturn JSON:\n{\n  \"programs\": [\n    {\n      \"name\": \"Program Name\",\n      \"provider\": \"Organization\",\n      \"type\": \"utility\" | \"rental\" | \"emergency\" | \"financial\",\n      \"eligibility\": \"Brief criteria\",\n      \"benefits\": \"What it provides\",\n      \"how_to_apply\": \"Process\",\n      \"contact\": \"Phone/website\",\n      \"citation_url\": \"https://...\",\n      \"verified\": true\n    }\n  ],\n  \"state_searched\": \"{{input.state}}\",\n  \"search_date\": \"current date\"\n}",
        "prompt": "Find current hardship programs in {{input.state}} Australia for gambling-related financial hardship.\n\nSearch for:\n1. Utility relief grants (electricity, gas, water)\n2. Energy hardship programs\n3. Rental assistance\n4. Emergency relief funds\n5. Food assistance programs\n\n{{#if input.specific_needs}}Also search for: {{input.specific_needs | join(', ')}}{{/if}}\n\nONLY include programs with verifiable sources."
      },
      "depends_on": [],
      "position": { "x": 100, "y": 100 }
    },
    {
      "id": "research-services",
      "name": "Research Local Services",
      "component_type": "generator",
      "config": {
        "provider": "perplexity",
        "model": "sonar-pro",
        "temperature": 0.1,
        "system_prompt": "Find gambling support services. Every service MUST have citation URL.\n\nReturn JSON:\n{\n  \"services\": [\n    {\n      \"name\": \"Service\",\n      \"type\": \"gambling_support\" | \"financial_counselling\" | \"mental_health\" | \"emergency\",\n      \"location\": \"Area\",\n      \"services_offered\": [],\n      \"contact\": \"\",\n      \"citation_url\": \"\"\n    }\n  ],\n  \"national_helplines\": [\n    { \"name\": \"Gambling Helpline\", \"number\": \"1800 858 858\", \"hours\": \"24/7\", \"citation_url\": \"\" }\n  ]\n}",
        "prompt": "Find gambling support and financial counselling services {{#if input.suburb}}near {{input.suburb}}{{/if}} {{input.state}} Australia.\n\nSearch for:\n1. Gambler's Help services\n2. NILS (No Interest Loan Scheme) providers\n3. Financial counselling services\n4. Community support organizations\n\nInclude national helplines with verified contact details."
      },
      "depends_on": [],
      "position": { "x": 350, "y": 100 }
    },
    {
      "id": "research-legal",
      "name": "Research Legal Protections",
      "component_type": "generator",
      "config": {
        "provider": "perplexity",
        "model": "sonar-pro",
        "temperature": 0.1,
        "system_prompt": "Find consumer protection information. Every protection MUST cite official sources.\n\nReturn JSON:\n{\n  \"protections\": [\n    {\n      \"name\": \"Protection\",\n      \"legislation\": \"Act name\",\n      \"summary\": \"Plain language\",\n      \"how_to_use\": \"Instructions\",\n      \"citation_url\": \"\"\n    }\n  ],\n  \"hardship_rights\": { \"description\": \"\", \"citation_url\": \"\" },\n  \"debt_collection_limits\": { \"description\": \"\", \"citation_url\": \"\" }\n}",
        "prompt": "Find consumer protections for gambling debts in Australia, particularly {{input.state}}.\n\nSearch for:\n1. National Consumer Credit Protection Act hardship provisions\n2. ACCC debt collection guidelines\n3. State consumer protections\n4. Hardship variation rights\n\nOnly include information from official government/legal sources."
      },
      "depends_on": [],
      "position": { "x": 600, "y": 100 }
    },
    {
      "id": "research-creditors",
      "name": "Research Creditor Policies",
      "component_type": "generator",
      "config": {
        "provider": "perplexity",
        "model": "sonar-pro",
        "temperature": 0.1,
        "system_prompt": "Find bank/lender hardship policies. Every policy MUST link to official page.\n\nReturn JSON:\n{\n  \"creditor_policies\": [\n    {\n      \"creditor\": \"Bank name\",\n      \"hardship_program\": \"Program name\",\n      \"contact_method\": \"How to apply\",\n      \"what_they_offer\": [],\n      \"gambling_specific\": boolean,\n      \"citation_url\": \"\"\n    }\n  ],\n  \"general_approach\": \"How to approach creditors about gambling hardship\"\n}",
        "prompt": "Find hardship policies for Australian banks:\n- Commonwealth Bank (CBA)\n- NAB\n- ANZ\n- Westpac\n{{#if input.creditors}}- {{input.creditors | join('\\n- ')}}{{/if}}\n\nSearch for financial hardship programs and gambling-specific support."
      },
      "depends_on": [],
      "position": { "x": 850, "y": 100 }
    },
    {
      "id": "compile-citations",
      "name": "Compile All Citations",
      "component_type": "json_transform",
      "config": {
        "data": {
          "hardship": "{{upstream.research-hardship.result}}",
          "services": "{{upstream.research-services.result}}",
          "legal": "{{upstream.research-legal.result}}",
          "creditors": "{{upstream.research-creditors.result}}"
        },
        "jmespath_expression": "{ hardship_programs: hardship, local_services: services, legal_protections: legal, creditor_policies: creditors }"
      },
      "depends_on": ["research-hardship", "research-services", "research-legal", "research-creditors"],
      "position": { "x": 475, "y": 300 }
    },
    {
      "id": "verify-citations",
      "name": "Verify Citation Completeness",
      "component_type": "generator",
      "config": {
        "provider": "anthropic",
        "model": "claude-sonnet-4-20250514",
        "temperature": 0.1,
        "system_prompt": "Review research results and verify citation completeness.\n\nReturn JSON:\n{\n  \"verification_summary\": {\n    \"total_items\": number,\n    \"items_with_citations\": number,\n    \"items_missing_citations\": number,\n    \"missing_citation_items\": [\"Item names without proper citations\"],\n    \"verification_status\": \"complete\" | \"partial\" | \"needs_review\",\n    \"recommendation\": \"What counsellor should verify manually\"\n  },\n  \"all_citations\": [\n    { \"source\": \"Item name\", \"url\": \"citation URL\", \"category\": \"hardship|service|legal|creditor\" }\n  ]\n}",
        "prompt": "Review this research for citation completeness:\n\n{{upstream.compile-citations.result}}\n\nIdentify any items that don't have proper citation URLs and flag for manual verification."
      },
      "depends_on": ["compile-citations"],
      "position": { "x": 475, "y": 450 }
    },
    {
      "id": "final-output",
      "name": "Prepare Final Output",
      "component_type": "json_transform",
      "config": {
        "data": {
          "hardship_programs": "{{upstream.research-hardship.result}}",
          "local_services": "{{upstream.research-services.result}}",
          "legal_protections": "{{upstream.research-legal.result}}",
          "creditor_policies": "{{upstream.research-creditors.result}}",
          "verification_summary": "{{upstream.verify-citations.result.verification_summary}}",
          "all_citations": "{{upstream.verify-citations.result.all_citations}}"
        },
        "jmespath_expression": "@"
      },
      "depends_on": ["verify-citations"],
      "position": { "x": 475, "y": 600 }
    }
  ],
  "output_stage_id": "final-output"
}
