Extract structured data from D&B company reports with GPT-4o
Ready for 3.0Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-10-19.
Nodes used (6)
- OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - HTTP Request
n8n-nodes-base.httpRequest - Convert to File
n8n-nodes-base.convertToFile - Extract from File
n8n-nodes-base.extractFromFile - AI Agent
@n8n/n8n-nodes-langchain.agent - Structured Output Parser
@n8n/n8n-nodes-langchain.outputParserStructured
What it does
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) - Auth: Header Auth (use an n8n HTTP Header Auth credential) - URL: https://plus.dnb.com/v1/reports/duns/804735132?productId=birstd&inLanguage=en-US&reportFormat=PDF&orderReason=6332&tradeUp=hq&customerReference=customer%20reference%20text - Headers: - Accept: application/json - Credential Example: D&B (HTTP Header Auth) > Put your Authorization: Bearer <token> header inside this credential, not directly in the node. 2) Convert to PDF File (Convert to File) - Operation: toBinary - Source Property: contents0.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 ailanguageModel to Analyze PDF - Connect another OpenAI Chat Model (also gpt-4o) as ailanguageModel 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: json { "reportdate": "", "companyname": "", "duns": "", "dnbratingoverall": "", "compositecreditappraisal": "", "viabilityscore": "", "portfoliocomparisonscore": "", "paydex3mo": "", "paydex24mo": "", "creditlimitconservative": "" } - Auto Fix: enabled - Wiring: Connect as aioutputParser 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: - granttype = clientcredentials - Headers: - Accept: application/json - Downstream usage: Set header Authorization: Bearer {{$json"accesstoken"}} in subsequent calls. > In this template, the D&B Report node us