AI-Powered Contact Data Extraction and JSON Formatting - n8n Workflow

Use this powerful n8n workflow template to convert unstructured contact data (emails, forms) into clean, structured JSON using an AI agent. Essential for CRM integration.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

CRM Administrators needing to automate data entry.
System Integrators looking for a reliable way to clean external data streams.
Developers building microservices where unstructured text must be converted to JSON.
Users seeking powerful, pre-built n8n templates for AI data processing.


  • Anyone utilizing the n8n platform for advanced data transformation tasks.

Overview

Integrating free-form, unstructured contact data—often found in emails or support requests—into strict database systems like CRMs or ERPs is a significant challenge. This specialized n8n workflow solves this by utilizing an advanced AI Agent powered by OpenAI. The automation takes a block of text via a Webhook n8n trigger, applies stringent extraction rules defined in the prompt, and outputs a perfectly formatted JSON object containing specific fields (e.g., firstname, companyname, email). This high-utility n8n template is designed to ensure data integrity and significantly reduce manual data entry errors, making it an indispensable tool for business process automation within your n8n environment. Every component, especially the custom Code n8n node, is engineered to guarantee clean, structured output.

How it Works

This n8n workflow begins with an external call, making it a highly flexible n8n template for system integration:


  1. Incoming Data (Webhook n8n Trigger): The n8n workflow is activated by an HTTP POST request to the configured Webhook path (contactdataconverter). This external system sends the unstructured contact information in the request body under the key prompt.

  2. AI Extraction (AI Agent n8n node): The received text is passed to the AI Agent n8n node, which is configured with detailed extraction rules. These rules instruct the underlying language model (OpenAI Chat Model) to strictly extract defined fields (like address, telephone, email) and adhere to a specific output JSON structure, leaving missing fields as empty strings ("").

  3. Language Model Connection: The AI Agent utilizes the configured OpenAI Chat Model n8n node to perform the heavy lifting of language understanding and extraction, leveraging powerful models like GPT-4 (or the configured alternative).

  4. JSON Cleaning and Parsing (Code n8n node): The raw output from the AI often includes markdown formatting (e.g., ```json... ``). The Code n8n node meticulously strips away these extraneous characters, validates the remaining string, and then parses it into a native n8n JSON object. This ensures the data is truly structured and usable downstream.

  5. Response: Finally, the structured, cleaned JSON object is returned to the initiating system using the Respond to Webhook` n8n node, completing the automation cycle.

Installation Guide

To install and utilize this n8n template, follow these steps:


  1. Import the n8n Workflow: Copy the provided JSON data and paste it into your n8n instance using the 'New' menu -> 'Import from JSON'.

  2. Set Up OpenAI Credentials: This n8n workflow requires credentials for the OpenAI Chat Model n8n node. Navigate to Settings > Credentials in n8n, add your OpenAI API key, and link it to the relevant node.

  3. Activate the Webhook: After importing, ensure the Webhook n8n trigger node is active. Save the workflow and retrieve the full testing or production URL provided by the n8n trigger.

  4. Testing: Send an HTTP POST request containing unstructured contact data to the Webhook URL. The body must be a JSON object containing the input text under the key prompt (e.g., {"prompt": "John Doe works for Acme Corp. Call him at 555-1234. His email is [email protected]."}).

Node Details

This n8n workflow relies on three main functional components, plus the trigger and response n8n nodes:

Webhook (n8n Trigger): Serves as the immediate n8n trigger. It listens for a POST request on the path /contactdataconverter, accepting the unstructured input text.
AI Agent (LangChain Integration n8n node): The core intelligence of this n8n template. It receives the input text and follows highly specific instructions to perform targeted information extraction, ensuring strict adherence to the defined output JSON schema.
OpenAI Chat Model (LangChain Integration n8n node): Provides the large language model backend (e.g., GPT-4) necessary for the AI Agent to process and structure the complex text data.
Code (n8n node): This crucial parsing n8n node cleans the AI output. It strips markdown fences (like ```json and ````) that the LLM may include, ensuring the final output is a valid, machine-readable JSON object, preventing integration errors in subsequent steps of the n8n workflow.


  • Respond to Webhook (n8n node): Sends the final, structured JSON data back to the originating external system.

Related n8n Workflows

Free

Nodes: 6 Nodes
Updated: December 26 2025
View all
Created by
Frankie Wong
Frankie Wong

With over 10 years of experience in customizing open-source platforms like Dolibarr, WordPress, OpenCart and Shopify, I now specialize in building powerful and practical workflow automations and AI agents using n8n. Whether you're looking to save time, streamline operations, or integrate AI into your business processes, I create ready-to-use n8n templates designed to make automation easy. Based in Birmingham, UK

Featured*