Skip to main content

Automate loan document analysis with Mistral OCR and GPT for underwriting decisions

Workflow preview

Workflow preview
100%
Automate loan document analysis with Mistral OCR and GPT for underwriting decisions preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

LOB Underwriting with AI This template ingests borrower documents from OneDrive, extracts text with OCR, classifies each file (ID, paystub, bank statement, utilities, tax forms, etc.), aggregates e...

Best for

  • Document Extraction automation workflows
  • AI Summarization automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.microsoftonedrive, n8n-nodes-base.mistralai, n8n-nodes-base.code, @n8n/n8n-nodes-langchain.agent, @n8n/n8n-nodes-langchain.lmchatopenai, n8n-nodes-base.manualtrigger, n8n-nodes-base.stickynote, n8n-nodes-base.splitinbatches

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Vinay Gangidi.

Original n8n.io source

1.1 Workflow description

Title
Automate loan document analysis with Mistral OCR and GPT for underwriting decisions
Workflow name
Automate loan document analysis with Mistral OCR and GPT for underwriting decisions

LOB Underwriting with AI

This template ingests borrower documents from OneDrive, extracts text with OCR, classifies each file (ID, paystub, bank statement, utilities, tax forms, etc.), aggregates everything per borrower, and asks an LLM to produce a clear underwriting summary and decision (plus next steps).

Good to know

  1. AI and OCR usage consume credits (OpenAI + your OCR provider).
  2. Folder lookups by name can be ambiguous—use a fixed folderId in production.
  3. Scanned image quality drives OCR accuracy; bad scans yield weak text.
  4. This flow handles PII—mask sensitive data in logs and control access.
  5. Start small: batch size and pagination keep costs/memory sane.

How it works

  1. Import & locate docs: Manual trigger kicks off a OneDrive folder search (e.g., “LOBs”) and lists files inside.
  2. Per-file loop: Download each file → run OCR → classify the document type using filename + extracted text.
  3. Aggregate: Combine per-file results into a borrower payload (make BorrowerName dynamic).
  4. LLM analysis: Feed the payload to an AI Agent (OpenAI model) to extract underwriting-relevant facts and produce a decision + next steps.
  5. Output: Return a human-readable summary (and optionally structured JSON for systems).

How to use

  1. Start with the Manual Trigger to validate end-to-end on a tiny test folder.
  2. Once stable, swap in a Schedule/Cron or Webhook trigger.
  3. Review the generated underwriting summary; handle only flagged exceptions (unknown/unreadable docs, low confidence).

Setup steps

Connect accounts

  • Add credentials for OneDrive, OCR, and OpenAI.

Configure inputs

  • In Search a folder, point to your borrower docs (prefer folderId; otherwise tighten the name query).
  • In Get items in a folder, enable pagination if the folder is large.
  • In Split in Batches, set a conservative batch size to control costs.

Wire the file path

  • Download a file must receive the current file’s id from the folder listing.
  • Make sure the OCR node receives binary input (PDFs/images).

Classification

  • Update keyword rules to match your region/lenders/utilities/tax forms.
  • Keep a fallback Unknown class and log it for review.

Combine

  1. Replace the hard-coded BorrowerName with:
  • a Set node field,
  • a form input, or
  • parsing from folder/file naming conventions.

AI Agent

  • Set your OpenAI model/credentials.
  • Ask the model to output JSON first (structured fields) and Markdown second (readable summary).
  • Keep temperature low for consistent, audit-friendly results.

Optional outputs

  • Persist JSON/Markdown to Notion/Docs/DB or write to storage.

Customize if needed

  • Doc types: add/remove categories and keywords without touching core logic.
  • Error handling: add IF paths for empty folders, failed downloads, empty OCR, or Unknown class; retry transient API errors.
  • Privacy: redact IDs/account numbers in logs; restrict execution visibility.
  • Scale: add MIME/size filters, duplicate detection, and multi-borrower folder patterns (parent → subfolders).

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Search a folder

Type / Role
n8n-nodes-base.microsoftOneDrive - microsoftOneDrive
Config choices
Version 1

Block 2 - Get items in a folder

Type / Role
n8n-nodes-base.microsoftOneDrive - microsoftOneDrive
Config choices
Version 1

Block 3 - Download a file

Type / Role
n8n-nodes-base.microsoftOneDrive - microsoftOneDrive
Config choices
Version 1

Block 4 - Extract text

Type / Role
n8n-nodes-base.mistralAi - mistralAi
Config choices
Version 1

Block 5 - Classify the File

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 6 - Combine the Data

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 7 - AI Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 2.2

Block 8 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Block 9 - When clicking ‘Execute workflow’

Type / Role
n8n-nodes-base.manualTrigger - manualTrigger
Config choices
Version 1

Block 10 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 11 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 12 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 13 - Loop Over Items

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 14 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 15 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 16 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 17 - Sticky Note6

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Automate loan document analysis with Mistral OCR and GPT for underwriting decisions
Complexity advanced
Nodes 17
Categories Document Extraction, AI Summarization
Author Vinay Gangidi
Published 30 Oct 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/10369/10369.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Automate loan document analysis with Mistral OCR and GPT for underwriting decisions do?

LOB Underwriting with AI This template ingests borrower documents from OneDrive, extracts text with OCR, classifies each file (ID, paystub, bank statement, utilities, tax forms, etc.), aggregates e...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Document Extraction, AI Summarization use case.