My workflow
Shared 12/8/2025
1 views
Visual Workflow
JSON Code
{
"id": "mJHKV4afO6ACpOT1",
"meta": {
"instanceId": "c3d3da890e44310c48ae288dd5d2b3d3ed54f24492f883b558024dcd2ab22ce6"
},
"name": "My workflow",
"tags": [],
"nodes": [
{
"id": "db24c3f7-332c-4366-8d62-f6e4c489d544",
"name": "Webhook Trigger",
"type": "n8n-nodes-base.webhook",
"position": [
2592,
256
],
"webhookId": "46f84f0e-1a1e-45fb-8e70-626c9f487df6",
"parameters": {
"path": "shopify-cta-audit",
"options": {},
"httpMethod": "POST",
"responseMode": "lastNode"
},
"typeVersion": 2.1
},
{
"id": "116a43dd-dddd-4588-a937-66b2a1dff069",
"name": "Workflow Configuration",
"type": "n8n-nodes-base.set",
"position": [
2816,
256
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "id-1",
"name": "shopifyStore",
"type": "string",
"value": "<__PLACEHOLDER_VALUE__Your Shopify store domain (e.g., yourstore.myshopify.com)__>"
},
{
"id": "id-2",
"name": "shopifyAccessToken",
"type": "string",
"value": "<__PLACEHOLDER_VALUE__Shopify Admin API Access Token__>"
},
{
"id": "id-3",
"name": "browserlessToken",
"type": "string",
"value": "<__PLACEHOLDER_VALUE__Browserless API Token__>"
},
{
"id": "id-4",
"name": "googlePageSpeedKey",
"type": "string",
"value": "<__PLACEHOLDER_VALUE__Google PageSpeed API Key__>"
}
]
},
"includeOtherFields": true
},
"typeVersion": 3.4
},
{
"id": "f419b5f3-165f-49cc-838a-8ba89674134f",
"name": "Extract Handle",
"type": "n8n-nodes-base.code",
"position": [
3040,
256
],
"parameters": {
"jsCode": "const url = $json.url;\nconst path = new URL(url).pathname;\nconst parts = path.split('/');\nconst handle = parts[parts.length - 1];\nreturn [{ json: { url, handle } }];"
},
"typeVersion": 2
},
{
"id": "d468e08f-4564-4996-9b15-02df00fef252",
"name": "Shopify Get Product",
"type": "n8n-nodes-base.httpRequest",
"position": [
3264,
256
],
"parameters": {
"url": "={{ 'https://' + $('Workflow Configuration').first().json.shopifyStore + '/admin/api/2024-01/graphql.json' }}",
"method": "POST",
"options": {},
"jsonBody": "={\n \"query\": \"query($handle:String!){productByHandle(handle:$handle){id title descriptionHtml onlineStoreUrl totalInventory}}\",\n \"variables\": {\n \"handle\": \"={{ $json.handle }}\"\n }\n}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"headerParameters": {
"parameters": [
{
"name": "X-Shopify-Access-Token",
"value": "={{ $('Workflow Configuration').first().json.shopifyAccessToken }}"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"typeVersion": 4.3
},
{
"id": "e19e872e-6c88-4877-a108-be45a3f461ef",
"name": "Shopify Get Orders",
"type": "n8n-nodes-base.httpRequest",
"position": [
3488,
256
],
"parameters": {
"url": "={{ 'https://' + $('Workflow Configuration').first().json.shopifyStore + '/admin/api/2024-01/graphql.json' }}",
"method": "POST",
"options": {},
"jsonBody": "={\"query\":\"query($query:String!){orders(first:100,query:$query){edges{node{lineItems(first:20){edges{node{product{id} quantity discountedTotalSet{shopMoney{amount}}}}}}}}}\",\"variables\":{\"query\":\"line_items.product_id:\" + $json.data.productByHandle.id.split('/').pop() + \" created_at:>\" + $now.minus({days: 30}).toFormat('yyyy-MM-dd')}}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"headerParameters": {
"parameters": [
{
"name": "X-Shopify-Access-Token",
"value": "={{ $('Workflow Configuration').first().json.shopifyAccessToken }}"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"typeVersion": 4.3
},
{
"id": "b11e9899-08aa-419d-b8dc-e30af1a7267e",
"name": "Compute Sales Metrics",
"type": "n8n-nodes-base.code",
"position": [
3712,
256
],
"parameters": {
"jsCode": "const orders = $json.data.orders.edges.map(e => e.node);\nlet units = 0;\nlet revenue = 0;\nfor (const order of orders) {\n for (const edge of order.lineItems.edges) {\n const li = edge.node;\n units += li.quantity;\n revenue += Number(li.discountedTotalSet.shopMoney.amount);\n }\n}\nreturn [{ json: { ...$json, units_sold_30d: units, revenue_30d: revenue } }];"
},
"typeVersion": 2
},
{
"id": "e24972bc-555d-481a-8f80-5fedf3f1b785",
"name": "Browserless Get HTML",
"type": "n8n-nodes-base.httpRequest",
"position": [
3936,
256
],
"parameters": {
"url": "={{ 'https://chrome.browserless.io/content?token=' + $('Workflow Configuration').first().json.browserlessToken }}",
"method": "POST",
"options": {},
"jsonBody": "={\n \"url\": \"={{ $('Extract Handle').first().json.url }}\",\n \"waitFor\": 3000\n}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"typeVersion": 4.3
},
{
"id": "62872ce9-9149-4625-b6ac-529a287c0e61",
"name": "Browserless Screenshot",
"type": "n8n-nodes-base.httpRequest",
"position": [
4160,
256
],
"parameters": {
"url": "={{ 'https://chrome.browserless.io/screenshot?token=' + $('Workflow Configuration').first().json.browserlessToken }}",
"method": "POST",
"options": {
"response": {
"response": {
"responseFormat": "file"
}
}
},
"jsonBody": "={\n \"url\": \"={{ $('Extract Handle').first().json.url }}\",\n \"options\": {\n \"fullPage\": true\n }\n}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"typeVersion": 4.3
},
{
"id": "48c207d5-239f-44b4-8189-d0d9729abaaa",
"name": "PageSpeed API",
"type": "n8n-nodes-base.httpRequest",
"position": [
4384,
256
],
"parameters": {
"url": "={{ 'https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=' + encodeURIComponent($('Extract Handle').first().json.url) + '&strategy=mobile&key=' + $('Workflow Configuration').first().json.googlePageSpeedKey }}",
"options": {}
},
"typeVersion": 4.3
},
{
"id": "4640e6d0-1463-41c6-ba80-7aec080dbe5d",
"name": "Extract Performance Metrics",
"type": "n8n-nodes-base.code",
"position": [
4608,
256
],
"parameters": {
"jsCode": "const l = $json.lighthouseResult;\nreturn [{\n json: {\n ...$json,\n performance_score: l.categories.performance.score * 100,\n lcp_ms: l.audits['largest-contentful-paint'].numericValue,\n cls: l.audits['cumulative-layout-shift'].numericValue,\n tbt_ms: l.audits['total-blocking-time'].numericValue\n }\n}];"
},
"typeVersion": 2
},
{
"id": "51499cce-5fa5-4d17-8712-d71fdc89a64d",
"name": "Prepare AI Payload",
"type": "n8n-nodes-base.code",
"position": [
4832,
256
],
"parameters": {
"jsCode": "const productData = $('Shopify Get Product').first().json.data.productByHandle;\nconst metricsData = $('Compute Sales Metrics').first().json;\nconst htmlData = $('Browserless Get HTML').first().json;\nconst perfData = $('Extract Performance Metrics').first().json;\n\nreturn [{\n json: {\n product: productData,\n metrics: {\n units_sold_30d: metricsData.units_sold_30d,\n revenue_30d: metricsData.revenue_30d\n },\n html: htmlData,\n performance: {\n lcp_ms: perfData.lcp_ms,\n cls: perfData.cls,\n tbt_ms: perfData.tbt_ms,\n score: perfData.performance_score\n }\n }\n}];"
},
"typeVersion": 2
},
{
"id": "8925cff2-eff0-40cc-968f-3177a945dbef",
"name": "AI CTA Audit Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
5056,
256
],
"parameters": {
"text": "={{ 'Product: ' + $json.product.title + '\\n\\nSales Metrics (Last 30 Days):\\n- Units Sold: ' + $json.metrics.units_sold_30d + '\\n- Revenue: $' + $json.metrics.revenue_30d + '\\n\\nPerformance Metrics:\\n- Performance Score: ' + $json.performance.score + '\\n- LCP: ' + $json.performance.lcp_ms + 'ms\\n- CLS: ' + $json.performance.cls + '\\n- TBT: ' + $json.performance.tbt_ms + 'ms\\n\\nHTML Content:\\n' + $json.html }}",
"options": {
"systemMessage": "You are a CRO (Conversion Rate Optimization) and UI/UX expert specializing in e-commerce product pages.\n\nYour task is to:\n1. Analyze the provided product data, sales metrics, HTML content, and performance metrics\n2. Identify CTA (Call-to-Action) issues and opportunities for improvement\n3. Recommend specific improvements based on conversion best practices\n4. Create a new optimized CTA design with HTML/CSS\n5. Generate metafield values for Shopify integration\n6. Create A/B test variants for the CTA\n\nFocus on:\n- Button placement, size, and visibility\n- Copy clarity and urgency\n- Trust signals and social proof\n- Mobile responsiveness\n- Performance impact\n- Conversion psychology\n\nReturn your analysis and recommendations in the structured JSON format."
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 3
},
{
"id": "a748d114-2609-4011-a09e-537d87403002",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
5072,
480
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {},
"builtInTools": {}
},
"credentials": {
"openAiApi": {
"id": "AGsOKrB8TEE47Hch",
"name": "n8n free OpenAI API credits"
}
},
"typeVersion": 1.3
},
{
"id": "b34a5c85-43fa-44f0-bb11-c75019a1c691",
"name": "Structured Output Parser",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
5200,
480
],
"parameters": {
"schemaType": "manual",
"inputSchema": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"issues\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"List of identified CTA issues\"\n\t\t},\n\t\t\"recommendations\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Recommended improvements\"\n\t\t},\n\t\t\"new_design\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Description of new CTA design\"\n\t\t},\n\t\t\"cta_html\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"HTML/CSS code for new CTA\"\n\t\t},\n\t\t\"cta_heading\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"CTA heading text\"\n\t\t},\n\t\t\"cta_subheading\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"CTA subheading text\"\n\t\t},\n\t\t\"cta_button_label\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"CTA button label\"\n\t\t},\n\t\t\"cta_trust_text\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Trust signal text\"\n\t\t},\n\t\t\"cta_style_variant\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Style variant identifier\"\n\t\t},\n\t\t\"variant_A\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"A/B test variant A description\"\n\t\t},\n\t\t\"variant_B\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"A/B test variant B description\"\n\t\t}\n\t}\n}"
},
"typeVersion": 1.3
},
{
"id": "f5da4457-b540-46e8-8838-257e0e3e496d",
"name": "Shopify Update Metafields",
"type": "n8n-nodes-base.httpRequest",
"position": [
5408,
256
],
"parameters": {
"url": "={{ 'https://' + $('Workflow Configuration').first().json.shopifyStore + '/admin/api/2024-01/graphql.json' }}",
"method": "POST",
"options": {},
"jsonBody": "={\n \"query\": \"mutation metafieldsSet($metafields:[MetafieldsSetInput!]!){metafieldsSet(metafields:$metafields){userErrors{message}}}\",\n \"variables\": {\n \"metafields\": [\n {\n \"ownerId\": \"={{ $('Prepare AI Payload').first().json.product.id }}\",\n \"namespace\": \"ai_cta\",\n \"key\": \"heading\",\n \"type\": \"single_line_text_field\",\n \"value\": \"={{ $json.cta_heading }}\"\n },\n {\n \"ownerId\": \"={{ $('Prepare AI Payload').first().json.product.id }}\",\n \"namespace\": \"ai_cta\",\n \"key\": \"subheading\",\n \"type\": \"single_line_text_field\",\n \"value\": \"={{ $json.cta_subheading }}\"\n },\n {\n \"ownerId\": \"={{ $('Prepare AI Payload').first().json.product.id }}\",\n \"namespace\": \"ai_cta\",\n \"key\": \"button_label\",\n \"type\": \"single_line_text_field\",\n \"value\": \"={{ $json.cta_button_label }}\"\n },\n {\n \"ownerId\": \"={{ $('Prepare AI Payload').first().json.product.id }}\",\n \"namespace\": \"ai_cta\",\n \"key\": \"trust_text\",\n \"type\": \"single_line_text_field\",\n \"value\": \"={{ $json.cta_trust_text }}\"\n },\n {\n \"ownerId\": \"={{ $('Prepare AI Payload').first().json.product.id }}\",\n \"namespace\": \"ai_cta\",\n \"key\": \"style_variant\",\n \"type\": \"single_line_text_field\",\n \"value\": \"={{ $json.cta_style_variant }}\"\n },\n {\n \"ownerId\": \"={{ $('Prepare AI Payload').first().json.product.id }}\",\n \"namespace\": \"ai_cta\",\n \"key\": \"enabled\",\n \"type\": \"boolean\",\n \"value\": \"true\"\n }\n ]\n }\n}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"headerParameters": {
"parameters": [
{
"name": "X-Shopify-Access-Token",
"value": "={{ $('Workflow Configuration').first().json.shopifyAccessToken }}"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"typeVersion": 4.3
},
{
"id": "46a938f3-7264-4cdb-a8c5-74b6770b6be6",
"name": "Save Audit Snapshot",
"type": "n8n-nodes-base.googleSheets",
"position": [
5632,
256
],
"parameters": {
"columns": {
"value": {
"issues": "={{ $('AI CTA Audit Agent').first().json.issues }}",
"timestamp": "={{ $now.toISO() }}",
"product_id": "={{ $('Prepare AI Payload').first().json.product.id }}",
"cta_heading": "={{ $('AI CTA Audit Agent').first().json.cta_heading }}",
"product_url": "={{ $('Extract Handle').first().json.url }}",
"revenue_30d": "={{ $('Prepare AI Payload').first().json.metrics.revenue_30d }}",
"product_title": "={{ $('Prepare AI Payload').first().json.product.title }}",
"units_sold_30d": "={{ $('Prepare AI Payload').first().json.metrics.units_sold_30d }}",
"cta_button_label": "={{ $('AI CTA Audit Agent').first().json.cta_button_label }}",
"performance_score": "={{ $('Prepare AI Payload').first().json.performance.score }}"
},
"schema": [
{
"id": "timestamp",
"required": false,
"displayName": "timestamp",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "product_url",
"required": false,
"displayName": "product_url",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "product_id",
"required": false,
"displayName": "product_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "product_title",
"required": false,
"displayName": "product_title",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "units_sold_30d",
"required": false,
"displayName": "units_sold_30d",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "revenue_30d",
"required": false,
"displayName": "revenue_30d",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "performance_score",
"required": false,
"displayName": "performance_score",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "issues",
"required": false,
"displayName": "issues",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "cta_heading",
"required": false,
"displayName": "cta_heading",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "cta_button_label",
"required": false,
"displayName": "cta_button_label",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": []
},
"options": {},
"operation": "appendOrUpdate",
"sheetName": {
"__rl": true,
"mode": "name",
"value": "<__PLACEHOLDER_VALUE__Sheet Name (e.g., CTA Audits)__>"
},
"documentId": {
"__rl": true,
"mode": "id",
"value": "<__PLACEHOLDER_VALUE__Google Sheets Document ID__>"
}
},
"typeVersion": 4.7
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "bff0465b-79d7-4acc-a982-1e39e30c0ef1",
"connections": {
"PageSpeed API": {
"main": [
[
{
"node": "Extract Performance Metrics",
"type": "main",
"index": 0
}
]
]
},
"Extract Handle": {
"main": [
[
{
"node": "Shopify Get Product",
"type": "main",
"index": 0
}
]
]
},
"Webhook Trigger": {
"main": [
[
{
"node": "Workflow Configuration",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI CTA Audit Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"AI CTA Audit Agent": {
"main": [
[
{
"node": "Shopify Update Metafields",
"type": "main",
"index": 0
}
]
]
},
"Prepare AI Payload": {
"main": [
[
{
"node": "AI CTA Audit Agent",
"type": "main",
"index": 0
}
]
]
},
"Shopify Get Orders": {
"main": [
[
{
"node": "Compute Sales Metrics",
"type": "main",
"index": 0
}
]
]
},
"Shopify Get Product": {
"main": [
[
{
"node": "Shopify Get Orders",
"type": "main",
"index": 0
}
]
]
},
"Browserless Get HTML": {
"main": [
[
{
"node": "Browserless Screenshot",
"type": "main",
"index": 0
}
]
]
},
"Compute Sales Metrics": {
"main": [
[
{
"node": "Browserless Get HTML",
"type": "main",
"index": 0
}
]
]
},
"Browserless Screenshot": {
"main": [
[
{
"node": "PageSpeed API",
"type": "main",
"index": 0
}
]
]
},
"Workflow Configuration": {
"main": [
[
{
"node": "Extract Handle",
"type": "main",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "AI CTA Audit Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Shopify Update Metafields": {
"main": [
[
{
"node": "Save Audit Snapshot",
"type": "main",
"index": 0
}
]
]
},
"Extract Performance Metrics": {
"main": [
[
{
"node": "Prepare AI Payload",
"type": "main",
"index": 0
}
]
]
}
}
}