This workflow corresponds to n8n.io template #8647 — we link there as the canonical source.
This workflow follows the Gmail → Gmail Trigger 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 →
{
"name": "Gmail \u2192 HubSpot Automation (Leads to Contacts & Deals)",
"nodes": [
{
"name": "Gmail Trigger",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
-480,
-64
],
"parameters": {
"simple": false,
"filters": {},
"options": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"typeVersion": 1.2
},
{
"name": "Get a message",
"type": "n8n-nodes-base.gmail",
"position": [
-208,
-16
],
"parameters": {
"simple": false,
"options": {},
"messageId": "={{ $json.id }}",
"operation": "get"
},
"typeVersion": 2.1
},
{
"name": "Extract From Email",
"type": "n8n-nodes-base.function",
"position": [
-544,
224
],
"parameters": {
"functionCode": "let fromEmail = $json.from?.value?.[0]?.address || null;return [{ json: { ...$json, extractedFromEmail: fromEmail } }];"
},
"typeVersion": 1
},
{
"name": "If Sender is Shopify",
"type": "n8n-nodes-base.if",
"position": [
-320,
224
],
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $json.extractedFromEmail }}",
"value2": "user@example.com"
}
]
}
},
"typeVersion": 1
},
{
"name": "Code",
"type": "n8n-nodes-base.code",
"position": [
-480,
448
],
"parameters": {
"jsCode": "const rawText = $json.text || $json.from?.text || null; if (!rawText) throw new Error('Email body not found.'); const cleanMessage = rawText.replace(/\\r?\\n|\\r/g, ' ').replace(/\\s+/g, ' '); const nameMatch = cleanMessage.match(/Name:\\s*(.*?)\\s*Email:/i); const emailMatch = cleanMessage.match(/Email:\\s*(.*?)\\s*City:/i); const cityMatch = cleanMessage.match(/City:\\s*(.*?)\\s*Phone:/i); const phoneMatch = cleanMessage.match(/Phone:\\s*(.*?)\\s*Body:/i); const bodyMatch = cleanMessage.match(/Body:\\s*(.*?)\\s*(Product Url:|Product Title:|$)/i); const urlMatch = cleanMessage.match(/Product Url:\\s*(.*?)\\s*(Product Title:|$)/i); const titleMatch = cleanMessage.match(/Product Title:\\s*(.*)/i); return [{ json: { name: nameMatch?.[1]?.trim() || null, email: emailMatch?.[1]?.trim() || null, city: cityMatch?.[1]?.trim() || null, phone: phoneMatch?.[1]?.trim() || null, body: bodyMatch?.[1]?.trim() || null, product_url: urlMatch?.[1]?.trim() || null, product_title: titleMatch?.[1]?.trim() || null } }];"
},
"typeVersion": 2
},
{
"name": "Edit Fields",
"type": "n8n-nodes-base.set",
"position": [
-208,
448
],
"parameters": {
"assignments": {
"assignments": [
{
"name": "name",
"type": "string",
"value": "={{ $json.name }}"
},
{
"name": "email",
"type": "string",
"value": "={{ $json.email }}"
},
{
"name": "city",
"type": "string",
"value": "={{ $json.city }}"
},
{
"name": "phone",
"type": "string",
"value": "={{ $json.phone }}"
},
{
"name": "body",
"type": "string",
"value": "={{ $json.body }}"
},
{
"name": "product_title",
"type": "string",
"value": "={{ $json.product_title }}"
},
{
"name": "product_url",
"type": "string",
"value": "={{ $json.product_url }}"
}
]
}
},
"typeVersion": 3.4
},
{
"name": "Create or update a contact",
"type": "n8n-nodes-base.hubspot",
"position": [
-96,
208
],
"parameters": {
"email": "={{ $json.email }}",
"options": {},
"authentication": "appToken",
"additionalFields": {
"city": "={{ $json.city }}",
"firstName": "={{ $json.name }}",
"websiteUrl": "interwood.pk",
"mobilePhoneNumber": "={{ $json.phone }}"
}
},
"typeVersion": 2.1
},
{
"name": "Create a deal",
"type": "n8n-nodes-base.hubspot",
"position": [
-16,
448
],
"parameters": {
"stage": "YOUR_STAGE_ID",
"resource": "deal",
"authentication": "appToken",
"additionalFields": {
"amount": "5",
"dealName": "={{ $json.name }}",
"description": "={{ $('Edit Fields').item.json.body }} of {{ $('Edit Fields').item.json.product_title }}",
"associatedVids": [
"={{ $json.vid }}"
],
"customPropertiesUi": {
"customPropertiesValues": [
{
"value": "Website",
"property": "campaign"
},
{
"value": "={{ $('Edit Fields').item.json.body }} of {{ $('Edit Fields').item.json.product_title }}",
"property": "message"
}
]
}
}
},
"typeVersion": 2.1
},
{
"name": "Sticky: Gmail Trigger",
"type": "n8n-nodes-base.stickyNote",
"position": [
-700,
-120
],
"parameters": {
"width": 360,
"height": 160,
"content": "## Gmail Trigger\nPolls Gmail every minute and emits new emails into the flow."
},
"typeVersion": 1
},
{
"name": "Sticky: Get Message",
"type": "n8n-nodes-base.stickyNote",
"position": [
-60,
-120
],
"parameters": {
"width": 360,
"height": 160,
"content": "## Get Message\nFetches full email (body + metadata) for parsing."
},
"typeVersion": 1
},
{
"name": "Sticky: Extract From Email",
"type": "n8n-nodes-base.stickyNote",
"position": [
-760,
170
],
"parameters": {
"width": 380,
"height": 160,
"content": "## Extract From Email\nPulls sender address used for filtering/routing."
},
"typeVersion": 1
},
{
"name": "Sticky: Shopify Filter",
"type": "n8n-nodes-base.stickyNote",
"position": [
-140,
170
],
"parameters": {
"width": 360,
"height": 160,
"content": "## If Sender is Shopify\nProcesses only emails from Shopify (change to your source if needed)."
},
"typeVersion": 1
},
{
"name": "Sticky: Parser",
"type": "n8n-nodes-base.stickyNote",
"position": [
-700,
520
],
"parameters": {
"width": 420,
"height": 200,
"content": "## Code (Regex Parser)\nExtracts: name, email, city, phone, message, product_url, product_title.\nAdjust regex if your email format differs."
},
"typeVersion": 1
},
{
"name": "Sticky: Normalize",
"type": "n8n-nodes-base.stickyNote",
"position": [
-20,
520
],
"parameters": {
"width": 380,
"height": 180,
"content": "## Edit Fields\nNormalizes extracted values into clean JSON for HubSpot."
},
"typeVersion": 1
},
{
"name": "Sticky: HubSpot Contact",
"type": "n8n-nodes-base.stickyNote",
"position": [
-300,
80
],
"parameters": {
"width": 420,
"height": 180,
"content": "## HubSpot Contact\nCreates/updates a Contact (email, name, phone, city)."
},
"typeVersion": 1
},
{
"name": "Sticky: HubSpot Deal",
"type": "n8n-nodes-base.stickyNote",
"position": [
160,
520
],
"parameters": {
"width": 440,
"height": 200,
"content": "## HubSpot Deal\nCreates a Deal linked to the Contact.\nSet your pipeline stage (replace `YOUR_STAGE_ID`)."
},
"typeVersion": 1
}
],
"active": true,
"settings": {
"executionOrder": "v1"
},
"connections": {
"Code": {
"main": [
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields": {
"main": [
[
{
"node": "Create or update a contact",
"type": "main",
"index": 0
}
]
]
},
"Get a message": {
"main": [
[
{
"node": "Extract From Email",
"type": "main",
"index": 0
}
]
]
},
"Gmail Trigger": {
"main": [
[
{
"node": "Get a message",
"type": "main",
"index": 0
}
]
]
},
"Extract From Email": {
"main": [
[
{
"node": "If Sender is Shopify",
"type": "main",
"index": 0
}
]
]
},
"If Sender is Shopify": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"Create or update a contact": {
"main": [
[
{
"node": "Create a deal",
"type": "main",
"index": 0
}
]
]
}
}
}
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This workflow automatically processes incoming Shopify/Gmail leads and pushes them into HubSpot as both Contacts and Deals.
Source: https://n8n.io/workflows/8647/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
When a property portal sends a lead notification to your Gmail, this workflow parses the email with Gemini AI, qualifies the lead, sends an instant acknowledgment, creates a HubSpot contact and deal i
This project automates the process of collecting and managing new leads submitted through a web form. It eliminates the need for manual data entry and ensures that each lead is: Properly recorded and
This workflow starts whenever a new lead submits a Typeform. It captures the lead’s details, checks their budget, and routes them based on priority and source. High-budget leads are pushed into HubSpo
Who is this for? Event sales teams & conference organizers processing 100+ sponsor/partner emails weekly who need instant lead qualification, Salesforce automation, & pipeline analytics. _
Email Sentiment Router for Event Sales Leads