Skip to main content

Extract structured data from D&B company reports with GPT-4o

Workflow preview

Workflow preview
100%
Extract structured data from D&B company reports with GPT-4o preview
Open on n8n.io

Important notice

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

1. Workflow Overview

Pull a Dun & Bradstreet Business Information Report (PDF) by DUNS, convert the response into a binary PDF file , extract readable text, and use OpenAI to return a clean, flat JSON with only the key...

Best for

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

Tools used

n8n-nodes-base.stickynote, @n8n/n8n-nodes-langchain.lmchatopenai, n8n-nodes-base.httprequest, n8n-nodes-base.converttofile, n8n-nodes-base.extractfromfile, @n8n/n8n-nodes-langchain.agent, @n8n/n8n-nodes-langchain.outputparserstructured

Source and attribution

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

Original n8n.io source

1.1 Workflow description

Title
Extract structured data from D&B company reports with GPT-4o
Workflow name
Extract structured data from D&B company reports with GPT-4o

Pull a Dun & Bradstreet Business Information Report (PDF) by DUNS, convert the response into a binary PDF file, extract readable text, and use OpenAI to return a clean, flat JSON with only the key fields you care about (e.g., report date, Paydex, viability score, credit limit). Includes Sticky Notes for quick setup help and guidance.


βœ… What this template does

  • Requests a D&B report (PDF) for a specific DUNS via HTTP
  • Converts the API response into a binary PDF file
  • Extracts the text from the PDF for analysis
  • Uses OpenAI with a Structured Output Parser to return a flat JSON
  • Designed to be extended to Sheets, databases, or CRMs

🧩 How it works (node-by-node)

  1. Manual Trigger β€” Runs the workflow on demand ("When clicking 'Execute workflow'").
  2. D&B Report (HTTP Request) β€” Calls the D&B Reports API for a Business Information Report (PDF).
  3. Convert to PDF File (Convert to File) β€” Turns the D&B response payload into a binary PDF.
  4. Extract Binary (Extract from File) β€” Extracts text content from the PDF.
  5. OpenAI Chat Model β€” Provides the language model context for the analyzer.
  6. Analyze PDF (AI Agent) β€” Reads the extracted text and applies strict rules for a flat JSON output.
  7. Structured Output (AI Structured Output Parser) β€” Enforces a schema and validates/auto-fixes the JSON shape.
  8. (Optional) Get Bearer Token (HTTP Request) β€” Template guidance for OAuth token retrieval (shown as disabled; included for reference if you prefer Bearer flows).

πŸ› οΈ Setup instructions (from the JSON)

1) D&B Report (HTTP Request)

2) Convert to PDF File (Convert to File)

  • Operation: toBinary
  • Source Property: contents[0].contentObject
    > This takes the PDF content from the D&B API response and converts it to a binary file for downstream nodes.

3) Extract Binary (Extract from File)

  • Operation: pdf
    > Produces a text field with the extracted PDF content, ready for AI analysis.

4) OpenAI Model(s)

  • OpenAI Chat Model
  • Model: gpt-4o (as configured in the JSON)
  • Credential: Your stored OpenAI API credential (do not hardcode keys)
  • Wiring:
    • Connect OpenAI Chat Model as ai_languageModel to Analyze PDF
    • Connect another OpenAI Chat Model (also gpt-4o) as ai_languageModel to Structured Output

5) Analyze PDF (AI Agent)

  • Prompt Type: define
  • Text:
    ={{ $json.text }}
  • System Message (rules):
    • You are a precision extractor. Read the provided business report PDF and return only a single flat JSON object with the fields below.
    • No arrays/lists.
    • No prose.
    • If a value is missing, output null.
    • Dates: YYYY-MM-DD.
    • Numbers: plain numerics (no commas or $).
    • Prefer most recent or highest-level overall values if multiple are shown.
    • Never include arrays, nested structures, or text outside of the JSON object.

6) Structured Output (AI Structured Output Parser)

  • JSON Schema Example:
{
  "report_date": "",
  "company_name": "",
  "duns": "",
  "dnb_rating_overall": "",
  "composite_credit_appraisal": "",
  "viability_score": "",
  "portfolio_comparison_score": "",
  "paydex_3mo": "",
  "paydex_24mo": "",
  "credit_limit_conservative": ""
}
  • Auto Fix: enabled
  • Wiring: Connect as ai_outputParser to Analyze PDF

7) (Optional) Get Bearer Token (HTTP Request) β€” Disabled example

If you prefer fetching tokens dynamically:

  • Auth: Basic Auth (D&B username/password)
  • Method: POST
  • URL: https://plus.dnb.com/v3/token
  • Body Parameters:
    • grant_type = client_credentials
  • Headers:
    • Accept: application/json
  • Downstream usage: Set header Authorization: Bearer {{$json["access_token"]}} in subsequent calls.

> In this template, the D&B Report node uses Header Auth credential instead. Use one strategy consistently (credentials are recommended for security).


🧠 Output schema (flat JSON)

The analyzer + parser return a single flat object like:

{
  "report_date": "2024-12-31",
  "company_name": "Example Corp",
  "duns": "123456789",
  "dnb_rating_overall": "5A2",
  "composite_credit_appraisal": "Fair",
  "viability_score": "3",
  "portfolio_comparison_score": "2",
  "paydex_3mo": "80",
  "paydex_24mo": "78",
  "credit_limit_conservative": "25000"
}

πŸ§ͺ Test flow

  1. Click Execute workflow (Manual Trigger).
  2. Confirm D&B Report returns the PDF response.
  3. Check Convert to PDF File for a binary file.
  4. Verify Extract from File produces a text field.
  5. Inspect Analyze PDF β†’ Structured Output for valid JSON.

πŸ” Security notes

  • Do not hardcode tokens in nodes; use Credentials (HTTP Header Auth or Basic Auth).
  • Restrict who can execute the workflow if it's accessible from outside your network.
  • Avoid storing sensitive payloads in logs; mask tokens/headers.

🧩 Customize

  • Map the structured JSON to Google Sheets, Postgres/BigQuery, or a CRM.
  • Extend the schema with additional fields (e.g., number of employees, HQ address) β€” keep it flat.
  • Add validation (Set/IF nodes) to ensure required fields exist before writing downstream.

🩹 Troubleshooting

  • Missing PDF text? Ensure Convert to File source property is contents[0].contentObject.
  • Unauthorized from D&B? Refresh/verify token; confirm Header Auth credential contains Authorization: Bearer <token>.
  • Parser errors? Keep the agent output short and flat; the Structured Output node will auto-fix minor issues.
  • Different DUNS/product? Update the D&B Report URL query params (duns, productId, etc.).

πŸ—’οΈ Sticky Notes (included)

  • Overview: "Fetch D&B Company Report (PDF) β†’ Convert β†’ Extract β†’ Summarize to Structured JSON (n8n)"
  • Setup snippets for Data Blocks (optional) and Auth flow

πŸ“¬ Contact

Need help customizing this (e.g., routing the PDF to Drive, mapping JSON to your CRM, or expanding the schema)?

πŸ“§ [email protected]
πŸ”— https://www.linkedin.com/in/robert-breen-29429625/
🌐 https://ynteractive.com

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 - Sticky Note10

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

Block 2 - OpenAI Chat Model6

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

Block 3 - OpenAI Chat Model7

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

Block 4 - Sticky Note65

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

Block 5 - Sticky Note66

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

Block 6 - D&B Report

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

Block 7 - Convert to PDF File

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

Block 8 - Extract Binary

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

Block 9 - Analyze PDF

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

Block 10 - Structured Output

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

Block 11 - Get Token

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

3. Summary Table

Workflow Extract structured data from D&B company reports with GPT-4o
Complexity intermediate
Nodes 11
Categories Document Extraction, AI Summarization
Author Robert Breen
Published 23 Sept 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/8868/8868.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 Extract structured data from D&B company reports with GPT-4o do?

Pull a Dun & Bradstreet Business Information Report (PDF) by DUNS, convert the response into a binary PDF file , extract readable text, and use OpenAI to return a clean, flat JSON with only the key...

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.