{
  "name": "Insurance Claim Document Processor",
  "nodes": [
    {
      "parameters": {
        "content": "## \ud83c\udfe5 Insurance Claim Document Processor\n\n### What this workflow does\n1. Watches Gmail for claim emails with attachments\n2. Downloads and extracts claim details with PDF Vector\n3. Calculates estimated reimbursement\n4. Routes claims based on amount thresholds\n5. Flags missing pre-authorization or documents\n6. Logs to Google Sheets and notifies team via Slack\n\n### Setup steps\n1. Connect Gmail account (OAuth2)\n2. Get PDF Vector API key from pdfvector.com/api-keys\n3. Create Google Sheet with columns: Claim ID, Claim Type, Policy Number, Claimant, Incident Date, Provider, Diagnosis, Total Amount, Deductible, Est. Reimbursement, Route To, Flags, Status, Received Date\n4. Update spreadsheet ID in the Log Claim node\n5. Connect Slack and select your claims team channel\n\n### Routing thresholds\n- \u2264$1,000: Auto-Approve\n- $1,001-$5,000: Claims Adjuster\n- >$5,000: Senior Adjuster\n\n### Perfect for\n- Insurance companies processing claims\n- Healthcare billing departments\n- Claims adjusters and reviewers",
        "height": 560,
        "width": 360,
        "color": 5
      },
      "id": "sticky-main",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        60,
        60
      ]
    },
    {
      "parameters": {
        "content": "## \ud83d\udcca Claim Types Supported\n\n- Medical/Health\n- Auto/Vehicle\n- Property/Home\n- Life Insurance\n- Disability\n- Travel Insurance",
        "height": 200,
        "width": 200
      },
      "id": "sticky-types",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        440,
        60
      ]
    },
    {
      "parameters": {
        "content": "## \u26a0\ufe0f Auto-Flagged Issues\n\n- Missing Pre-Authorization (if amount >$500)\n- No Supporting Documents attached",
        "height": 120,
        "width": 240
      },
      "id": "sticky-flags",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        660,
        60
      ]
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "filters": {
          "includeSpamTrash": false
        }
      },
      "id": "gmail-trigger",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1,
      "position": [
        140,
        340
      ],
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "get",
        "messageId": "={{ $json.id }}",
        "simple": false,
        "options": {
          "downloadAttachments": true
        }
      },
      "id": "gmail-get",
      "name": "Get a message",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.2,
      "position": [
        340,
        340
      ],
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "extract",
        "inputType": "file",
        "prompt": "Extract insurance claim data as flat fields. claimType (one of: Medical, Auto, Property, Life, Disability, Travel, Other), policyNumber, claimNumber, claimantName, claimantDob, claimantPhone, claimantEmail, policyHolderName, claimantRelationship, incidentDate (YYYY-MM-DD), incidentDescription, incidentLocation, providerName, providerNpi, providerAddress, diagnosisList (semicolon-separated formatted as: code description), proceduresList (semicolon-separated formatted as: code description amount), totalAmount (number), deductible (number), coPayment (number), amountRequested (number), preAuthNumber, supportingDocsList (comma-separated list of attached documents).",
        "schema": "{\"type\": \"object\", \"properties\": {\"claimType\": {\"type\": \"string\"}, \"policyNumber\": {\"type\": \"string\"}, \"claimNumber\": {\"type\": \"string\"}, \"claimantName\": {\"type\": \"string\"}, \"claimantDob\": {\"type\": \"string\"}, \"claimantPhone\": {\"type\": \"string\"}, \"claimantEmail\": {\"type\": \"string\"}, \"policyHolderName\": {\"type\": \"string\"}, \"claimantRelationship\": {\"type\": \"string\"}, \"incidentDate\": {\"type\": \"string\"}, \"incidentDescription\": {\"type\": \"string\"}, \"incidentLocation\": {\"type\": \"string\"}, \"providerName\": {\"type\": \"string\"}, \"providerNpi\": {\"type\": \"string\"}, \"providerAddress\": {\"type\": \"string\"}, \"diagnosisList\": {\"type\": \"string\"}, \"proceduresList\": {\"type\": \"string\"}, \"totalAmount\": {\"type\": \"number\"}, \"deductible\": {\"type\": \"number\"}, \"coPayment\": {\"type\": \"number\"}, \"amountRequested\": {\"type\": \"number\"}, \"preAuthNumber\": {\"type\": \"string\"}, \"supportingDocsList\": {\"type\": \"string\"}}, \"additionalProperties\": false}",
        "binaryPropertyName": "attachment_0"
      },
      "id": "pdfvector-extract",
      "name": "PDF Vector - Extract Claim",
      "type": "n8n-nodes-pdfvector.pdfVector",
      "typeVersion": 2,
      "position": [
        540,
        340
      ],
      "credentials": {
        "pdfVectorApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const data = ($input.first().json?.data || $input.first().json) || {};\n\nconst claimId = data.claimNumber || `CLM-${Date.now().toString(36).toUpperCase()}`;\nconst totalAmount  = parseFloat(data.totalAmount)  || 0;\nconst deductible   = parseFloat(data.deductible)   || 0;\nconst copay        = parseFloat(data.coPayment)     || 0;\nconst estimatedReimbursement = Math.max(0, totalAmount - deductible - copay);\n\nlet routeTo = 'Auto-Approve';\nif (totalAmount > 5000)      routeTo = 'Senior Adjuster';\nelse if (totalAmount >= 1000) routeTo = 'Claims Adjuster';\n\nconst flags = [];\nif (!data.preAuthNumber && totalAmount > 500) flags.push('Missing Pre-Authorization');\nif (!data.supportingDocsList || data.supportingDocsList === 'None' || data.supportingDocsList === '') {\n  flags.push('No Supporting Documents');\n}\n\nreturn [{ json: {\n  claimId,\n  claimType:               data.claimType               || 'Other',\n  policyNumber:            data.policyNumber            || 'N/A',\n  claimantName:            data.claimantName            || 'N/A',\n  incidentDate:            data.incidentDate            || 'N/A',\n  incidentDescription:     data.incidentDescription     || 'N/A',\n  providerName:            data.providerName            || 'N/A',\n  diagnosisList:           data.diagnosisList           || 'N/A',\n  proceduresList:          data.proceduresList          || 'N/A',\n  totalAmount,\n  deductible,\n  estimatedReimbursement,\n  routeTo,\n  flags:     flags.join(', ') || 'None',\n  flagCount: flags.length,\n  processedAt: new Date().toISOString()\n}}];"
      },
      "id": "process-claim",
      "name": "Process Claim",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        740,
        340
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "YOUR_SPREADSHEET_ID",
          "mode": "list"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Claim ID": "={{ $json.claimId }}",
            "Claim Type": "={{ $json.claimType }}",
            "Policy Number": "={{ $json.policyNumber }}",
            "Claimant": "={{ $json.claimantName }}",
            "Incident Date": "={{ $json.incidentDate || 'N/A' }}",
            "Provider": "={{ $json.providerName }}",
            "Diagnosis": "={{ $json.diagnosisList }}",
            "Total Amount": "={{ $json.totalAmount }}",
            "Deductible": "={{ $json.deductible || 0 }}",
            "Est. Reimbursement": "={{ $json.estimatedReimbursement }}",
            "Route To": "={{ $json.routeTo }}",
            "Flags": "={{ $json.flags }}",
            "Status": "=Pending Review",
            "Received Date": "={{ $json.processedAt.split('T')[0] }}"
          }
        },
        "options": {}
      },
      "id": "sheets-log",
      "name": "Log Claim",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.4,
      "position": [
        940,
        340
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "YOUR_SLACK_CHANNEL_ID",
          "mode": "list"
        },
        "text": "=\ud83d\udccb *New Insurance Claim*\n\n*Claim ID:* {{ $('Process Claim').item.json.claimId }}\n*Type:* {{ $('Process Claim').item.json.claimType }}\n*Policy:* {{ $('Process Claim').item.json.policyNumber }}\n\n\ud83d\udc64 *Claimant:* {{ $('Process Claim').item.json.claimantName }}\n\ud83d\udcc5 *Incident Date:* {{ $('Process Claim').item.json.incidentDate }}\n\n\ud83d\udcb0 *Financial Summary:*\n\u2022 Total Claimed: ${{ $('Process Claim').item.json.totalAmount }}\n\u2022 Deductible: ${{ $('Process Claim').item.json.deductible }}\n\u2022 Est. Reimbursement: ${{ $('Process Claim').item.json.estimatedReimbursement }}\n\n\ud83d\udce4 *Route To:* {{ $('Process Claim').item.json.routeTo }}\n{{ $('Process Claim').item.json.flagCount > 0 ? '\\n\u26a0\ufe0f *Flags:* ' + $('Process Claim').item.json.flags : '' }}",
        "otherOptions": {}
      },
      "id": "slack-notify",
      "name": "Notify Claims Team",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.2,
      "position": [
        1140,
        340
      ],
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Get a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get a message": {
      "main": [
        [
          {
            "node": "PDF Vector - Extract Claim",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PDF Vector - Extract Claim": {
      "main": [
        [
          {
            "node": "Process Claim",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Claim": {
      "main": [
        [
          {
            "node": "Log Claim",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Claim": {
      "main": [
        [
          {
            "node": "Notify Claims Team",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "tags": [
    {
      "name": "PDF Vector"
    },
    {
      "name": "Insurance"
    },
    {
      "name": "Claims"
    },
    {
      "name": "Healthcare"
    }
  ],
  "meta": {
    "templateCredsSetupCompleted": false
  }
}