Parse Email Content
n8n-nodes-base.code
Extract structured data from email content using regex patterns and natural language processing. Great for automating email workflows.
π‘ Use Cases
- Extract order details from confirmation emails
- Parse invoice information
- Extract contact info from signatures
π Node Configuration
{
"nodes": [
{
"parameters": {
"content": "## π§ Email Content Parser\n\n**Usage:**\nExtracts structured data from email content using regex patterns.\n\n**Required Input:**\n- `body`: Email body text\n\n**Setup:**\n1. No credentials needed\n2. Pass email body in incoming data\n3. Code node extracts emails, phones, URLs, order numbers\n\n**Output:**\nJSON object with extracted data arrays and original content",
"height": 238,
"width": 389,
"color": 4
},
"type": "n8n-nodes-base.stickyNote",
"position": [
96,
332
],
"typeVersion": 1,
"id": "sticky-e5d4c3b2-a1f0-4e5f-8d9c-0a1b2c3d4e5f",
"name": "Sticky Note"
},
{
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "// Parse email content and extract structured data\nconst emailBody = $input.item.json.body || '';\n\n// Extract email address\nconst emailRegex = /([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\\.[a-zA-Z0-9_-]+)/gi;\nconst emails = emailBody.match(emailRegex) || [];\n\n// Extract phone numbers\nconst phoneRegex = /(\\+?\\d{1,3}[-.\\s]?)?\\(?\\d{3}\\)?[-.\\s]?\\d{3}[-.\\s]?\\d{4}/g;\nconst phones = emailBody.match(phoneRegex) || [];\n\n// Extract URLs\nconst urlRegex = /(https?:\\/\\/[^\\s]+)/g;\nconst urls = emailBody.match(urlRegex) || [];\n\n// Extract order numbers (example pattern)\nconst orderRegex = /(?:order|invoice)\\s*#?\\s*([A-Z0-9-]+)/gi;\nconst orders = [];\nlet match;\nwhile ((match = orderRegex.exec(emailBody)) !== null) {\n orders.push(match[1]);\n}\n\nreturn {\n json: {\n originalBody: emailBody,\n extractedData: {\n emails: [...new Set(emails)],\n phones: [...new Set(phones)],\n urls: [...new Set(urls)],\n orderNumbers: [...new Set(orders)]\n },\n parsedAt: new Date().toISOString()\n }\n};"
},
"id": "e5d4c3b2-a1f0-4e5f-8d9c-0a1b2c3d4e5f",
"name": "Parse Email Content",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
368,
400
]
}
],
"connections": {},
"pinData": {},
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "751aeba95f3d1aebe5a6ebe9d20293dd6c0f61b00ef369c580f0dc54913f5fcb"
}
}
BuildShip configuration not available for this node.
Make.com configuration not available for this node.