Skip to main content

Generate M&A due diligence PDF reports with LlamaIndex, OpenAI, Pinecone, and S3

Workflow preview

Workflow preview
100%
Generate M&A due diligence PDF reports with LlamaIndex, OpenAI, Pinecone, and S3 preview
Open on n8n.io

1. Workflow Overview

Streamline M&A due diligence with AI. This n8n workflow automatically parses financial documents using LlamaIndex, embeds data into Pinecone, and generates comprehensive, AI driven reports with GPT...

Best for

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

Tools used

n8n-nodes-base.httprequest, n8n-nodes-base.stickynote, n8n-nodes-base.webhook, n8n-nodes-base.code, n8n-nodes-base.splitinbatches, @n8n/n8n-nodes-langchain.vectorstorepinecone, @n8n/n8n-nodes-langchain.embeddingsopenai, @n8n/n8n-nodes-langchain.documentdefaultdataloader

Source and attribution

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

Original n8n.io source

1.1 Workflow description

Title
Generate M&A due diligence PDF reports with LlamaIndex, OpenAI, Pinecone, and S3
Workflow name
Generate M&A due diligence PDF reports with LlamaIndex, OpenAI, Pinecone, and S3

Streamline M&A due diligence with AI. This n8n workflow automatically parses financial documents using LlamaIndex, embeds data into Pinecone, and generates comprehensive, AI-driven reports with GPT-5-mini, saving hours of manual review and ensuring consistent, data-backed insights.

Why Use This Workflow?

Time Savings: Reduces manual document review and report generation from days to minutes. Cost Reduction: Minimizes reliance on expensive human analysts for initial data extraction and summary. Error Prevention: AI-driven analysis ensures consistent data extraction, reducing human error and oversight. Scalability: Effortlessly processes multiple documents and deals in parallel, scaling with your business needs.

Ideal For

  • Investment Analysts & Private Equity Firms: Quickly evaluate target companies by automating the extraction of key financials, risks, and business models from deal documents.
  • M&A Advisors: Conduct preliminary due diligence efficiently, generating comprehensive overview reports for clients without extensive manual effort.
  • Financial Professionals: Accelerate research and analysis of company filings, investor presentations, and market reports for critical decision-making.

How It Works

  1. Trigger: A webhook receives multiple due diligence documents (PDFs, DOCX, XLSX) along with associated metadata.
  2. Document Processing & Cache Check: Files are split individually. The workflow first checks Pinecone to see if the deal's documents have been processed before (cache hit). If so, it skips parsing and embedding.
  3. Data Extraction (LlamaIndex): For new deals, each document is sent to LlamaIndex for advanced parsing, extracting structured text content.
  4. Vectorization & Storage: The parsed text is then converted into numerical vector embeddings using OpenAI and stored in Pinecone, our vector database, with relevant metadata.
  5. AI-Powered Analysis (Langchain Agent): An n8n Langchain Agent, acting as a "Senior Investment Analyst," leverages GPT-5-mini to query Pinecone multiple times for specific information (e.g., company profile, financials, risks, business model). It synthesizes these findings into a structured JSON output.
  6. Report Generation: The structured AI output is transformed into an HTML report, then converted into a professional PDF document.
  7. Secure Storage & Delivery: The final PDF due diligence report is uploaded to an S3 bucket, and a public URL is returned via the initial webhook, providing instant access.

Setup Guide

Prerequisites

Requirement Type Purpose
n8n instance Essential Workflow execution platform
LlamaIndex API Key Essential For robust document parsing and text extraction
OpenAI API Key Essential For creating text embeddings and powering the GPT-5-mini AI agent
Pinecone API Key Essential For storing and retrieving vector embeddings
AWS S3 Account Essential For secure storage of generated PDF reports

Installation Steps

  1. Import the JSON file to your n8n instance.
  2. Configure credentials:
  • LlamaIndex: Create an "HTTP Header Auth" credential with x-api-key in the header and your LlamaIndex API key as the value.
  • OpenAI: Create an "OpenAI API" credential with your OpenAI API key. Ensure the credential name is "Sumopod" or update the workflow nodes accordingly.
  • Pinecone: Create a "Pinecone API" credential with your Pinecone API key and environment. Ensure the credential name is "w3khmuhtadin" or update the workflow nodes accordingly.
  • AWS S3: Create an "AWS S3" credential with your Access Key ID and Secret Access Key.
  1. Update environment-specific values:
  • In the "Upload to S3" node, ensure the bucketName is set to your desired S3 bucket.
  • In the "Create Public URL" node, update the baseUrl variable to match your S3 bucket's public access URL or CDN if applicable (e.g., https://your-s3-bucket-name.s3.amazonaws.com).
  1. Customize settings:
  • Review the prompt in the "Analyze" (Langchain Agent) node to adjust the AI's persona or required queries if needed.
  1. Test execution:
  • Send sample documents (PDF, DOCX, XLSX) to the webhook URL (/webhook/dd-ai) to verify all connections and processing steps work as expected.

Technical Details

Core Nodes

Node Purpose Key Configuration
Webhook Initiates workflow with document uploads Path: dd-ai, HTTP Method: POST
Split Multi-File (Code) Splits binary files, generates unique deal ID Parses filenames from body or binary, creates dealId from sorted names.
Parse Document via LlamaIndex Extracts structured text from various document types URL: https://api.cloud.llamaindex.ai/api/v1/parsing/upload, Authentication: HTTP Header Auth with x-api-key.
Monitor Document Processing Polls LlamaIndex for parsing status URL: https://api.cloud.llamaindex.ai/api/v1/parsing/job/{{ $json.id }}, Authentication: HTTP Header Auth.
Insert to Pinecone Stores vector embeddings in Pinecone Mode: insert, Pinecone Index: poc, Pinecone Namespace: dealId.
Data Retrieval (Pinecone) Enables AI agent to search due diligence documents Mode: retrieve-as-tool, Pinecone Index: poc, Pinecone Namespace: {{ $json.dealId }}, topK: 100.
Analyze (Langchain Agent) Orchestrates AI analysis using specific queries Prompt Type: define, detailed role and 6 mandatory Pinecone queries, Model: gpt-5-mini, Output Parser: Parser.
Generate PDF (Puppeteer) Converts HTML report to a professional PDF Script Code: await $page.pdf(...) with A4 format, margins, and 60s timeout.
Upload to S3 Stores final PDF reports securely Bucket Name: poc, File Name: {{ $json.fileName }}, Credentials: AWS S3.
If (Check Namespace Exists) Implements caching logic Checks stats.namespaces[dealId].vectorCount > 0 to determine cache hit/miss.

Workflow Logic

The workflow begins by accepting multiple files via a webhook. It intelligently checks if the specific "deal" (identified by a unique ID generated from filenames) has already had its documents processed and embedded in Pinecone. This cache mechanism prevents redundant processing, saving time and API costs. If a cache miss occurs, documents are parsed by LlamaIndex, their content vectorized by OpenAI, and stored in a Pinecone namespace unique to the deal.

For analysis, a Langchain Agent, powered by GPT-5-mini, is instructed with a specific persona and a mandatory sequence of Pinecone queries (e.g., company overview, financials, risks). It uses the Data Retrieval tool to interact with Pinecone, synthesizing information from the stored embeddings. The AI's output is then structured by a dedicated parser, transformed into a human-readable HTML report, and converted into a PDF. Finally, this comprehensive report is uploaded to AWS S3, and a public access URL is provided as a response.

Customization Options

Basic Adjustments:

  • AI Prompt Refinement: Modify the Prompt field in the "Analyze" (Langchain Agent) node to adjust the AI's persona, introduce new mandatory queries, or change reporting style.
  • Output Schema: Update the JSON schema in the "Parser" (Langchain Output Parser Structured) node to include additional fields or change the structure of the AI's output.

Advanced Enhancements:

  • Integration with CRM/Dataroom: Add nodes to automatically fetch documents from or update status in a CRM (e.g., Salesforce, HubSpot) or a virtual data room (e.g., CapLinked, Datasite).
  • Conditional Analysis: Implement logic to trigger different analysis paths or generate different report sections based on document content or deal parameters.
  • Notification System: Integrate with Slack, Microsoft Teams, or email to send notifications upon report generation or specific risk identification.

Use Case Examples

Scenario 1: Private Equity Firm Evaluating a Target Company

Challenge: A private equity firm receives dozens of due diligence documents (financials, CIM, management presentations) for a potential acquisition, needing a rapid initial assessment. Solution: The workflow ingests all documents, automatically parses them, and an AI agent synthesizes key company information, financial summaries (revenue history, margins), and identified risks into a structured report within minutes. Result: The firm's analysts gain an immediate, comprehensive overview, enabling faster screening and more focused deep-dive questions, significantly accelerating the deal cycle.

Scenario 2: M&A Advisor Conducting Preliminary Due Diligence

Challenge: An M&A advisory firm needs to provide clients with a quick, consistent, and standardized preliminary due diligence report across multiple prospects. Solution: Advisors upload relevant prospect documents to the workflow. The AI-powered system automatically extracts core business model details, investment thesis highlights, and customer concentration analysis, along with key financials. Result: The firm can generate standardized, high-quality preliminary reports efficiently, ensuring consistency across all client engagements and freeing up senior staff for strategic analysis.


Created by: Khmuhtadin Category: AI | Tags: Due Diligence, AI, Automation, M&A, LlamaIndex, Pinecone, GPT-5-mini, Document Processing Need custom workflows? Contact us

Connect with the creator: PortfolioWorkflowsLinkedInMediumThreads

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 - Retrieve Parsed Content

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 2 - Sticky Note

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

Block 3 - Receive Upload Request

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 2.1

Block 4 - Split Uploaded Files + Build Deal ID

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

Block 5 - Iterate Files for Parsing

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

Block 6 - Get Pinecone Index Stats

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.3

Block 7 - Upsert Chunks to Pinecone

Type / Role
@n8n/n8n-nodes-langchain.vectorStorePinecone - vectorStorePinecone
Config choices
Version 1.3

Block 8 - Generate Embeddings (Ingest)

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

Block 9 - Prepare Parsed Text Document

Type / Role
@n8n/n8n-nodes-langchain.documentDefaultDataLoader - documentDefaultDataLoader
Config choices
Version 1.1

Block 10 - Collect Ingested Deal IDs

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

Block 11 - Prepare Analysis Context

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

Block 12 - Run Due Diligence AI Analysis

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

Block 13 - OpenAI Chat Model (5-mini)

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

Block 14 - Parse Structured Analysis JSON

Type / Role
@n8n/n8n-nodes-langchain.outputParserStructured - outputParserStructured
Config choices
Version 1.3

Block 15 - Retrieve Context from Pinecone

Type / Role
@n8n/n8n-nodes-langchain.vectorStorePinecone - vectorStorePinecone
Config choices
Version 1.3

Block 16 - Generate Embeddings (Retrieval)

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

Block 17 - Map Analysis to Report Fields

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

Block 18 - Render DD Report HTML

Type / Role
n8n-nodes-base.html - html
Config choices
Version 1.2

Block 19 - Render PDF from HTML

Type / Role
n8n-nodes-puppeteer.puppeteer - puppeteer
Config choices
Version 1

Block 20 - Convert PDF Base64 to Binary File

Type / Role
n8n-nodes-base.convertToFile - convertToFile
Config choices
Version 1.1

Block 21 - Upload Report PDF to S3

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

Block 22 - Build Public Report URL

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

Block 23 - Merge Analysis + Report URL

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3.2

Block 24 - Is Parsing Job Complete?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Showing the first 24 of 39 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Generate M&A due diligence PDF reports with LlamaIndex, OpenAI, Pinecone, and S3
Complexity advanced
Nodes 39
Categories Document Extraction, AI RAG
Author Khairul Muhtadin
Published 13 Feb 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/13364/13364.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 Generate M&A due diligence PDF reports with LlamaIndex, OpenAI, Pinecone, and S3 do?

Streamline M&A due diligence with AI. This n8n workflow automatically parses financial documents using LlamaIndex, embeds data into Pinecone, and generates comprehensive, AI driven reports with GPT...

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 RAG use case.