{
  "id": "p2KycIntake00001",
  "name": "P2 KYC intake",
  "nodes": [
    {
      "id": "9bdf7311-b357-4578-8807-0021fa5ba7ca",
      "name": "Human: input",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -110,
        -170
      ],
      "parameters": {
        "content": "## Human: input\nA person uploads the documents in the form.",
        "width": 320,
        "height": 330,
        "color": 6
      }
    },
    {
      "id": "bf85ad14-50b1-4a41-8162-9ccdb4d16980",
      "name": "Human: result",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        4310,
        -170
      ],
      "parameters": {
        "content": "## Human: result\nThe same person sees the results table in the browser.",
        "width": 320,
        "height": 330,
        "color": 6
      }
    },
    {
      "id": "dc21e21f-aac2-469a-85bf-d0a2caa4fc2e",
      "position": [
        0,
        0
      ],
      "name": "Upload",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.5,
      "parameters": {
        "formTitle": "KYC intake",
        "formDescription": "Upload the onboarding documents of one new LP (PDF). They are classified, checked for completeness and validity, and risk-flagged.",
        "formFields": {
          "values": [
            {
              "fieldLabel": "LP name",
              "fieldName": "lp",
              "fieldType": "text",
              "requiredField": true
            },
            {
              "fieldLabel": "Documents",
              "fieldName": "files",
              "fieldType": "file",
              "multipleFiles": true,
              "acceptFileTypes": ".pdf",
              "requiredField": true
            }
          ]
        },
        "options": {
          "path": "kyc-intake",
          "appendAttribution": false
        }
      },
      "webhookId": "8319309e-f86f-4ddd-86d9-f134f1945aeb"
    },
    {
      "id": "f1db5494-f806-47e1-8f03-e6846cd79eae",
      "position": [
        260,
        0
      ],
      "name": "Read document",
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.2,
      "parameters": {
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "blkReadDocument1",
          "cachedResultName": "read document (OCR)",
          "cachedResultUrl": "/workflow/blkReadDocument1"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        },
        "mode": "each",
        "options": {
          "waitForSubWorkflow": true
        }
      },
      "notes": "One item per document with its text"
    },
    {
      "id": "fa609a9a-d7d7-4a27-8642-d4b0a11cb0e5",
      "position": [
        520,
        0
      ],
      "name": "Question: document type",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "52d7e236-8dcf-4de5-8d61-30f714a9b3ec",
              "name": "state",
              "value": "=File: {{ $json.fileName }}\n\n{{ $json.text.slice(0, 2500) }}",
              "type": "string"
            },
            {
              "id": "48165ae0-ea92-4753-89ff-69ff5566ccd3",
              "name": "questions",
              "value": "{\n  \"docType\": {\n    \"type\": \"choice\",\n    \"instructions\": \"Which KYC document is this?\",\n    \"criteria\": {\n      \"subscription_form\": \"a subscription form or subscription agreement signed by the investor\",\n      \"id_document\": \"a passport, identity card or driving licence of a person\",\n      \"proof_of_address\": \"a utility bill, bank statement or official letter proving a residential or business address\",\n      \"register_extract\": \"an extract from a commercial, trade or trust register about a company or trust\",\n      \"ubo_declaration\": \"a declaration of the ultimate beneficial owners\",\n      \"source_of_funds\": \"a letter explaining where the invested money comes from\",\n      \"other\": \"anything else\"\n    }\n  }\n}",
              "type": "object"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      }
    },
    {
      "id": "09d6926c-6021-4785-8859-1d652776edcf",
      "position": [
        780,
        0
      ],
      "name": "Ask Jev: document type",
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.2,
      "parameters": {
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "blkDecideJev0001",
          "cachedResultName": "decide (Jev)",
          "cachedResultUrl": "/workflow/blkDecideJev0001"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        },
        "mode": "each",
        "options": {
          "waitForSubWorkflow": true
        }
      }
    },
    {
      "id": "ccbcfb15-00e7-4dda-89f9-d3e3431e7d00",
      "position": [
        1040,
        0
      ],
      "name": "Fields to extract",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "dd3f3d3a-ec1f-4ec0-8008-690f43ff174c",
              "name": "schema",
              "value": "kyc",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      }
    },
    {
      "id": "cabb717a-6626-48e1-8a2a-8f19ada1c9b3",
      "position": [
        1300,
        0
      ],
      "name": "Extract document facts",
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.2,
      "parameters": {
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "blkExtractFields",
          "cachedResultName": "extract fields (LLM)",
          "cachedResultUrl": "/workflow/blkExtractFields"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        },
        "mode": "each",
        "options": {
          "waitForSubWorkflow": true
        }
      },
      "notes": "LLM reads dates, holder, public office holders"
    },
    {
      "id": "3f678e70-26ab-401f-8edf-a11c9437d5ec",
      "position": [
        1560,
        0
      ],
      "name": "Document checks",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "1e84e520-4dac-4c39-8318-793c312ae649",
              "name": "docType",
              "value": "={{ $json.answers.docType.value }}",
              "type": "string"
            },
            {
              "id": "22c1d52e-ad1a-4527-80c6-eff97c37b70f",
              "name": "idExpired",
              "value": "={{ $json.answers.docType.value == 'id_document' && $json.record.expiryDate < $today.toISODate() }}",
              "type": "boolean"
            },
            {
              "id": "69a7e5eb-cab2-4099-80ed-9819ef8c6432",
              "name": "addressTooOld",
              "value": "={{ $json.answers.docType.value == 'proof_of_address' && $json.record.documentDate < $today.minus({ days: 90 }).toISODate() }}",
              "type": "boolean"
            },
            {
              "id": "4e8d0023-b1fa-4994-8053-2780e0a70a38",
              "name": "publicOffice",
              "value": "={{ $json.record.publicOfficeHolders ?? [] }}",
              "type": "array"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      },
      "notes": "Per document: is the ID expired, is the proof of address older than 90 days?"
    },
    {
      "id": "e3f0c87b-75b2-49a5-87b6-d5cc0a3da1c7",
      "position": [
        1820,
        0
      ],
      "name": "All documents",
      "type": "n8n-nodes-base.aggregate",
      "typeVersion": 1,
      "parameters": {
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "docType"
            },
            {
              "fieldToAggregate": "idExpired"
            },
            {
              "fieldToAggregate": "addressTooOld"
            },
            {
              "fieldToAggregate": "publicOffice"
            }
          ]
        },
        "options": {
          "mergeLists": true
        }
      }
    },
    {
      "id": "7505baec-fc72-4ab0-804d-dafd9ea370c2",
      "position": [
        2080,
        0
      ],
      "name": "Checklist",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "2bbcbb20-1275-482f-81d3-1a93143cee8c",
              "name": "lp",
              "value": "={{ $('Upload').first().json.lp }}",
              "type": "string"
            },
            {
              "id": "e3f73893-53df-45f7-8041-31f36a064648",
              "name": "fields.Subscription form",
              "value": "={{ $json.docType.includes('subscription_form') ? 'received' : 'missing' }}",
              "type": "string"
            },
            {
              "id": "c4f431ae-b696-4830-8e01-8e48a37648e7",
              "name": "fields.ID document",
              "value": "={{ $json.docType.includes('id_document') ? 'received' : 'missing' }}",
              "type": "string"
            },
            {
              "id": "201e5f37-c623-4286-85e3-31c2038ada1b",
              "name": "fields.Proof of address",
              "value": "={{ $json.docType.includes('proof_of_address') ? 'received' : 'missing' }}",
              "type": "string"
            },
            {
              "id": "fd563810-4c05-4955-8528-269af7cf68e6",
              "name": "fields.Register extract",
              "value": "={{ $json.docType.includes('register_extract') ? 'received' : 'missing' }}",
              "type": "string"
            },
            {
              "id": "755f1c09-99a9-406a-8aff-8dcb04c615b6",
              "name": "fields.UBO declaration",
              "value": "={{ $json.docType.includes('ubo_declaration') ? 'received' : 'missing' }}",
              "type": "string"
            },
            {
              "id": "8933057a-f4ce-4194-8dd6-a7c93eb36656",
              "name": "fields.Source-of-funds letter",
              "value": "={{ $json.docType.includes('source_of_funds') ? 'received' : 'missing' }}",
              "type": "string"
            },
            {
              "id": "23b13267-5014-4d4e-8b7b-62932051a2ed",
              "name": "fields.ID validity",
              "value": "={{ $json.idExpired.includes(true) ? 'expired' : 'valid' }}",
              "type": "string"
            },
            {
              "id": "d6bc7ccc-9533-4e0d-8e46-26362e903e31",
              "name": "fields.Address proof",
              "value": "={{ $json.addressTooOld.includes(true) ? 'older than three months' : 'recent' }}",
              "type": "string"
            },
            {
              "id": "caab572e-96dd-487f-8171-a01e6664d3dd",
              "name": "fields.Public office named",
              "value": "={{ $json.publicOffice.join('; ') || 'none' }}",
              "type": "string"
            },
            {
              "id": "d90ad920-157e-4df7-8251-51f84527f90c",
              "name": "received",
              "value": "={{ $json.docType.join(', ') }}",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": false,
        "options": {}
      },
      "notes": "One line per required document; change the list here"
    },
    {
      "id": "ca5a7859-cf3a-41aa-8467-64c250852b8e",
      "position": [
        2340,
        0
      ],
      "name": "Checklist and risk",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {
          "includeUnpaired": true
        }
      }
    },
    {
      "id": "939d8652-8d91-4f41-8c3a-f2f95f947d24",
      "position": [
        2600,
        0
      ],
      "name": "Status",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "parameters": {
        "mode": "rules",
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "loose",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "56d0ab01-a171-4a91-859a-e73adaa0332a",
                    "leftValue": "={{ $json.answers.pep.value }}",
                    "rightValue": "",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    }
                  },
                  {
                    "id": "73bd3d3d-30be-4827-8257-41df9c81e992",
                    "leftValue": "={{ $json.fields['Public office named'] }}",
                    "rightValue": "none",
                    "operator": {
                      "type": "string",
                      "operation": "notEquals"
                    }
                  },
                  {
                    "id": "db9c9c4f-b619-4688-80d2-1ab53aabc70c",
                    "leftValue": "={{ $json.answers.risk.value }}",
                    "rightValue": 4,
                    "operator": {
                      "type": "number",
                      "operation": "gte"
                    }
                  }
                ],
                "combinator": "or"
              },
              "renameOutput": true,
              "outputKey": "escalate"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "loose",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "9a29e9ec-a6cb-42c3-8056-2249e01f230a",
                    "leftValue": "={{ $json.fields['Subscription form'] }}",
                    "rightValue": "missing",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  },
                  {
                    "id": "d28ab5a5-5950-458f-870d-a1f20466a716",
                    "leftValue": "={{ $json.fields['ID document'] }}",
                    "rightValue": "missing",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  },
                  {
                    "id": "eb0ade45-748e-4e21-8791-92de8407fac0",
                    "leftValue": "={{ $json.fields['Proof of address'] }}",
                    "rightValue": "missing",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  },
                  {
                    "id": "543a1c7d-ed7f-4fc3-82f9-3ab79c5808e9",
                    "leftValue": "={{ $json.fields['Register extract'] }}",
                    "rightValue": "missing",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  },
                  {
                    "id": "a8c22a63-82a0-486a-88c4-adc38a0c84f6",
                    "leftValue": "={{ $json.fields['UBO declaration'] }}",
                    "rightValue": "missing",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  },
                  {
                    "id": "4472357c-55fd-437c-80d8-78911e206111",
                    "leftValue": "={{ $json.fields['Source-of-funds letter'] }}",
                    "rightValue": "missing",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  },
                  {
                    "id": "5c452bf7-4360-4fad-8f09-ce92ca193270",
                    "leftValue": "={{ $json.fields['ID validity'] }}",
                    "rightValue": "expired",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  },
                  {
                    "id": "57727100-ac96-4a1d-8939-89d38d56c6ba",
                    "leftValue": "={{ $json.fields['Address proof'] }}",
                    "rightValue": "older than three months",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "or"
              },
              "renameOutput": true,
              "outputKey": "pending"
            }
          ]
        },
        "looseTypeValidation": true,
        "options": {
          "fallbackOutput": "extra",
          "renameFallbackOutput": "complete"
        }
      },
      "notes": "Escalate: PEP or high risk. Pending: something missing or not valid."
    },
    {
      "id": "21aa335b-fa82-4bd4-862f-417579c18f8c",
      "position": [
        1560,
        300
      ],
      "name": "Source-of-funds letter",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "72202c04-547a-4721-8257-6f3c596b4acf",
              "leftValue": "={{ $json.docType }}",
              "rightValue": "source_of_funds",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": true,
        "options": {}
      }
    },
    {
      "id": "ceef683c-882f-454b-8c2e-ac9570c994c7",
      "position": [
        1820,
        300
      ],
      "name": "Question: risk",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "ba8aeb76-d7e1-4b72-8e1c-b3ee013fa3d8",
              "name": "state",
              "value": "={{ $json.text }}",
              "type": "string"
            },
            {
              "id": "dcd48cd3-f9f1-47fc-8c9b-a20a6e63a3e8",
              "name": "questions",
              "value": "{\n  \"pep\": {\n    \"type\": \"noul\",\n    \"instructions\": \"Does this letter name a person who holds or held a public office, such as a mayor, minister, member of parliament or senior official?\",\n    \"criteria\": {\n      \"true\": \"yes, a current or former public office holder is named\",\n      \"false\": \"no public office holder is named\"\n    }\n  },\n  \"sofConcrete\": {\n    \"type\": \"noul\",\n    \"instructions\": \"Does the letter name a concrete origin of the money, such as the sale of a company, with an amount and a date?\",\n    \"criteria\": {\n      \"true\": \"a concrete origin with amount and date is given\",\n      \"false\": \"the origin is vague\"\n    }\n  },\n  \"risk\": {\n    \"type\": \"score\",\n    \"instructions\": \"How high is the money-laundering risk of this investor?\",\n    \"criteria\": [\n      \"low\",\n      \"moderate\",\n      \"elevated\",\n      \"high\",\n      \"very high\"\n    ]\n  }\n}",
              "type": "object"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      }
    },
    {
      "id": "1ba62f04-c9cd-4f9a-8a02-2dfc2e3668ba",
      "position": [
        2080,
        300
      ],
      "name": "Ask Jev: risk",
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.2,
      "parameters": {
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "blkDecideJev0001",
          "cachedResultName": "decide (Jev)",
          "cachedResultUrl": "/workflow/blkDecideJev0001"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        },
        "mode": "each",
        "options": {
          "waitForSubWorkflow": true
        }
      },
      "notes": "PEP, source of funds, risk score; reads the source-of-funds letter"
    },
    {
      "id": "738f09ca-037b-4267-89a3-7c2d223388c8",
      "position": [
        3120,
        0
      ],
      "name": "KYC result",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a6938912-cc8d-41ad-8a07-1ad20ad00d93",
              "name": "checkedOn",
              "value": "={{ $today.toISODate() }}",
              "type": "string"
            },
            {
              "id": "7e8a5517-6812-465c-86bf-562f14f33b8f",
              "name": "fields.PEP (Jev)",
              "value": "={{ ($json.answers.pep.probability * 100).round() }}%",
              "type": "string"
            },
            {
              "id": "13a8eeac-879b-49e4-8e9b-f13cbe28b27c",
              "name": "fields.Risk",
              "value": "={{ $json.answers.risk.value }} of 5 ({{ $json.answers.risk.label }})",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      }
    },
    {
      "id": "f006a05e-822b-4dd0-8201-c6a16fc8d70e",
      "position": [
        3380,
        0
      ],
      "name": "Draft email to LP (LLM)",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.7,
      "parameters": {
        "promptType": "define",
        "text": "=Write a short, polite email from Investor Relations at Team Rocket Capital Management to {{ $json.lp }} about their onboarding (KYC) documents.\nChecklist: {{ $json.fields.toJsonString() }}\nAsk for every document marked missing, expired or older than three months. If nothing is missing or invalid, confirm that the documents are complete and that we will be in touch about the next steps. Never mention internal risk ratings, PEP checks, public offices or escalations. Sign as \"Investor Relations, Team Rocket Capital Management\". Plain text without Markdown (no asterisks, no bullet symbols), no subject line."
      }
    },
    {
      "id": "c708de3d-3718-4068-8c9b-17a312a9cb03",
      "position": [
        3640,
        0
      ],
      "name": "Save status",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "parameters": {
        "resource": "row",
        "operation": "upsert",
        "dataTableId": {
          "__rl": true,
          "mode": "name",
          "value": "kyc_status",
          "cachedResultName": "kyc_status"
        },
        "filters": {
          "conditions": [
            {
              "keyName": "lp",
              "condition": "eq",
              "keyValue": "={{ $('KYC result').item.json.lp }}"
            }
          ]
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "lp": "={{ $('KYC result').item.json.lp }}",
            "received": "={{ $('KYC result').item.json.received }}",
            "uboDeclaration": "={{ $('KYC result').item.json.fields['UBO declaration'] }}",
            "idDocument": "={{ $('KYC result').item.json.fields['ID validity'] }}",
            "proofOfAddress": "={{ $('KYC result').item.json.fields['Address proof'] }}",
            "pep": "={{ $('KYC result').item.json.status == 'escalate' }}",
            "risk": "={{ $('KYC result').item.json.answers.risk.value }}",
            "status": "={{ $('KYC result').item.json.status }}",
            "checkedOn": "={{ $('KYC result').item.json.checkedOn }}",
            "draft": "={{ $('Draft email to LP (LLM)').item.json.text }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "lp",
              "displayName": "lp",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "received",
              "displayName": "received",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "uboDeclaration",
              "displayName": "uboDeclaration",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "idDocument",
              "displayName": "idDocument",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "proofOfAddress",
              "displayName": "proofOfAddress",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "pep",
              "displayName": "pep",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "boolean",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "risk",
              "displayName": "risk",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "status",
              "displayName": "status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "checkedOn",
              "displayName": "checkedOn",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "draft",
              "displayName": "draft",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      }
    },
    {
      "id": "53286ffc-a68c-49a8-89d5-1b3d27dacc8d",
      "position": [
        3900,
        0
      ],
      "name": "Result row",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "c85e39b3-7377-49d5-8c6a-e18ddc0292af",
              "name": "LP",
              "value": "={{ $('KYC result').item.json.lp }}",
              "type": "string"
            },
            {
              "id": "6cc699f3-5916-46e9-8900-06540ebf0599",
              "name": "Status",
              "value": "={{ $('KYC result').item.json.status }}",
              "type": "string"
            },
            {
              "id": "02474e90-7e9f-4be2-84c2-82bcaa49abcd",
              "name": "Subscription form",
              "value": "={{ $('KYC result').item.json.fields['Subscription form'] }}",
              "type": "string"
            },
            {
              "id": "8dff4d2e-dfcc-42d8-88a7-e020c261556a",
              "name": "ID document",
              "value": "={{ $('KYC result').item.json.fields['ID document'] }}",
              "type": "string"
            },
            {
              "id": "31fa8016-7fb2-4d9b-8acf-b756579d207b",
              "name": "Proof of address",
              "value": "={{ $('KYC result').item.json.fields['Proof of address'] }}",
              "type": "string"
            },
            {
              "id": "e783a27a-ac1c-48a0-874c-f90a6000360f",
              "name": "Register extract",
              "value": "={{ $('KYC result').item.json.fields['Register extract'] }}",
              "type": "string"
            },
            {
              "id": "0d5e16eb-8593-485d-8967-4ae7b45c2c3c",
              "name": "UBO declaration",
              "value": "={{ $('KYC result').item.json.fields['UBO declaration'] }}",
              "type": "string"
            },
            {
              "id": "61f0495c-dd5a-400f-8008-8c8ee290f9b8",
              "name": "Source-of-funds letter",
              "value": "={{ $('KYC result').item.json.fields['Source-of-funds letter'] }}",
              "type": "string"
            },
            {
              "id": "8befe51a-8950-40a4-89ec-17850787f289",
              "name": "ID validity",
              "value": "={{ $('KYC result').item.json.fields['ID validity'] }}",
              "type": "string"
            },
            {
              "id": "742b2a1d-112c-4454-8362-5e8283871adc",
              "name": "Address proof",
              "value": "={{ $('KYC result').item.json.fields['Address proof'] }}",
              "type": "string"
            },
            {
              "id": "6cc1aca2-4615-4885-8319-67080156a98b",
              "name": "Public office named",
              "value": "={{ $('KYC result').item.json.fields['Public office named'] }}",
              "type": "string"
            },
            {
              "id": "0c45be5d-9e96-4509-8353-6e6d8e61f8e3",
              "name": "PEP (Jev)",
              "value": "={{ $('KYC result').item.json.fields['PEP (Jev)'] }}",
              "type": "string"
            },
            {
              "id": "3b2fc266-43f3-4e28-84d5-ed4cfc246e40",
              "name": "Risk",
              "value": "={{ $('KYC result').item.json.fields['Risk'] }}",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": false,
        "options": {}
      },
      "notes": "The row of the results table"
    },
    {
      "id": "02034fd9-e777-4a95-8796-e6dc1a93add5",
      "position": [
        4160,
        0
      ],
      "name": "Results table",
      "type": "n8n-nodes-base.html",
      "typeVersion": 1.2,
      "parameters": {
        "operation": "convertToHtmlTable",
        "options": {
          "customStyling": true,
          "tableAttributes": "style=\"border-collapse:collapse;font-size:14px;margin:0 auto\"",
          "headerAttributes": "style=\"background:#f2f2f2;border:1px solid #ccc;padding:6px 8px;text-align:left;vertical-align:top\"",
          "cellAttributes": "style=\"border:1px solid #ccc;padding:6px 8px;text-align:left;vertical-align:top\""
        }
      }
    },
    {
      "id": "9b70f191-fd72-484b-82b6-6942c5cb25f2",
      "position": [
        4420,
        0
      ],
      "name": "Show result",
      "type": "n8n-nodes-base.form",
      "typeVersion": 2.5,
      "parameters": {
        "operation": "completion",
        "respondWith": "showText",
        "responseText": "=<div style=\"font-family:system-ui,sans-serif\"><h2 style=\"text-align:center\">KYC intake: result</h2>{{ $json.table }}<h3 style=\"text-align:center\">Email draft to the LP</h3><div style=\"max-width:720px;margin:16px auto;white-space:pre-wrap;text-align:left\">{{ $('Draft email to LP (LLM)').first().json.text }}</div></div>"
      },
      "webhookId": "51671e45-619b-44d4-8f43-89956feb4b0f"
    },
    {
      "id": "9515fb00-3d65-4366-8dc9-4ca5db9ac044",
      "position": [
        2860,
        -160
      ],
      "name": "Escalate",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "5361d239-bde9-4d25-846a-fd3036f50d83",
              "name": "status",
              "value": "escalate",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      }
    },
    {
      "id": "c7d829ec-da9b-4d26-89a9-bb9ad1c4c8eb",
      "position": [
        2860,
        0
      ],
      "name": "Pending",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a5fded3c-f9e5-4722-84a6-0f6531da8776",
              "name": "status",
              "value": "pending",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      }
    },
    {
      "id": "79dd08d0-2dc6-4b17-8b9a-ed9732bae4e8",
      "position": [
        2860,
        160
      ],
      "name": "Complete",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "85282598-280d-4ad2-8e7c-a26f43c73f6e",
              "name": "status",
              "value": "complete",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      }
    },
    {
      "id": "094b945e-24de-4535-84f7-72fe8511f487",
      "position": [
        3380,
        220
      ],
      "name": "Chat model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {
          "temperature": 0
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "cred-openai",
          "name": "n8n free OpenAI API credits"
        }
      }
    },
    {
      "id": "bbcf3c4a-9e7a-49c5-8035-193f7aeb724d",
      "position": [
        0,
        -470
      ],
      "name": "About",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "parameters": {
        "content": "## P2 KYC intake (Jev)\nRead each document, Jev classifies it, the LLM extracts dates and names. The checklist marks missing documents, an expired ID and an old proof of address; Jev rates PEP, source of funds and risk from the source-of-funds letter; the Status node decides; the LLM drafts the email to the LP. No code.",
        "width": 660,
        "height": 260,
        "color": 7
      }
    }
  ],
  "connections": {
    "Upload": {
      "main": [
        [
          {
            "node": "Read document",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read document": {
      "main": [
        [
          {
            "node": "Question: document type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Question: document type": {
      "main": [
        [
          {
            "node": "Ask Jev: document type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ask Jev: document type": {
      "main": [
        [
          {
            "node": "Fields to extract",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fields to extract": {
      "main": [
        [
          {
            "node": "Extract document facts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract document facts": {
      "main": [
        [
          {
            "node": "Document checks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Document checks": {
      "main": [
        [
          {
            "node": "All documents",
            "type": "main",
            "index": 0
          },
          {
            "node": "Source-of-funds letter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "All documents": {
      "main": [
        [
          {
            "node": "Checklist",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Checklist": {
      "main": [
        [
          {
            "node": "Checklist and risk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Checklist and risk": {
      "main": [
        [
          {
            "node": "Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Source-of-funds letter": {
      "main": [
        [
          {
            "node": "Question: risk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Question: risk": {
      "main": [
        [
          {
            "node": "Ask Jev: risk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "KYC result": {
      "main": [
        [
          {
            "node": "Draft email to LP (LLM)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Draft email to LP (LLM)": {
      "main": [
        [
          {
            "node": "Save status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save status": {
      "main": [
        [
          {
            "node": "Result row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Result row": {
      "main": [
        [
          {
            "node": "Results table",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Results table": {
      "main": [
        [
          {
            "node": "Show result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ask Jev: risk": {
      "main": [
        [
          {
            "node": "Checklist and risk",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Status": {
      "main": [
        [
          {
            "node": "Escalate",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Pending",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Complete",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Escalate": {
      "main": [
        [
          {
            "node": "KYC result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pending": {
      "main": [
        [
          {
            "node": "KYC result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Complete": {
      "main": [
        [
          {
            "node": "KYC result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chat model": {
      "ai_languageModel": [
        [
          {
            "node": "Draft email to LP (LLM)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "callerPolicy": "workflowsFromSameOwner"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true
  }
}
