AutomationFlowsAI & RAG › Convert Unstructured Contact Data to JSON with Gpt-4 for System Integration

Convert Unstructured Contact Data to JSON with Gpt-4 for System Integration

ByFrankie Wong @frankiewong on n8n.io

This workflow contains community nodes that are only compatible with the self-hosted version of n8n.

Webhook trigger★★★★☆ complexityAI-powered9 nodesAgentOpenAI Chat
AI & RAG Trigger: Webhook Nodes: 9 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #6779 — we link there as the canonical source.

This workflow follows the Agent → OpenAI Chat recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "Q94SsUmoQurlkhBF",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Public Template - Extract Contact Information",
  "tags": [],
  "nodes": [
    {
      "id": "d5432499-566f-4829-9aa7-dc74ce6f2275",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -176,
        0
      ],
      "parameters": {
        "path": "contact_data_converter",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2
    },
    {
      "id": "fc8b683a-2069-4823-8220-d7eb3592e42f",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        928,
        0
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "7af49992-dbe3-4034-adc9-ca1b8fd523da",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        112,
        0
      ],
      "parameters": {
        "text": "=Extract the following fields from the input text. Follow these rules strictly:\n\n**EXTRACTION RULES:**\n1. Only extract information that is explicitly stated in the text\n2. Do not infer, guess, or make assumptions\n3. If a field is missing, ambiguous, or uncertain, leave it as an empty string \"\"\n4. Extract information exactly as written (preserve original formatting for addresses, phone numbers, etc.)\n5. For names: only extract if clearly identified as a person's name (not just any name in the text)\n6. For company names: look for business names, organization names, or company identifiers\n\n**FIELD DEFINITIONS:**\n- **company_name**: Business or organization name\n- **tel**: Phone/telephone number (any format)\n- **fax**: Fax number (any format)\n- **email**: Email address\n- **first_name**: Person's first/given name\n- **last_name**: Person's last/family name\n- **address**: Street address or mailing address\n- **zipcode**: Postal/ZIP code\n- **city**: City name\n- **country**: Country name\n- **website**: Website URL or domain\n\n**OUTPUT FORMAT:**\nReturn only valid JSON with exactly these keys (no additional text or explanation):\n\n{\n  \"company_name\": \"\",\n  \"tel\": \"\",\n  \"fax\": \"\",\n  \"email\": \"\",\n  \"first_name\": \"\",\n  \"last_name\": \"\",\n  \"address\": \"\",\n  \"zipcode\": \"\",\n  \"city\": \"\",\n  \"country\": \"\",\n  \"website\": \"\"\n}\n\n**INPUT TEXT:**\n{{ $json.body.prompt }}\n\n\n",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2.1
    },
    {
      "id": "dfe113b0-8259-4432-a672-7b8f2b29c250",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        608,
        0
      ],
      "parameters": {
        "jsCode": "return items.map(item => {\n  let jsonStr = item.json.output;\n  jsonStr = jsonStr.replace(/^```json\\n?/, '').replace(/\\n?```$/, '');\n  \n  try {\n    const parsed = JSON.parse(jsonStr);\n    return {\n      json: {\n        output: parsed\n      }\n    };\n  } catch (error) {\n    throw new Error('Invalid JSON string: ' + error.message);\n  }\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "857a4ac8-0dc8-4e11-b5f2-b5c64868b121",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        112,
        272
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-nano",
          "cachedResultName": "gpt-4.1-nano"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "0a79b2ec-67f9-4e4d-9303-d3e34f9bfd3d",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -832,
        -304
      ],
      "parameters": {
        "width": 480,
        "height": 480,
        "content": "## Contact Data Converter \u2013 Unstructured Text to JSON for System Integration\n\nThis n8n workflow converts unstructured contact information\u2014such as customer details from emails or messages\u2014into structured JSON data using an AI agent.\n\nIt extracts key fields like Company Name, Address, Phone, Email, First Name, Last Name, etc.\n\nThe structured output is ideal for seamless integration into CRM / ERP systems like Dolibarr, or any other system that accepts JSON input.\n\nWhether you're automating CRM data entry or syncing contacts into your ERP, this template saves time and reduces manual errors."
      },
      "typeVersion": 1
    },
    {
      "id": "50fc716f-d92c-4a52-91ee-6ced006dda1e",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -272,
        -192
      ],
      "parameters": {
        "color": 4,
        "width": 288,
        "height": 368,
        "content": "This webhook acts as the entry point for the workflow.\n\nIt accepts an HTTP POST request containing unstructured contact information (e.g., the body of an email) in the request body under the key **\"prompt\"**"
      },
      "typeVersion": 1
    },
    {
      "id": "485ce0f8-4259-4419-8fe6-8ce70fcbb0f6",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        -304
      ],
      "parameters": {
        "color": 4,
        "width": 336,
        "height": 480,
        "content": "This node uses an AI agent to extract structured contact information from the unstructured input text.\n\nThe input text is passed from the previous Webhook node using: {{ $json.body.prompt }}\n\nThe AI prompt can be customized to fit your specific use case or formatting needs.\n\nYou can adjust the instructions in the prompt to tailor the output fields, structure, or style of the resulting JSON."
      },
      "typeVersion": 1
    },
    {
      "id": "08d1216e-fe9b-48d7-863f-30cafcb82936",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        -304
      ],
      "parameters": {
        "color": 4,
        "width": 352,
        "height": 480,
        "content": "This node processes the raw output from the AI Agent and ensures it\u2019s a valid JSON object.\n\nIt removes any Markdown-style code block formatting (e.g., json ... ) from the AI response.\n\nIt then parses the cleaned string into a proper JSON object.\n\nIf the AI output is not valid JSON, it will throw an error to help with debugging.\n\nThe parsed and structured data is returned under output, ready for use in downstream nodes or ERP system integration."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "f7d4d1c1-58e3-473a-8c17-10f73ce81e49",
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow contains community nodes that are only compatible with the self-hosted version of n8n.

Source: https://n8n.io/workflows/6779/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

⏺ 🚀 How it works

Agent, Anthropic Chat, Output Parser Structured +6
AI & RAG

L&D_AgentsAI_ATIVO. Uses httpRequest, agent, googleCalendarTool, toolSerpApi. Webhook trigger; 93 nodes.

HTTP Request, Agent, Google Calendar Tool +9
AI & RAG

CLINICAINTEGRAL_secretary. Uses postgres, mcpClientTool, googleDriveTool, toolWorkflow. Webhook trigger; 89 nodes.

Postgres, Mcp Client Tool, Google Drive Tool +14
AI & RAG

Remi 1.1. Uses lmChatOpenAi, memoryPostgresChat, openAi, postgres. Webhook trigger; 89 nodes.

OpenAI Chat, Memory Postgres Chat, OpenAI +7
AI & RAG

This n8n workflow orchestrates a powerful suite of AI Agents and automations to manage and optimize various aspects of an e-commerce operation, particularly for platforms like Shopify. It leverages La

Google Sheets, HTTP Request, Slack +10