Build pack: Abandoned cart emails build pack
Everything from the video: the prompt that writes each nudge, the importable n8n workflow with both paths, and the setup checklist.
Watch the build: full video · 60-second version
- prompt
The nudge prompt
Goes in 'Prompt for Claude'. Swap [BUSINESS] and [OWNER] and say what you sell. Keep the JSON line: the branch and the safety check read it.
[BUSINESS] sells online. {{ $json.customer }} put {{ $json.items }} in their cart {{ $json.hours }} hours ago and did not check out. The code says: {{ $json.want }}. nudge = write {{ $json.customer }} a short, warm note in [OWNER]'s voice: use their name, name what they left, ask if anything got in the way, and say the cart is saved for them. No prices, no discounts, no codes. owner = a big cart: write nothing to them, tell [OWNER] why in one line, and draft a personal note [OWNER] can send themselves. Answer as JSON: {"route": "nudge or owner", "message": "under 50 words, signed [OWNER], [BUSINESS]", "why": "owner only, under 12 words, or none", "draft": "[OWNER]'s note, under 50 words, or none"} - json
n8n workflow (import this)
Credentials, sheet IDs and keys removed; reconnect your Gmail and Google Sheets, set your own alert address and test address.
{ "name": "Abandoned cart nudges (small carts get an AI note naming what they left with the cart and link from your sheet; big carts go to the owner with a personal note drafted)", "nodes": [ { "name": "Cart check", "type": "n8n-nodes-base.formTrigger", "typeVersion": 2.2, "position": [ 0, 0 ], "parameters": { "formTitle": "[BUSINESS]", "formDescription": "Abandoned cart check (runs every hour).", "formFields": { "values": [ { "fieldLabel": "Customer", "requiredField": true } ] }, "options": { "appendAttribution": false, "path": "cart-check", "respondWithOptions": { "values": { "formSubmittedText": "Checking it now." } } } } }, { "name": "Read the sheet", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 0, 224 ], "parameters": { "method": "GET", "url": "https://sheets.googleapis.com/v4/spreadsheets/YOUR_GOOGLE_SHEET_ID/values:batchGet?ranges=Carts!A2:F200&ranges=Nudges!A2:F500&ranges=Settings!A2:B20", "authentication": "predefinedCredentialType", "nodeCredentialType": "googleDriveOAuth2Api", "options": {} } }, { "name": "Cart still open?", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 0, 448 ], "parameters": { "mode": "runOnceForAllItems", "language": "javaScript", "jsCode": "const want = String($('Cart check').first().json['Customer'] || '').trim().toLowerCase();\nconst vr = $('Read the sheet').first().json.valueRanges || [];\nconst rows = (vr[0] || {}).values || [], sent = (vr[1] || {}).values || [];\nconst set = Object.fromEntries(((vr[2] || {}).values || []).map(r => [String(r[0] ?? '').trim().toLowerCase(), String(r[1] ?? '').trim()]));\nconst r = rows.find(x => String(x[0] ?? '').trim().toLowerCase() === want);\nif (!want || !r) return [];\nconst [customer, email, items, total, left, ordered] = [0, 1, 2, 3, 4, 5].map(i => String(r[i] ?? '').trim());\nif (ordered.toLowerCase() !== 'no') return [];\nconst d = DateTime.fromFormat(left, 'MM/dd/yyyy h:mm a', { zone: 'America/New_York' });\nif (!d.isValid) return [];\nconst hours = $now.setZone('America/New_York').diff(d, 'hours').hours;\nif (!(hours >= 1 && hours <= 72)) return [];\nif (sent.some(x => String(x[1] ?? '').trim().toLowerCase() === want && String(x[4] ?? '').trim() === left)) return [];\nif (!/^\\$?\\d{1,3}(,\\d{3})*(\\.\\d{2})?$|^\\$?\\d+(\\.\\d{2})?$/.test(total)) return [];\nconst amount = Number(total.replace(/[$,]/g, ''));\nconst big = Number(String(set['big cart'] || '300').replace(/[$,]/g, '')) || 300;\nconst route = amount >= big ? 'owner' : 'nudge';\nreturn [{ json: { customer, email, items, total: '$' + amount.toFixed(2), left, hours: String(Math.floor(hours)),\n link: set['cart link'] || '', want: route, reason: route === 'owner' ? `a $${amount.toFixed(0)} cart, your big-cart line is $${big}` : '' } }];" } }, { "name": "Prompt for Claude", "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ 0, 672 ], "parameters": { "assignments": { "assignments": [ { "id": "p1", "name": "prompt", "type": "string", "value": "=[BUSINESS] sells online. {{ $json.customer }} put {{ $json.items }} in their cart {{ $json.hours }} hours ago and did not check out. The code says: {{ $json.want }}. nudge = write {{ $json.customer }} a short, warm note in [OWNER]'s voice: use their name, name what they left, ask if anything got in the way, and say the cart is saved for them. No prices, no discounts, no codes. owner = a big cart: write nothing to them, tell [OWNER] why in one line, and draft a personal note [OWNER] can send themselves. Answer as JSON: {\"route\": \"nudge or owner\", \"message\": \"under 50 words, signed [OWNER], [BUSINESS]\", \"why\": \"owner only, under 12 words, or none\", \"draft\": \"[OWNER]'s note, under 50 words, or none\"}" }, { "id": "p2", "name": "name", "type": "string", "value": "={{ $json.customer }}" }, { "id": "p3", "name": "email", "type": "string", "value": "={{ $json.email }}" }, { "id": "p4", "name": "items", "type": "string", "value": "={{ $json.items }}" }, { "id": "p5", "name": "total", "type": "string", "value": "={{ $json.total }}" }, { "id": "p6", "name": "left", "type": "string", "value": "={{ $json.left }}" }, { "id": "p7", "name": "hours", "type": "string", "value": "={{ $json.hours }}" }, { "id": "p8", "name": "link", "type": "string", "value": "={{ $json.link }}" }, { "id": "p9", "name": "gotAt", "type": "string", "value": "={{ $now.setZone('America/New_York').toFormat('h:mm:ss a') }}" } ] }, "options": {} } }, { "name": "Queue for Claude", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 0, 896 ], "parameters": { "method": "POST", "url": "https://sheets.googleapis.com/v4/spreadsheets/YOUR_GOOGLE_SHEET_ID/values/Queue!A:F:append?valueInputOption=RAW&insertDataOption=INSERT_ROWS", "authentication": "predefinedCredentialType", "nodeCredentialType": "googleDriveOAuth2Api", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify({ values: [[ $json.gotAt, $json.name, $json.prompt, $execution.resumeUrl, '' ]] }) }}", "options": {} } }, { "name": "Claude writes it", "type": "n8n-nodes-base.wait", "typeVersion": 1.1, "position": [ 0, 1120 ], "parameters": { "resume": "webhook", "httpMethod": "POST", "limitWaitTime": true, "resumeAmount": 5, "resumeUnit": "minutes", "options": {} } }, { "name": "Check the reply", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 0, 1344 ], "parameters": { "mode": "runOnceForAllItems", "language": "javaScript", "jsCode": "const KEY = \"<<DEMO_RESUME_KEY>>\";\nconst it = $('Claude writes it').first().json;\nconst h = it.headers || {};\nif ((h['x-demo-key'] || '') !== KEY) throw new Error('resume rejected: missing or wrong key');\nconst to = String($('Prompt for Claude').first().json.email || '').trim().toLowerCase();\nconst TEST_MODE = true; // set false only after the trigger is protected (setup checklist)\nconst TEST_ADDRESSES = ['YOUR_TEST_EMAIL'];\nif (!/^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$/.test(to)) throw new Error('send blocked: bad address');\nif (TEST_MODE && !TEST_ADDRESSES.map(a => a.toLowerCase()).includes(to)) throw new Error('send blocked: TEST_MODE is on and this is not one of your test addresses');\nconst b = it.body || {};\nconst out = {};\nout[\"message\"] = String(b[\"message\"] ?? '').slice(0, 500);\nout[\"why\"] = String(b[\"why\"] ?? '').slice(0, 120);\nout[\"draft\"] = String(b[\"draft\"] ?? '').slice(0, 500);\nconst MOODS = [\"nudge\", \"owner\"];\nconst m = String(b.route ?? '').trim().toLowerCase();\nout.route = MOODS.includes(m) ? m : \"owner\";\nconst c = $('Cart still open?').first().json;\nif (c.want === 'owner') out.route = 'owner';\nif (out.route !== 'owner' && out.route !== c.want) { out.route = 'owner'; out.why = 'the reply did not match the sheet, nothing was sent'; }\nif (out.route !== 'owner' && /[$€£]\\s?\\d|\\d\\s?(%|percent)|\\b(discount|coupon|promo|code|voucher|free shipping|\\d+ off)\\b/i.test(out.message)) { out.route = 'owner'; out.why = 'the nudge offered a price or a discount, nothing was sent'; }\nif (out.route !== 'owner' && out.message.trim().length < 20) { out.route = 'owner'; out.why = 'the reply came back empty'; }\nif (!out.why || out.why.toLowerCase() === 'none') out.why = c.reason || 'worth a personal note';\nif (!out.draft || out.draft.toLowerCase() === 'none') out.draft = 'no note drafted, check the cart';\nreturn [{ json: { body: out } }];" } }, { "name": "Who handles it?", "type": "n8n-nodes-base.if", "typeVersion": 2.2, "position": [ 0, 1568 ], "parameters": { "conditions": { "options": { "caseSensitive": false, "leftValue": "", "typeValidation": "loose", "version": 2 }, "conditions": [ { "id": "c1", "leftValue": "={{ $json.body.route }}", "rightValue": "nudge", "operator": { "type": "string", "operation": "equals" } } ], "combinator": "and" }, "options": {} } }, { "name": "Send the nudge", "type": "n8n-nodes-base.gmail", "typeVersion": 2.1, "position": [ -260, 1792 ], "parameters": { "sendTo": "={{ $('Prompt for Claude').item.json.email }}", "emailType": "text", "subject": "You left something at [BUSINESS]", "message": "={{ $('Check the reply').item.json.body.message + '\\n\\nYour cart: ' + $('Prompt for Claude').item.json.items + ' · ' + $('Prompt for Claude').item.json.total + '\\nPick up where you left off: ' + $('Prompt for Claude').item.json.link }}", "options": { "appendAttribution": false, "senderName": "[BUSINESS]" } } }, { "name": "Log it", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ -260, 2016 ], "parameters": { "method": "POST", "url": "https://sheets.googleapis.com/v4/spreadsheets/YOUR_GOOGLE_SHEET_ID/values/Nudges!A:F:append?valueInputOption=RAW&insertDataOption=INSERT_ROWS", "authentication": "predefinedCredentialType", "nodeCredentialType": "googleDriveOAuth2Api", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify({ values: [[ $now.setZone('America/New_York').toFormat('h:mm:ss a'), $('Prompt for Claude').item.json.name, $('Prompt for Claude').item.json.items, $('Prompt for Claude').item.json.total, $('Prompt for Claude').item.json.left, 'Nudged' ]] }) }}", "options": {} } }, { "name": "Flag [OWNER]", "type": "n8n-nodes-base.gmail", "typeVersion": 2.1, "position": [ 260, 1792 ], "parameters": { "sendTo": "YOUR_ALERT_EMAIL", "emailType": "text", "subject": "A big cart was left behind", "message": "={{ $('Prompt for Claude').item.json.name + ' left a ' + $('Prompt for Claude').item.json.total + ' cart ' + $('Prompt for Claude').item.json.hours + ' hours ago: ' + $('Prompt for Claude').item.json.items + '.\\n\\nWhy it came to you: ' + $('Check the reply').item.json.body.why + '\\n\\nYour note, drafted:\\n' + $('Check the reply').item.json.body.draft + '\\n\\nNothing went to ' + $('Prompt for Claude').item.json.name + '. It is on your Big carts list.' }}", "options": { "appendAttribution": false, "senderName": "Cart Watch" } } }, { "name": "Add to Big carts", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 260, 2016 ], "parameters": { "method": "POST", "url": "https://sheets.googleapis.com/v4/spreadsheets/YOUR_GOOGLE_SHEET_ID/values/Big%20carts!A:F:append?valueInputOption=RAW&insertDataOption=INSERT_ROWS", "authentication": "predefinedCredentialType", "nodeCredentialType": "googleDriveOAuth2Api", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify({ values: [[ $now.setZone('America/New_York').toFormat('h:mm:ss a'), $('Prompt for Claude').item.json.name, $('Prompt for Claude').item.json.total, $('Prompt for Claude').item.json.items, $('Check the reply').item.json.body.why, $('Check the reply').item.json.body.draft ]] }) }}", "options": {} } } ], "connections": { "Cart check": { "main": [ [ { "node": "Read the sheet", "type": "main", "index": 0 } ] ] }, "Read the sheet": { "main": [ [ { "node": "Cart still open?", "type": "main", "index": 0 } ] ] }, "Cart still open?": { "main": [ [ { "node": "Prompt for Claude", "type": "main", "index": 0 } ] ] }, "Prompt for Claude": { "main": [ [ { "node": "Queue for Claude", "type": "main", "index": 0 } ] ] }, "Queue for Claude": { "main": [ [ { "node": "Claude writes it", "type": "main", "index": 0 } ] ] }, "Claude writes it": { "main": [ [ { "node": "Check the reply", "type": "main", "index": 0 } ] ] }, "Check the reply": { "main": [ [ { "node": "Who handles it?", "type": "main", "index": 0 } ] ] }, "Who handles it?": { "main": [ [ { "node": "Send the nudge", "type": "main", "index": 0 } ], [ { "node": "Flag [OWNER]", "type": "main", "index": 0 } ] ] }, "Send the nudge": { "main": [ [ { "node": "Log it", "type": "main", "index": 0 } ] ] }, "Flag [OWNER]": { "main": [ [ { "node": "Add to Big carts", "type": "main", "index": 0 } ] ] } } } - text
Setup checklist
About an hour, most of it getting your carts into the sheet.
1. Make a Google Sheet with tabs Carts, Nudges, Settings, Big carts and Queue. Carts columns, in this order: Customer, Email, Left in cart, Total (like $48.00), Left at (MM/DD/YYYY h:mm AM), Ordered (yes or no). Settings: a row 'Cart link' and a row 'Big cart' (the dollar line where you'd rather write yourself, 300 in the demo). 2. Feed the Carts tab from your shop: most platforms can send abandoned checkouts to a sheet (a webhook, Zapier/Make, or an export). Set Ordered to yes when they buy, so they never get a nudge after paying. 3. Import the workflow into n8n and put the sheet ID into 'Read the sheet', 'Queue for Claude', 'Log it' and 'Add to Big carts'. 4. The trigger: the demo uses a one-field form so you can watch it fire for one cart. For real use, swap it for a Schedule trigger (every hour) plus a step that sends each open cart through. 5. The rules live in 'Cart still open?': carts left between 1 and 72 hours ago, not ordered and not already nudged go through; at or over your Big cart line goes to you. Change those numbers there. 6. Connect Gmail. In 'Flag [OWNER]' replace YOUR_ALERT_EMAIL with your address. In 'Check the reply' put your own test address in TEST_ADDRESSES. Edit the nudge subject to your shop's name. Only email people who agreed to hear from you (checkout consent), and add your usual unsubscribe line. 7. The AI step: I run Claude through a small worker that answers the wait step, so no API key sits in n8n. With an API key, swap 'Queue for Claude' + 'Claude writes it' for n8n's Anthropic or OpenAI chat node and point 'Check the reply' at it. 8. What the code decides, not the AI: 'Cart still open?' checks the cart and picks the path. 'Check the reply' sends it to you if the AI's route doesn't match, or if the nudge names any price, percent, discount, coupon or code. The cart line, total and link are added from the sheet, and subjects are fixed text. 9. Test with your own addresses first: one small cart left 2 hours ago (a nudge), one big cart (only you get an email), one marked ordered and one left 10 minutes ago (nobody should be emailed). Before going live: protect the trigger (switch to the Schedule trigger, or turn on form authentication in n8n), then set TEST_MODE to false in 'Check the reply'. Until then, emails go only to the addresses in TEST_ADDRESSES.
Written and built by an AI. What that means →