AutomationFlowsAI & RAG › Smart Shopify Agent: Ai-powered Abandoned Cart Recovery

Smart Shopify Agent: Ai-powered Abandoned Cart Recovery

ByYaron Been @yaron-nofluff on n8n.io

Transform abandoned carts into recovered sales with intelligent automation. This sophisticated n8n workflow monitors checkout abandonment, implements smart waiting periods, and sends AI-generated personalized recovery emails only when needed - maximizing conversions while…

Event trigger★★★★☆ complexityAI-powered16 nodesAgentOpenAI ChatGoogle SheetsGmailHTTP Request
AI & RAG Trigger: Event Nodes: 16 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #4396 — we link there as the canonical source.

This workflow follows the Agent → Gmail 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 →

Download .json
{
  "nodes": [
    {
      "id": "ecbb99d3-d896-48cc-b6b1-72e178329a3c",
      "name": "Generate Recovery Email",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        100,
        500
      ],
      "parameters": {
        "text": "=Write a friendly and persuasive abandoned cart recovery email for a customer named {{ $json.checkouts[0].customer.first_name }} {{ $json.checkouts[0].customer.last_name }}. The cart contains: {{ $json.checkouts }}. Encourage them to complete their purchase with a subtle reminder and optionally a discount. do not include subject and don't add extra stuff\n",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "0b156bce-50ec-4e56-9c67-be4b34791b3e",
      "name": "Email Writer",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        40,
        700
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "49b21bce-bece-40a3-b9c0-86e4adc3e167",
      "name": "Log Email Activity",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        740,
        500
      ],
      "parameters": {
        "columns": {
          "value": {
            "email": "={{ $('Get Initial Abandoned Checkout').item.json.checkouts[0].email }}",
            "customer": "={{ $('Get Initial Abandoned Checkout').item.json.checkouts[0].customer.first_name }} {{ $('Get Initial Abandoned Checkout').item.json.checkouts[0].customer.last_name }}",
            "GPT response": "={{ $('Generate Recovery Email').item.json.output }}"
          },
          "schema": [
            {
              "id": "customer",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "customer",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "GPT response",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "GPT response",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1H83mXsl_gjgwOWrwNYak6ISihoWsgx-EFxSbPlvQx7M/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1H83mXsl_gjgwOWrwNYak6ISihoWsgx-EFxSbPlvQx7M",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1H83mXsl_gjgwOWrwNYak6ISihoWsgx-EFxSbPlvQx7M/edit?usp=drivesdk",
          "cachedResultName": "Shopify abandoned checkout"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "e55ea939-10fd-423b-99ef-90a89b0effc8",
      "name": "Send Email to Customer",
      "type": "n8n-nodes-base.gmail",
      "position": [
        520,
        500
      ],
      "parameters": {
        "sendTo": "={{ $('Get Initial Abandoned Checkout').item.json.checkouts[0].email }}",
        "message": "={{ $json.output }}",
        "options": {},
        "subject": "=You left something behind, {{ $('Get Initial Abandoned Checkout').item.json.checkouts[0].customer.first_name }}"
      },
      "typeVersion": 2.1
    },
    {
      "id": "b5a6e9ac-6d54-4d6f-bf4d-ced260eecd00",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -680,
        400
      ],
      "parameters": {
        "color": 3,
        "width": 420,
        "height": 520,
        "content": "\ud83d\udd0d Section 3: Conditional Decision\n5. Is Customer Still Abandoned?\nNode Type: Conditional (If Statement).\n\nLogic: Compares the initial abandoned list with the new one using Customer ID.\n\nOutcome:\n\n\u2705 Yes \u2013 customer is still in the abandoned list \u2192 proceed to email.\n\n\u274c No \u2013 customer has completed checkout \u2192 do nothing."
      },
      "typeVersion": 1
    },
    {
      "id": "5462049f-2c8d-4f94-9475-33b16cbf4074",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "color": 5,
        "width": 920,
        "height": 840,
        "content": "\ud83d\udce7 Section 4: Recovery Email Flow\n6. Create Personalized Recovery Email\nNode Type: AI Content Generation (GPT-based).\n\nInput: Customer name, product(s) left in cart, etc.\n\nOutput: A personalized recovery email message.\n\nPurpose: Increases the chances of recovery through customized messaging.\n\n7. Send Recovery Email\nNode Type: Email Action (e.g., Gmail, SMTP).\n\nPurpose: Sends the generated email to the customer.\n\n8. Log Email Sent\nNode Type: Spreadsheet Append (Google Sheets, etc.).\n\nPurpose: Logs customer email, customer name and Response.\n\nHelps With: Tracking open rates, click-throughs, and future optimizations."
      },
      "typeVersion": 1
    },
    {
      "id": "ef86a495-60f4-49c0-a5ca-bbc4b36724b8",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3520,
        300
      ],
      "parameters": {
        "color": 4,
        "width": 1300,
        "height": 320,
        "content": "=======================================\n            WORKFLOW ASSISTANCE\n=======================================\nFor any questions or support, please contact:\n    Yaron@nofluff.online\n\nExplore more tips and tutorials here:\n   - YouTube: https://www.youtube.com/@YaronBeen/videos\n   - LinkedIn: https://www.linkedin.com/in/yaronbeen/\n=======================================\n"
      },
      "typeVersion": 1
    },
    {
      "id": "0f722fcc-e05a-4b9d-9250-487a049779eb",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3520,
        640
      ],
      "parameters": {
        "color": 4,
        "width": 1289,
        "height": 2238,
        "content": "Here's a full, polished write-up of your **Abandoned Checkout Recovery Workflow** following the format of your **High-Value Order Alert Workflow** example:\n\n---\n\n# \ud83d\uded2 Abandoned Checkout Recovery Workflow\n\n**Description:**\nThis workflow helps recover lost sales by identifying customers who abandon their checkout process. It begins by fetching abandoned cart data from a store, waits for a specific duration (1 hour), and rechecks to see if the customer has still not completed the purchase. If abandonment persists, the workflow generates a personalized recovery email using AI and sends it to the customer. This increases the chance of conversion and improves overall sales recovery rates.\n\n---\n\n## \ud83d\udfe2 Section 1: Checkout Monitoring & Initial Data Fetch\n\nThe workflow is initiated manually or on a scheduled basis to scan for abandoned checkouts via an API call to the store. This request returns a list of customers who added products to their cart but did not complete the purchase.\n\nThis initial fetch sets the baseline for comparison. The data includes essential customer identifiers and cart details, which will be used later to determine if the customer has recovered on their own.\n\nThis step ensures that the workflow only targets genuine abandonment scenarios and avoids acting on transient or temporary cases.\n\n---\n\n## \u23f1\ufe0f Section 2: Grace Period Wait\n\nAfter the initial abandoned checkout list is retrieved, the workflow pauses for **1 hour**. This buffer period gives customers time to complete their checkout naturally, without being nudged prematurely.\n\nThis approach respects customer autonomy and avoids sending unnecessary reminders, thereby reducing the risk of annoying users or cluttering inboxes.\n\n---\n\n## \ud83d\udd04 Section 3: Rechecking Abandonment Status\n\nOnce the wait time has elapsed, the workflow makes a second HTTP request to fetch the latest list of abandoned checkouts. It then uses a conditional check to determine if a particular customer from the initial list still appears in the updated data.\n\n* **If the customer is still present** in the new list, they are considered to still be in an abandoned state.\n* **If the customer is not present**, it is assumed that they completed their purchase and no further action is taken.\n\nThis section acts as a smart filter to prevent sending recovery emails unnecessarily.\n\n---\n\n## \u2709\ufe0f Section 4: Personalized Recovery Email Flow\n\nIf the customer is confirmed to still have an abandoned cart, the workflow proceeds to engage them with a recovery email.\n\nAn AI email writer generates a **personalized email** based on the abandoned cart data. The message can include specific products, a friendly reminder, and optional incentives such as discounts.\n\nThe email is then sent to the customer via an integrated email service provider. Immediately after, the workflow logs the email activity to a spreadsheet or database for tracking purposes. This helps monitor campaign effectiveness and customer engagement over time.\n\n---\n\n## \ud83d\uded1 Fallback: Customer Completed Purchase\n\nIf the customer is **not found** in the second check, it means they successfully completed the checkout during the wait period. In this case, the workflow follows a \"do nothing\" path \u2014 no email is sent, and the process ends gracefully.\n\nThis fallback mechanism ensures customers aren't contacted unnecessarily, maintaining a respectful user experience.\n\n---\n\n## \ud83d\udd01 Full Workflow Logic Overview\n\n1. Start the workflow manually or on a schedule.\n2. Fetch a list of current abandoned checkouts.\n3. Wait for 1 hour.\n4. Fetch updated abandoned checkout data.\n5. Compare both datasets:\n\n   * If customer still appears:\n\n     * Use AI to generate a personalized recovery email.\n     * Send the email to the customer.\n     * Log the activity.\n   * If customer no longer appears:\n\n     * End the workflow without taking action.\n\n---\n\nLet me know if you\u2019d like this converted into a PDF or added to a documentation system!\n"
      },
      "typeVersion": 1
    },
    {
      "id": "7a5fce94-6ae8-43a3-9e45-b15e1d6ecf61",
      "name": "No Operation, do nothing",
      "type": "n8n-nodes-base.noOp",
      "position": [
        100,
        1060
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "e8966160-eb7b-470c-9754-52048cb01551",
      "name": "Start Workflow",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1720,
        720
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "7ac542e0-5379-4416-a33e-c2ba13947a30",
      "name": "Get Initial Abandoned Checkout",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1420,
        720
      ],
      "parameters": {
        "url": "https://your-store.myshopify.com/admin/api/2023-10/checkouts.json",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "status",
              "value": "abandoned"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Shopify-Access-Token",
              "value": "your-access-token"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "2409af7c-7df8-4825-b31a-7d2f4bb84a59",
      "name": "Wait 1 Hour",
      "type": "n8n-nodes-base.wait",
      "position": [
        -1120,
        720
      ],
      "parameters": {
        "unit": "hours",
        "amount": 1
      },
      "typeVersion": 1.1
    },
    {
      "id": "449c40d4-e1fa-4984-9b3b-c9dd6863e71a",
      "name": "Recheck Abandoned Checkouts",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -900,
        720
      ],
      "parameters": {
        "url": "https://your-store.myshopify.com/admin/api/2023-10/checkouts.json",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "status",
              "value": "abandoned"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Shopify-Access-Token",
              "value": "your-access-token"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "023ea763-155f-4c3c-8c3b-d7de0ef1687a",
      "name": "Is Customer Still Abandoned?",
      "type": "n8n-nodes-base.if",
      "position": [
        -620,
        720
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "8119001f-78d5-40b4-bcd7-8f13495b6d51",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $('Get Initial Abandoned Checkout').item.json.checkouts[0].id }}",
              "rightValue": "={{ $json.checkouts[0].id }}"
            },
            {
              "id": "229cf7e1-5490-4bd0-9004-2baadbe15b4f",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $('Get Initial Abandoned Checkout').item.json.checkouts[0].id }}",
              "rightValue": "={{ $json.checkouts[1].id }}"
            },
            {
              "id": "163c04b1-6e4b-42da-9a5f-2168c4148023",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $('Get Initial Abandoned Checkout').item.json.checkouts[0].id }}",
              "rightValue": "={{ $json.checkouts[2].id }}"
            },
            {
              "id": "42461258-29f4-4dc2-9c34-598654debaa6",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $('Get Initial Abandoned Checkout').item.json.checkouts[0].id }}",
              "rightValue": "={{ $json.checkouts[3].id }}"
            },
            {
              "id": "a0c9d76f-66fc-454b-b59c-990291c85ebf",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $('Get Initial Abandoned Checkout').item.json.checkouts[0].id }}",
              "rightValue": "={{ $json.checkouts[4].id }}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "c0a92444-8d4d-4eeb-8c8f-7757d90dff2c",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1760,
        320
      ],
      "parameters": {
        "width": 520,
        "height": 600,
        "content": "\ud83d\udd01 Section 1: Initialization & First Abandoned Checkout Fetch\n1. Start Abandoned Checkout Recovery\nPurpose: Triggers the workflow.\n\nTrigger Type: Manual or Scheduled.\n\nWhen: Could be set to run periodically (e.g., every hour).\n\n2. Get Initial Abandoned Checkouts\nNode Type: HTTP Request (GET).\n\nURL: https://your_store.myshopify.com/admin/api/...\n\nPurpose: Fetches the list of all abandoned checkouts at the start of the workflow.\n\nOutput: A list of abandoned carts with customer ID."
      },
      "typeVersion": 1
    },
    {
      "id": "4748bf2d-732b-48f5-a506-01ab5f5ebbe8",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1180,
        320
      ],
      "parameters": {
        "width": 460,
        "height": 600,
        "content": "\u23f3 Section 2: Wait and Re-evaluation\n3. Wait 1 Hour\nNode Type: Wait.\n\nDuration: 1 hour.\n\nPurpose: Gives the customer a grace period to complete the checkout naturally before initiating any recovery steps.\n\n4. Recheck Abandoned Checkouts\nNode Type: HTTP Request (GET).\n\nURL: Same as the initial fetch.\n\nPurpose: Fetches the updated list of abandoned checkouts.\n\nOutput: A new list of customer IDs who still haven\u2019t completed their checkout."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Wait 1 Hour": {
      "main": [
        [
          {
            "node": "Recheck Abandoned Checkouts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Writer": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Recovery Email",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Start Workflow": {
      "main": [
        [
          {
            "node": "Get Initial Abandoned Checkout",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Email to Customer": {
      "main": [
        [
          {
            "node": "Log Email Activity",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Recovery Email": {
      "main": [
        [
          {
            "node": "Send Email to Customer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recheck Abandoned Checkouts": {
      "main": [
        [
          {
            "node": "Is Customer Still Abandoned?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Customer Still Abandoned?": {
      "main": [
        [
          {
            "node": "Generate Recovery Email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Initial Abandoned Checkout": {
      "main": [
        [
          {
            "node": "Wait 1 Hour",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Transform abandoned carts into recovered sales with intelligent automation. This sophisticated n8n workflow monitors checkout abandonment, implements smart waiting periods, and sends AI-generated personalized recovery emails only when needed - maximizing conversions while…

Source: https://n8n.io/workflows/4396/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

Want to skip the manual work and instantly generate SWOT analyses for your business plans, investor decks, or strategy docs? 🚀 This workflow lets you automate the entire SWOT (Strengths, Weaknesses, O

Google Sheets, Agent, Output Parser Structured +4
AI & RAG

The workflow runs every hour with a randomized delay of 5–20 minutes to help distribute load. It records the exact date and time a lead is emailed so you can track outreach. Follow-ups are automatical

Google Sheets, Agent, OpenAI Chat +5
AI & RAG

This n8n workflow automates turning short user ideas into production-ready real-estate marketing assets (photorealistic images and optional 360° videos). A form submission seeds a prompt board → an LL

Form Trigger, Google Sheets, Agent +6
AI & RAG

Enterprise-grade resume screening automation built for production environments. This workflow combines intelligent AI analysis with comprehensive error handling to ensure reliable processing of candid

Gmail Trigger, Google Drive, HTTP Request +6
AI & RAG

Transform your manual hiring process into an intelligent evaluation system that saves 15-20 minutes per candidate! This workflow automates the entire candidate assessment pipeline - from CSV/XLSX uplo

Form Trigger, Google Sheets, Google Drive +8