Skip to content

Instantly share code, notes, and snippets.

@dashcraft
Created February 3, 2026 16:27
Show Gist options
  • Select an option

  • Save dashcraft/56418608baaa1efa3704a91bfbb2570b to your computer and use it in GitHub Desktop.

Select an option

Save dashcraft/56418608baaa1efa3704a91bfbb2570b to your computer and use it in GitHub Desktop.
n8n Reengagement A/B Test Workflow
{
"name": "Drip: Inactive Client Reengagement (A/B Test)",
"nodes": [
{
"parameters": {
"rule": {
"interval": [
{
"field": "weeks",
"weeksInterval": 13,
"triggerAtDayOfWeek": 1,
"triggerAtHour": 9,
"triggerAtMinute": 0
}
]
}
},
"id": "schedule-trigger",
"name": "Quarterly Trigger",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [0, 300]
},
{
"parameters": {
"method": "GET",
"url": "https://listmonk-production-6d67.up.railway.app/api/subscribers",
"authentication": "genericCredentialType",
"genericAuthType": "httpBasicAuth",
"sendQuery": true,
"queryParameters": {
"parameters": [
{ "name": "list_id", "value": "5" },
{ "name": "per_page", "value": "100" }
]
},
"options": {}
},
"id": "get-inactive-clients",
"name": "Get Inactive Clients",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [220, 300],
"credentials": {
"httpBasicAuth": {
"id": "listmonk-api",
"name": "Listmonk API"
}
}
},
{
"parameters": {
"jsCode": "// Extract subscribers from API response\nconst subscribers = $input.first().json.data?.results || [];\n\n// Filter to only confirmed subscribers not already in a drip\nreturn subscribers\n .filter(s => s.status === 'confirmed')\n .map(s => ({\n json: {\n id: s.id,\n email: s.email,\n firstName: s.name?.split(' ')[0] || 'there',\n name: s.name,\n // Randomly assign to A or B variant (50/50 split)\n variant: Math.random() < 0.5 ? 'A' : 'B',\n // Track sequence position\n sequenceStep: 1\n }\n }));"
},
"id": "prepare-subscribers",
"name": "Prepare & Split A/B",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [440, 300]
},
{
"parameters": {
"batchSize": 10,
"options": {}
},
"id": "loop-subscribers",
"name": "Loop Subscribers",
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 3,
"position": [660, 300]
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict"
},
"conditions": [
{
"id": "variant-check",
"leftValue": "={{ $json.variant }}",
"rightValue": "A",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"options": {}
},
"id": "route-ab",
"name": "Route A/B",
"type": "n8n-nodes-base.if",
"typeVersion": 2,
"position": [880, 300]
},
{
"parameters": {
"method": "PUT",
"url": "https://listmonk-production-6d67.up.railway.app/api/subscribers/lists",
"authentication": "genericCredentialType",
"genericAuthType": "httpBasicAuth",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"ids\": [{{ $json.id }}],\n \"action\": \"add\",\n \"target_list_ids\": [20],\n \"status\": \"confirmed\"\n}",
"options": {}
},
"id": "add-to-variant-a",
"name": "Add to Variant A List",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [1100, 200],
"credentials": {
"httpBasicAuth": {
"id": "listmonk-api",
"name": "Listmonk API"
}
}
},
{
"parameters": {
"method": "PUT",
"url": "https://listmonk-production-6d67.up.railway.app/api/subscribers/lists",
"authentication": "genericCredentialType",
"genericAuthType": "httpBasicAuth",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"ids\": [{{ $json.id }}],\n \"action\": \"add\",\n \"target_list_ids\": [21],\n \"status\": \"confirmed\"\n}",
"options": {}
},
"id": "add-to-variant-b",
"name": "Add to Variant B List",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [1100, 400],
"credentials": {
"httpBasicAuth": {
"id": "listmonk-api",
"name": "Listmonk API"
}
}
},
{
"parameters": {
"method": "POST",
"url": "https://listmonk-production-6d67.up.railway.app/api/tx",
"authentication": "genericCredentialType",
"genericAuthType": "httpBasicAuth",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"subscriber_id\": {{ $('Prepare & Split A/B').item.json.id }},\n \"template_id\": 14,\n \"from_email\": \"Daniel Ashcraft <daniel.ashcraft@ofashandfire.com>\",\n \"data\": {\n \"variant\": \"A\",\n \"step\": 1\n }\n}",
"options": {}
},
"id": "send-email-a1",
"name": "Send Email A1",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [1320, 200],
"credentials": {
"httpBasicAuth": {
"id": "listmonk-api",
"name": "Listmonk API"
}
}
},
{
"parameters": {
"method": "POST",
"url": "https://listmonk-production-6d67.up.railway.app/api/tx",
"authentication": "genericCredentialType",
"genericAuthType": "httpBasicAuth",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"subscriber_id\": {{ $('Prepare & Split A/B').item.json.id }},\n \"template_id\": 18,\n \"from_email\": \"Daniel Ashcraft <daniel.ashcraft@ofashandfire.com>\",\n \"data\": {\n \"variant\": \"B\",\n \"step\": 1\n }\n}",
"options": {}
},
"id": "send-email-b1",
"name": "Send Email B1",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [1320, 400],
"credentials": {
"httpBasicAuth": {
"id": "listmonk-api",
"name": "Listmonk API"
}
}
},
{
"parameters": {
"unit": "days",
"amount": 7
},
"id": "wait-7-days-a",
"name": "Wait 7 Days (A)",
"type": "n8n-nodes-base.wait",
"typeVersion": 1.1,
"position": [1540, 200]
},
{
"parameters": {
"unit": "days",
"amount": 7
},
"id": "wait-7-days-b",
"name": "Wait 7 Days (B)",
"type": "n8n-nodes-base.wait",
"typeVersion": 1.1,
"position": [1540, 400]
},
{
"parameters": {
"method": "POST",
"url": "https://listmonk-production-6d67.up.railway.app/api/tx",
"authentication": "genericCredentialType",
"genericAuthType": "httpBasicAuth",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"subscriber_id\": {{ $('Prepare & Split A/B').item.json.id }},\n \"template_id\": 15,\n \"from_email\": \"Daniel Ashcraft <daniel.ashcraft@ofashandfire.com>\",\n \"data\": {\n \"variant\": \"A\",\n \"step\": 2\n }\n}",
"options": {}
},
"id": "send-email-a2",
"name": "Send Email A2",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [1760, 200],
"credentials": {
"httpBasicAuth": {
"id": "listmonk-api",
"name": "Listmonk API"
}
}
},
{
"parameters": {
"method": "POST",
"url": "https://listmonk-production-6d67.up.railway.app/api/tx",
"authentication": "genericCredentialType",
"genericAuthType": "httpBasicAuth",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"subscriber_id\": {{ $('Prepare & Split A/B').item.json.id }},\n \"template_id\": 19,\n \"from_email\": \"Daniel Ashcraft <daniel.ashcraft@ofashandfire.com>\",\n \"data\": {\n \"variant\": \"B\",\n \"step\": 2\n }\n}",
"options": {}
},
"id": "send-email-b2",
"name": "Send Email B2",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [1760, 400],
"credentials": {
"httpBasicAuth": {
"id": "listmonk-api",
"name": "Listmonk API"
}
}
},
{
"parameters": {
"unit": "days",
"amount": 14
},
"id": "wait-14-days-a",
"name": "Wait 14 Days (A)",
"type": "n8n-nodes-base.wait",
"typeVersion": 1.1,
"position": [1980, 200]
},
{
"parameters": {
"unit": "days",
"amount": 14
},
"id": "wait-14-days-b",
"name": "Wait 14 Days (B)",
"type": "n8n-nodes-base.wait",
"typeVersion": 1.1,
"position": [1980, 400]
},
{
"parameters": {
"method": "POST",
"url": "https://listmonk-production-6d67.up.railway.app/api/tx",
"authentication": "genericCredentialType",
"genericAuthType": "httpBasicAuth",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"subscriber_id\": {{ $('Prepare & Split A/B').item.json.id }},\n \"template_id\": 16,\n \"from_email\": \"Daniel Ashcraft <daniel.ashcraft@ofashandfire.com>\",\n \"data\": {\n \"variant\": \"A\",\n \"step\": 3\n }\n}",
"options": {}
},
"id": "send-email-a3",
"name": "Send Email A3",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [2200, 200],
"credentials": {
"httpBasicAuth": {
"id": "listmonk-api",
"name": "Listmonk API"
}
}
},
{
"parameters": {
"method": "POST",
"url": "https://listmonk-production-6d67.up.railway.app/api/tx",
"authentication": "genericCredentialType",
"genericAuthType": "httpBasicAuth",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"subscriber_id\": {{ $('Prepare & Split A/B').item.json.id }},\n \"template_id\": 20,\n \"from_email\": \"Daniel Ashcraft <daniel.ashcraft@ofashandfire.com>\",\n \"data\": {\n \"variant\": \"B\",\n \"step\": 3\n }\n}",
"options": {}
},
"id": "send-email-b3",
"name": "Send Email B3",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [2200, 400],
"credentials": {
"httpBasicAuth": {
"id": "listmonk-api",
"name": "Listmonk API"
}
}
},
{
"parameters": {
"unit": "days",
"amount": 14
},
"id": "wait-14-days-a2",
"name": "Wait 14 Days (A) 2",
"type": "n8n-nodes-base.wait",
"typeVersion": 1.1,
"position": [2420, 200]
},
{
"parameters": {
"unit": "days",
"amount": 14
},
"id": "wait-14-days-b2",
"name": "Wait 14 Days (B) 2",
"type": "n8n-nodes-base.wait",
"typeVersion": 1.1,
"position": [2420, 400]
},
{
"parameters": {
"method": "POST",
"url": "https://listmonk-production-6d67.up.railway.app/api/tx",
"authentication": "genericCredentialType",
"genericAuthType": "httpBasicAuth",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"subscriber_id\": {{ $('Prepare & Split A/B').item.json.id }},\n \"template_id\": 17,\n \"from_email\": \"Daniel Ashcraft <daniel.ashcraft@ofashandfire.com>\",\n \"data\": {\n \"variant\": \"A\",\n \"step\": 4\n }\n}",
"options": {}
},
"id": "send-email-a4",
"name": "Send Email A4 (Final)",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [2640, 200],
"credentials": {
"httpBasicAuth": {
"id": "listmonk-api",
"name": "Listmonk API"
}
}
},
{
"parameters": {
"method": "POST",
"url": "https://listmonk-production-6d67.up.railway.app/api/tx",
"authentication": "genericCredentialType",
"genericAuthType": "httpBasicAuth",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"subscriber_id\": {{ $('Prepare & Split A/B').item.json.id }},\n \"template_id\": 21,\n \"from_email\": \"Daniel Ashcraft <daniel.ashcraft@ofashandfire.com>\",\n \"data\": {\n \"variant\": \"B\",\n \"step\": 4\n }\n}",
"options": {}
},
"id": "send-email-b4",
"name": "Send Email B4 (Final)",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [2640, 400],
"credentials": {
"httpBasicAuth": {
"id": "listmonk-api",
"name": "Listmonk API"
}
}
},
{
"parameters": {},
"id": "merge-completed",
"name": "Merge Completed",
"type": "n8n-nodes-base.merge",
"typeVersion": 3,
"position": [2860, 300]
},
{
"parameters": {},
"id": "continue-loop",
"name": "Continue Loop",
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [3080, 300]
}
],
"connections": {
"Quarterly Trigger": {
"main": [[{ "node": "Get Inactive Clients", "type": "main", "index": 0 }]]
},
"Get Inactive Clients": {
"main": [[{ "node": "Prepare & Split A/B", "type": "main", "index": 0 }]]
},
"Prepare & Split A/B": {
"main": [[{ "node": "Loop Subscribers", "type": "main", "index": 0 }]]
},
"Loop Subscribers": {
"main": [
null,
[{ "node": "Route A/B", "type": "main", "index": 0 }]
]
},
"Route A/B": {
"main": [
[{ "node": "Add to Variant A List", "type": "main", "index": 0 }],
[{ "node": "Add to Variant B List", "type": "main", "index": 0 }]
]
},
"Add to Variant A List": {
"main": [[{ "node": "Send Email A1", "type": "main", "index": 0 }]]
},
"Add to Variant B List": {
"main": [[{ "node": "Send Email B1", "type": "main", "index": 0 }]]
},
"Send Email A1": {
"main": [[{ "node": "Wait 7 Days (A)", "type": "main", "index": 0 }]]
},
"Send Email B1": {
"main": [[{ "node": "Wait 7 Days (B)", "type": "main", "index": 0 }]]
},
"Wait 7 Days (A)": {
"main": [[{ "node": "Send Email A2", "type": "main", "index": 0 }]]
},
"Wait 7 Days (B)": {
"main": [[{ "node": "Send Email B2", "type": "main", "index": 0 }]]
},
"Send Email A2": {
"main": [[{ "node": "Wait 14 Days (A)", "type": "main", "index": 0 }]]
},
"Send Email B2": {
"main": [[{ "node": "Wait 14 Days (B)", "type": "main", "index": 0 }]]
},
"Wait 14 Days (A)": {
"main": [[{ "node": "Send Email A3", "type": "main", "index": 0 }]]
},
"Wait 14 Days (B)": {
"main": [[{ "node": "Send Email B3", "type": "main", "index": 0 }]]
},
"Send Email A3": {
"main": [[{ "node": "Wait 14 Days (A) 2", "type": "main", "index": 0 }]]
},
"Send Email B3": {
"main": [[{ "node": "Wait 14 Days (B) 2", "type": "main", "index": 0 }]]
},
"Wait 14 Days (A) 2": {
"main": [[{ "node": "Send Email A4 (Final)", "type": "main", "index": 0 }]]
},
"Wait 14 Days (B) 2": {
"main": [[{ "node": "Send Email B4 (Final)", "type": "main", "index": 0 }]]
},
"Send Email A4 (Final)": {
"main": [[{ "node": "Merge Completed", "type": "main", "index": 0 }]]
},
"Send Email B4 (Final)": {
"main": [[{ "node": "Merge Completed", "type": "main", "index": 1 }]]
},
"Merge Completed": {
"main": [[{ "node": "Continue Loop", "type": "main", "index": 0 }]]
},
"Continue Loop": {
"main": [[{ "node": "Loop Subscribers", "type": "main", "index": 0 }]]
}
},
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"staticData": null,
"tags": [
{ "name": "drip-campaign" },
{ "name": "reengagement" },
{ "name": "ab-test" }
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment