{
  "name": "TestFluxNova",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "cbc9a13e-952e-4708-83d4-eac803e99a93",
        "options": {
          "rawBody": false
        }
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        -2800,
        300
      ],
      "id": "webhook-main",
      "name": "Receive Both Files"
    },
    {
      "parameters": {
        "method": "PUT",
        "url": "={{ $('Receive Both Files').item.json.body?.baseUrl }}/api/workflows/{{ $json.body?.workflowId }}/status",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Bypass-Tunnel-Reminder",
              "value": "true"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{ \"status\": \"PARSING\" }",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -2560,
        300
      ],
      "id": "callback-parsing",
      "name": "Callback: PARSING"
    },
    {
      "parameters": {
        "operation": "xlsx",
        "binaryPropertyName": "source1",
        "options": {}
      },
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        -2300,
        100
      ],
      "id": "parse-xlsx",
      "name": "Parse Source 1 (XLSX)"
    },
    {
      "parameters": {
        "operation": "pdf",
        "binaryPropertyName": "source2",
        "options": {}
      },
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        -2300,
        500
      ],
      "id": "parse-pdf",
      "name": "Parse Source 2 (PDF)"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ JSON.stringify($('Parse Source 1 (XLSX)').item.json) }}\n\nYou are a financial document parser specializing in  Test sample events.\n\nGenerate ONLY valid JSON with these fields:\n- cusip (the CUSIP identifier)\n- eventType: Determine the event type using these rules:\n  * If Call Type = 'F' or text mentions 'all outstanding' \u2192 'Full Call'\n  * If Call Type = 'P' or text mentions 'partial' or 'random lot' \u2192 'Partial Call'\n  * If text mentions 'maturity' or 'redeemed at par' or 'final paydown' \u2192 'Redemption'\n  * If text mentions 'merger' 'exchange offer' 'tender' 'conversion' \u2192 'Reorg'\n- principalRate (default 1000 if not found)\n- premiumRate (if applicable)\n- securityCalledAmount:\n  * For Partial Call: use 'random lot amount paid(partial)' value\n  * For Full Call: use total outstanding amount\n  * For Redemption: use maturity/paydown amount\n- securityDescription (description of the security)\n- payableDate: from redemption date (convert Excel serial numbers to YYYY-MM-DD, e.g. 45944 \u2192 2025-10-14)\n- publicationDate: from publication date (same date conversion)\n- recordDate: 5 business days before payableDate\n- status: always \"Created\"\n- confidenceScore: your confidence in the extraction accuracy (0.0 to 1.0)\n\nRemove any line breaks and special characters. Return ONLY clean JSON.",
        "hasOutputParser": true,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.2,
      "position": [
        -2000,
        100
      ],
      "id": "ai-extract-source1",
      "name": "AI Extract Source 1 JSON"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('Parse Source 2 (PDF)').item.json.text }}\n\nYou are a financial document parser specializing in  Test sample events.\nExtract the following fields from this PDF document:\n\n- cusip: from CUSIP number field\n- payableDate: from 'redeemed on' or 'redemption date' field (YYYY-MM-DD format)\n- publicationDate: from 'Dated:' field (YYYY-MM-DD format)\n- eventType: Determine type:\n  * If document says 'all outstanding' or 'full redemption' \u2192 'Full Call'\n  * If document mentions 'partial' or specific amount less than total \u2192 'Partial Call'\n  * If document mentions 'maturity' \u2192 'Redemption'\n  * If document mentions 'merger' 'exchange' 'tender' \u2192 'Reorg'\n- securityCalledAmount: from 'Amount called' or 'principal amount'\n- securityDescription: description of the security\n- confidenceScore: your confidence (0.0 to 1.0)\n\nReturn ONLY clean JSON.",
        "hasOutputParser": true,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.2,
      "position": [
        -2000,
        500
      ],
      "id": "ai-extract-source2",
      "name": "AI Extract Source 2 JSON"
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n  \"cusip\": \"\",\n  \"eventType\": \"\",\n  \"principalRate\": 1000,\n  \"premiumRate\": 0,\n  \"securityCalledAmount\": 0,\n  \"securityDescription\": \"\",\n  \"payableDate\": \"\",\n  \"publicationDate\": \"\",\n  \"recordDate\": \"\",\n  \"status\": \"Created\",\n  \"confidenceScore\": 0.0\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        -1860,
        300
      ],
      "id": "json-formatter-s1",
      "name": "JSON Formatter (S1)"
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n  \"cusip\": \"\",\n  \"payableDate\": \"\",\n  \"publicationDate\": \"\",\n  \"eventType\": \"\",\n  \"securityCalledAmount\": 0,\n  \"securityDescription\": \"\",\n  \"confidenceScore\": 0.0\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        -1860,
        700
      ],
      "id": "json-formatter-s2",
      "name": "JSON Formatter (S2)"
    },
    {
      "parameters": {
        "modelSource": "inferenceProfile",
        "model": "us.anthropic.claude-opus-4-20250514-v1:0",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatAwsBedrock",
      "typeVersion": 1.1,
      "position": [
        -2000,
        300
      ],
      "id": "bedrock-s1",
      "name": "AWS Bedrock (S1)",
      "credentials": {
        "aws": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "modelSource": "inferenceProfile",
        "model": "us.anthropic.claude-opus-4-20250514-v1:0",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatAwsBedrock",
      "typeVersion": 1.1,
      "position": [
        -2000,
        700
      ],
      "id": "bedrock-s2",
      "name": "AWS Bedrock (S2)",
      "credentials": {
        "aws": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $('Receive Both Files').item.json.body?.baseUrl }}/api/events",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Bypass-Tunnel-Reminder",
              "value": "true"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify(Object.assign({}, $json.output, { workflowId: $('Receive Both Files').item.json.body?.workflowId || '' })) }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -1600,
        100
      ],
      "id": "create-event",
      "name": "Create Event API"
    },
    {
      "parameters": {
        "mode": "append"
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 2.1,
      "position": [
        -1300,
        300
      ],
      "id": "merge-sources",
      "name": "Merge S1 + S2 Results"
    },
    {
      "parameters": {
        "operation": "limit",
        "limit": 1
      },
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 1,
      "position": [
        -1150,
        300
      ],
      "id": "limit-1",
      "name": "Limit to 1"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "Source 1 (XLSX) extracted data: {{ JSON.stringify($('Create Event API').item.json) }}\n\nSource 2 (PDF) extracted data: {{ JSON.stringify($('AI Extract Source 2 JSON').item.json.output) }}\n\nCompare these two sources for the same Test sample event:\n\n1. Compare CUSIP - must match exactly\n2. Compare payable date - must match\n3. Compare event type - must match\n\nGenerate ONLY valid JSON with:\n- cusip: the CUSIP from the comparison\n- status: 'Verified' if ALL fields match, 'Verification Failure' if ANY mismatch\n- remarks: detailed explanation of what matched/mismatched\n- confidenceScore: overall confidence (0.0 to 1.0)\n- matchDetails: object with { cusipMatch: bool, dateMatch: bool, typeMatch: bool }",
        "hasOutputParser": true,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.2,
      "position": [
        -1000,
        300
      ],
      "id": "compare-sources",
      "name": "Compare S1 & S2"
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n  \"cusip\": \"\",\n  \"status\": \"\",\n  \"remarks\": \"\",\n  \"confidenceScore\": 0.0,\n  \"matchDetails\": { \"cusipMatch\": true, \"dateMatch\": true, \"typeMatch\": true }\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        -860,
        500
      ],
      "id": "json-formatter-compare",
      "name": "JSON Formatter (Compare)"
    },
    {
      "parameters": {
        "modelSource": "inferenceProfile",
        "model": "us.anthropic.claude-opus-4-20250514-v1:0",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatAwsBedrock",
      "typeVersion": 1.1,
      "position": [
        -1000,
        500
      ],
      "id": "bedrock-compare",
      "name": "AWS Bedrock (Compare)",
      "credentials": {
        "aws": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "PUT",
        "url": "={{ $('Receive Both Files').item.json.body?.baseUrl }}/api/events/{{ $('Create Event API').item.json.eventId }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Bypass-Tunnel-Reminder",
              "value": "true"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json.output) }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -600,
        300
      ],
      "id": "update-event-status",
      "name": "Update Event Status"
    },
    {
      "parameters": {
        "method": "PUT",
        "url": "={{ $('Receive Both Files').item.json.body?.baseUrl }}/api/workflows/{{ $('Receive Both Files').item.json.body?.workflowId }}/status",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Bypass-Tunnel-Reminder",
              "value": "true"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ status: $('Compare S1 & S2').item.json.output.status === 'Verified' ? 'COMPLETED' : 'COMPLETED_WITH_FAILURE', eventType: $('Create Event API').item.json.event_type, cusip: $('Create Event API').item.json.cusip }) }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -300,
        300
      ],
      "id": "callback-complete",
      "name": "Callback: COMPLETED"
    }
  ],
  "connections": {
    "Receive Both Files": {
      "main": [
        [
          {
            "node": "Callback: PARSING",
            "type": "main",
            "index": 0
          },
          {
            "node": "Parse Source 1 (XLSX)",
            "type": "main",
            "index": 0
          },
          {
            "node": "Parse Source 2 (PDF)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Callback: PARSING": {
      "main": [
        []
      ]
    },
    "Parse Source 1 (XLSX)": {
      "main": [
        [
          {
            "node": "AI Extract Source 1 JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Source 2 (PDF)": {
      "main": [
        [
          {
            "node": "AI Extract Source 2 JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Extract Source 1 JSON": {
      "main": [
        [
          {
            "node": "Create Event API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "JSON Formatter (S1)": {
      "ai_outputParser": [
        [
          {
            "node": "AI Extract Source 1 JSON",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "JSON Formatter (S2)": {
      "ai_outputParser": [
        [
          {
            "node": "AI Extract Source 2 JSON",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "AWS Bedrock (S1)": {
      "ai_languageModel": [
        [
          {
            "node": "AI Extract Source 1 JSON",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "AWS Bedrock (S2)": {
      "ai_languageModel": [
        [
          {
            "node": "AI Extract Source 2 JSON",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Create Event API": {
      "main": [
        [
          {
            "node": "Merge S1 + S2 Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Extract Source 2 JSON": {
      "main": [
        [
          {
            "node": "Merge S1 + S2 Results",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge S1 + S2 Results": {
      "main": [
        [
          {
            "node": "Limit to 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit to 1": {
      "main": [
        [
          {
            "node": "Compare S1 & S2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "JSON Formatter (Compare)": {
      "ai_outputParser": [
        [
          {
            "node": "Compare S1 & S2",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "AWS Bedrock (Compare)": {
      "ai_languageModel": [
        [
          {
            "node": "Compare S1 & S2",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Compare S1 & S2": {
      "main": [
        [
          {
            "node": "Update Event Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Event Status": {
      "main": [
        [
          {
            "node": "Callback: COMPLETED",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "tags": [
    {
      "name": "TestFluxNova"
    }
  ]
}