{
  "nodes": [
    {
      "parameters": {
        "content": "## Automated Stripe Payment Recovery: Assign Account Manager for High LTV and coupons for others\n\n### How it works\n\nThe workflow triggers on a Stripe payment failure and retrieves contact details.\nIt queries the payment failures table to check if the client already has a recorded failure.\nIf a record exists, it increments the failure count; otherwise, it creates a new entry in the table.\nThe workflow evaluates the client's lifetime value (LTV) and checks if they have already been processed in the system.\nHigh LTV clients receive a newly created Stripe discount coupon via Gmail to encourage retention.\nThe system also checks for pending tasks, creating new internal tasks and Google Calendar events if none exist.\n\n### Setup steps\n\n- [ ] Configure Stripe credentials for the trigger and coupon creation nodes.\n- [ ] Connect the HighLevel account to manage contacts and tasks.\n- [ ] Authenticate your chosen data table here it is n8n official data tables.\n- [ ] Set up Gmail credentials for sending emails to users.\n- [ ] Connect Google Calendar for internal event creation.\n\n### Customization\n\nYou can customize the Stripe coupon amount, the criteria used to determine 'high LTV' clients, and the email template sent to them.",
        "height": 896,
        "width": 480
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -2368,
        288
      ],
      "id": "71803eb3-c095-47bb-8f05-d425b03a9c78",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## Handle Stripe trigger\n\nReceives the Stripe webhook and fetches associated contact details.",
        "height": 272,
        "width": 640,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -1808,
        592
      ],
      "id": "85137481-5ddf-4690-9f0d-fe713f1d4ab8",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "## Query payment failures table\n\nChecks the data table to see if a failure record already exists for the client.",
        "height": 320,
        "width": 416,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -1136,
        560
      ],
      "id": "b91ca06e-b0f7-4bd5-9854-7c6e17191855",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "content": "## Process existing failure record\n\nIncrements the failure count for known clients and evaluates their LTV status.",
        "height": 320,
        "width": 640,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -672,
        96
      ],
      "id": "cc9b08b5-d0f9-4086-9e6d-8d0f5d089942",
      "name": "Sticky Note3"
    },
    {
      "parameters": {
        "content": "## Process new failure record\n\nCreates a new data table entry for first-time payment failures and evaluates LTV.",
        "height": 320,
        "width": 640,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -688,
        880
      ],
      "id": "f9176afb-3423-4bf9-af32-43b43462de90",
      "name": "Sticky Note4"
    },
    {
      "parameters": {
        "content": "## Check for existing pending tasks\n\nFetches and aggregates current tasks to check if the client already has pending follow-ups.",
        "height": 304,
        "width": 640,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "id": "4f356d63-2425-4450-87c5-82c54f041851",
      "name": "Sticky Note5"
    },
    {
      "parameters": {
        "content": "## Create follow-up task and event for a dedicated account manager\n\nGenerates a new internal task, creates a Google Calendar event, and updates the row.",
        "height": 304,
        "width": 640,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        720,
        128
      ],
      "id": "1a2034f9-2f3c-4784-9a70-de636870473e",
      "name": "Sticky Note6"
    },
    {
      "parameters": {
        "content": "## Generate coupon and send message\n\nCreates a discount coupon in Stripe and sends it to the high LTV client via Gmail.",
        "height": 304,
        "width": 640,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        336
      ],
      "id": "108f08e5-4008-4aa0-b038-fe5e7db6042e",
      "name": "Sticky Note7"
    },
    {
      "parameters": {
        "content": "## Evaluate tasks for new records\n\nFetches and aggregates tasks for clients with newly created failure records.",
        "height": 304,
        "width": 640,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -16,
        768
      ],
      "id": "2d9ac668-fa16-40d0-8196-ecdf45c6b38f",
      "name": "Sticky Note8"
    },
    {
      "parameters": {
        "content": "## Schedule task for new records\n\nCreates follow-up tasks and calendar events for new payment failure instances.",
        "height": 304,
        "width": 640,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        704,
        896
      ],
      "id": "ab52aa64-01b3-488c-97f8-b3c558efea28",
      "name": "Sticky Note9"
    },
    {
      "parameters": {
        "content": "## Issue coupon for new records\n\nCreates a Stripe coupon and sends a retention email for newly recorded high LTV clients.",
        "height": 304,
        "width": 640,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -16,
        1104
      ],
      "id": "faf71875-4786-4051-932e-da7fffbd110c",
      "name": "Sticky Note10"
    },
    {
      "parameters": {
        "events": [
          "invoice.payment_failed",
          "payment_intent.payment_failed"
        ]
      },
      "id": "c894bc0d-7ad8-486f-8e7f-2be1a983f523",
      "name": "Stripe Event Trigger",
      "type": "n8n-nodes-base.stripeTrigger",
      "typeVersion": 1,
      "position": [
        -1760,
        704
      ],
      "credentials": {
        "stripeApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "getAll",
        "filters": {
          "query": "={{ $json.data.object.receipt_email }}"
        },
        "options": {},
        "requestOptions": {}
      },
      "type": "n8n-nodes-base.highLevel",
      "typeVersion": 2,
      "position": [
        -1536,
        704
      ],
      "id": "580818b0-abf6-4d4c-94c4-75c9d4453988",
      "name": "Fetch Contacts List",
      "alwaysOutputData": true,
      "credentials": {
        "highLevelOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "de566e1a-9687-4bfd-84bb-70005de261e3",
              "leftValue": "={{ $json.id }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        -1312,
        704
      ],
      "id": "7ddb8eb6-e7bb-46a7-8eff-86cac1fa7302",
      "name": "If Contact Exists"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "80468b7c-f365-447f-813a-d8641a66cd9c",
              "leftValue": "={{ $json.id }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        -864,
        688
      ],
      "id": "e1e83686-d089-40f9-9c46-077efe5d7011",
      "name": "If Payment Failure Exists"
    },
    {
      "parameters": {
        "resource": "task",
        "contactId": "={{ $('Update Failure Count').item.json.ContactID }}",
        "title": "High LTV Customer Payment Issue | Very Important",
        "dueDate": "2026-05-22T00:00:00",
        "additionalFields": {
          "assignedTo": "=enter-your-dedicated-account-manager-ghl-id"
        },
        "requestOptions": {}
      },
      "type": "n8n-nodes-base.highLevel",
      "typeVersion": 2,
      "position": [
        768,
        256
      ],
      "id": "2802df7f-0aed-4cfb-85cd-cfeaf8351cd9",
      "name": "Create Task",
      "credentials": {
        "highLevelOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "task",
        "contactId": "={{ $('Add Payment Failure Record').item.json.ContactID }}",
        "title": "High LTV Customer Payment Issue | Very Important",
        "dueDate": "2026-05-22T00:00:00",
        "additionalFields": {
          "assignedTo": "=enter-your-dedicated-account-manager-ghl-id"
        },
        "requestOptions": {}
      },
      "type": "n8n-nodes-base.highLevel",
      "typeVersion": 2,
      "position": [
        752,
        1024
      ],
      "id": "bdd26f3d-341d-4141-a3cd-18c7cadb54fb",
      "name": "Create Task for New Failure",
      "credentials": {
        "highLevelOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "dataTableId": {
          "__rl": true,
          "value": "d5QC1syJrsgKlhaz",
          "mode": "list",
          "cachedResultName": "Payment_intent_failures",
          "cachedResultUrl": "/projects/S0V0gYYsL1xXfutM/datatables/d5QC1syJrsgKlhaz"
        },
        "filters": {
          "conditions": [
            {
              "keyValue": "={{ $json.id }}"
            }
          ]
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Email": "={{ $json.Email }}",
            "ContactID": "={{ $json.ContactID }}",
            "StripePaymentIntentID": "={{ $('Stripe Event Trigger').item.json.data.object.id }}",
            "Amount": "={{ parseFloat($('Stripe Event Trigger').item.json.data.object.amount) / 100 }}",
            "Currency": "$",
            "FailureCount": "={{ new Date($json.updatedAt).getTime() > (Date.now() - 30 * 24 * 60 * 60 * 1000) ? ($('Get Payment Failures Data').item.json.FailureCount || 0) + 1 : 1 }}",
            "DiscountOffered": 0,
            "ErrorMessage": "={{ $('Stripe Event Trigger').item.json.data.object.last_payment_error.message }}",
            "ErrorCode": "={{ $('Stripe Event Trigger').item.json.data.object.last_payment_error.code }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Email",
              "displayName": "Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "ContactID",
              "displayName": "ContactID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "StripePaymentIntentID",
              "displayName": "StripePaymentIntentID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "Amount",
              "displayName": "Amount",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "Currency",
              "displayName": "Currency",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "FailureCount",
              "displayName": "FailureCount",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "DiscountOffered",
              "displayName": "DiscountOffered",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "ErrorCode",
              "displayName": "ErrorCode",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "ErrorMessage",
              "displayName": "ErrorMessage",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        -624,
        224
      ],
      "id": "62fbf15e-9c9e-4c8a-acfe-935d3b87428c",
      "name": "Update Failure Count"
    },
    {
      "parameters": {
        "dataTableId": {
          "__rl": true,
          "value": "d5QC1syJrsgKlhaz",
          "mode": "list",
          "cachedResultName": "Payment_intent_failures",
          "cachedResultUrl": "/projects/S0V0gYYsL1xXfutM/datatables/d5QC1syJrsgKlhaz"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Email": "={{ $json.Email }}",
            "ContactID": "={{ $('Fetch Contacts List').item.json.id }}",
            "StripePaymentIntentID": "={{ $('Stripe Event Trigger').item.json.data.object.id }}",
            "Amount": "={{ parseFloat($('Stripe Event Trigger').item.json.data.object.amount) / 100 }}",
            "Currency": "$",
            "FailureCount": "=1",
            "DiscountOffered": 0,
            "ErrorMessage": "={{ $('Stripe Event Trigger').item.json.data.object.last_payment_error.message }}",
            "ErrorCode": "={{ $('Stripe Event Trigger').item.json.data.object.last_payment_error.code }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Email",
              "displayName": "Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "ContactID",
              "displayName": "ContactID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "StripePaymentIntentID",
              "displayName": "StripePaymentIntentID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "Amount",
              "displayName": "Amount",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "Currency",
              "displayName": "Currency",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "FailureCount",
              "displayName": "FailureCount",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "DiscountOffered",
              "displayName": "DiscountOffered",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "ErrorCode",
              "displayName": "ErrorCode",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "ErrorMessage",
              "displayName": "ErrorMessage",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        -640,
        1008
      ],
      "id": "db66fc88-65f0-42f0-b2b0-4d65f66cc8e1",
      "name": "Add Payment Failure Record"
    },
    {
      "parameters": {
        "calendar": {
          "__rl": true,
          "value": "family01867773017172104160@group.calendar.google.com",
          "mode": "list",
          "cachedResultName": "Family"
        },
        "additionalFields": {
          "attendees": [
            "=enter-your-dedicated-account-manager-email-here"
          ],
          "description": "=Customer Email: {{ $('Fetch Contacts List').item.json.email }}\n\nHey, This is some serious issue out there support our IMP customer payment issue. And report back to our manager",
          "sendUpdates": "all",
          "summary": "={{ $json.task.title }}"
        }
      },
      "type": "n8n-nodes-base.googleCalendar",
      "typeVersion": 1.3,
      "position": [
        992,
        256
      ],
      "id": "efca41ed-6ea8-47cd-9a6c-45dfc44709e2",
      "name": "Create Calendar Event",
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "calendar": {
          "__rl": true,
          "value": "family01867773017172104160@group.calendar.google.com",
          "mode": "list",
          "cachedResultName": "Family"
        },
        "additionalFields": {
          "attendees": [
            "=enter-your-dedicated-account-manager-email-here"
          ],
          "description": "=Customer Email: {{ $('Fetch Contacts List').item.json.email }}\n\nHey, This is some serious issue out there support our IMP customer payment issue. And report back to our manager.",
          "sendUpdates": "all",
          "summary": "={{ $json.task.title }}"
        }
      },
      "type": "n8n-nodes-base.googleCalendar",
      "typeVersion": 1.3,
      "position": [
        976,
        1024
      ],
      "id": "74fb9654-58ad-4a22-af59-89a3c99cac14",
      "name": "Create Calendar Event for New",
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "coupon",
        "percentOff": 5
      },
      "type": "n8n-nodes-base.stripe",
      "typeVersion": 1,
      "position": [
        48,
        464
      ],
      "id": "4aa6f0a2-b04d-4363-82c2-0a1f511cf230",
      "name": "Create Stripe Coupon",
      "credentials": {
        "stripeApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sendTo": "={{ $('Fetch Contacts List').item.json.email }}",
        "subject": "=Action Required: Your recent payment failed (Plus a 5% discount inside!)",
        "message": "=<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<title>Action Required: Your recent payment failed</title>\n<style>\n  /* Reset & Base Styles */\n  body, table, td, a {\n    -webkit-text-size-adjust: 100%;\n    -ms-text-size-adjust: 100%;\n  }\n  body {\n    margin: 0;\n    padding: 0;\n    background-color: #f4f7f6;\n    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;\n    color: #333333;\n    -webkit-font-smoothing: antialiased;\n  }\n  /* Layout */\n  .email-wrapper {\n    width: 100%;\n    background-color: #f4f7f6;\n    padding: 40px 0;\n  }\n  .email-content {\n    max-width: 600px;\n    margin: 0 auto;\n    background-color: #ffffff;\n    border-radius: 8px;\n    box-shadow: 0 4px 10px rgba(0,0,0,0.05);\n    overflow: hidden;\n  }\n  .email-header {\n    text-align: center;\n    padding: 30px 40px 10px;\n  }\n  .email-body {\n    padding: 20px 40px 30px;\n  }\n  /* Typography */\n  h1 {\n    font-size: 22px;\n    color: #1a1a1a;\n    margin-top: 0;\n    margin-bottom: 20px;\n    font-weight: 600;\n  }\n  p {\n    font-size: 16px;\n    line-height: 1.6;\n    margin-top: 0;\n    margin-bottom: 20px;\n    color: #4a4a4a;\n  }\n  /* Highlight Box */\n  .discount-box {\n    background-color: #f0f7ff;\n    border: 2px dashed #0066cc;\n    border-radius: 6px;\n    padding: 25px 20px;\n    text-align: center;\n    margin: 30px 0;\n  }\n  .discount-box p {\n    margin: 0;\n    color: #004499;\n    font-size: 15px;\n  }\n  .discount-code {\n    display: block;\n    font-size: 26px;\n    font-weight: bold;\n    letter-spacing: 1.5px;\n    margin-top: 10px;\n    color: #0066cc;\n  }\n  /* Button */\n  .cta-container {\n    text-align: center;\n    margin: 35px 0 20px;\n  }\n  .cta-button {\n    background-color: #0066cc;\n    color: #ffffff !important;\n    text-decoration: none;\n    padding: 14px 32px;\n    border-radius: 6px;\n    font-size: 16px;\n    font-weight: bold;\n    display: inline-block;\n  }\n  /* Footer */\n  .email-footer {\n    background-color: #f9fafc;\n    padding: 30px 40px;\n    text-align: center;\n    border-top: 1px solid #eeeeee;\n  }\n  .email-footer p {\n    font-size: 13px;\n    color: #888888;\n    margin-bottom: 10px;\n    line-height: 1.5;\n  }\n  /* Responsive */\n  @media only screen and (max-width: 600px) {\n    .email-body, .email-header, .email-footer {\n      padding-left: 20px !important;\n      padding-right: 20px !important;\n    }\n  }\n</style>\n</head>\n<body>\n\n<div class=\"email-wrapper\">\n  <div class=\"email-content\">\n    \n    <div class=\"email-body\">\n      <h1>Action Required: Your payment failed</h1>\n      \n      <p>Hi {{ $('Stripe Event Trigger').item.json.data.object.last_payment_error.payment_method.billing_details.name }},</p>\n      \n      <p>It looks like we ran into a small hiccup while processing your recent payment. Don't worry\u2014this usually just happens due to an expired card, a typo, or a strict bank filter.</p>\n      \n      <p>To help get things back on track and make up for the inconvenience, we\u2019ve set up a custom <strong>5% discount</strong> for you to apply when you retry your payment.</p>\n\n      <div class=\"discount-box\">\n        <p>Use this promo code at checkout:</p>\n        <span class=\"discount-code\">{{ $json.id }}</span>\n      </div>\n\n      <div class=\"cta-container\">\n        <a href=\"https://www.blankarray.com/\" class=\"cta-button\">Update Payment Details</a>\n      </div>\n\n      <p>If you run into any issues or have questions, simply reply directly to this email and our support team will get it sorted out for you.</p>\n      \n      <p>Best regards,<br>\n      <strong>The Blankarray Team</strong></p>\n    </div>\n\n    <div class=\"email-footer\">\n      <p>You are receiving this email because you recently attempted a transaction at blankarray.</p>\n      <p>&copy; 2026 Blankarray. All rights reserved.</p>\n    </div>\n\n  </div>\n</div>\n\n</body>\n</html>",
        "options": {}
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.2,
      "position": [
        272,
        464
      ],
      "id": "1cdec0b4-b1e2-4f70-9259-068213717feb",
      "name": "Send Coupon Email",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "coupon",
        "percentOff": 5
      },
      "type": "n8n-nodes-base.stripe",
      "typeVersion": 1,
      "position": [
        32,
        1232
      ],
      "id": "a5d0b89c-5b6a-4052-8803-4bec9f3e47f0",
      "name": "Create Stripe Coupon for New",
      "credentials": {
        "stripeApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sendTo": "={{ $('Fetch Contacts List').item.json.email }}",
        "subject": "=Action Required: Your recent payment failed (Plus a 5% discount inside!)",
        "message": "=<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<title>Action Required: Your recent payment failed</title>\n<style>\n  /* Reset & Base Styles */\n  body, table, td, a {\n    -webkit-text-size-adjust: 100%;\n    -ms-text-size-adjust: 100%;\n  }\n  body {\n    margin: 0;\n    padding: 0;\n    background-color: #f4f7f6;\n    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;\n    color: #333333;\n    -webkit-font-smoothing: antialiased;\n  }\n  /* Layout */\n  .email-wrapper {\n    width: 100%;\n    background-color: #f4f7f6;\n    padding: 40px 0;\n  }\n  .email-content {\n    max-width: 600px;\n    margin: 0 auto;\n    background-color: #ffffff;\n    border-radius: 8px;\n    box-shadow: 0 4px 10px rgba(0,0,0,0.05);\n    overflow: hidden;\n  }\n  .email-header {\n    text-align: center;\n    padding: 30px 40px 10px;\n  }\n  .email-body {\n    padding: 20px 40px 30px;\n  }\n  /* Typography */\n  h1 {\n    font-size: 22px;\n    color: #1a1a1a;\n    margin-top: 0;\n    margin-bottom: 20px;\n    font-weight: 600;\n  }\n  p {\n    font-size: 16px;\n    line-height: 1.6;\n    margin-top: 0;\n    margin-bottom: 20px;\n    color: #4a4a4a;\n  }\n  /* Highlight Box */\n  .discount-box {\n    background-color: #f0f7ff;\n    border: 2px dashed #0066cc;\n    border-radius: 6px;\n    padding: 25px 20px;\n    text-align: center;\n    margin: 30px 0;\n  }\n  .discount-box p {\n    margin: 0;\n    color: #004499;\n    font-size: 15px;\n  }\n  .discount-code {\n    display: block;\n    font-size: 26px;\n    font-weight: bold;\n    letter-spacing: 1.5px;\n    margin-top: 10px;\n    color: #0066cc;\n  }\n  /* Button */\n  .cta-container {\n    text-align: center;\n    margin: 35px 0 20px;\n  }\n  .cta-button {\n    background-color: #0066cc;\n    color: #ffffff !important;\n    text-decoration: none;\n    padding: 14px 32px;\n    border-radius: 6px;\n    font-size: 16px;\n    font-weight: bold;\n    display: inline-block;\n  }\n  /* Footer */\n  .email-footer {\n    background-color: #f9fafc;\n    padding: 30px 40px;\n    text-align: center;\n    border-top: 1px solid #eeeeee;\n  }\n  .email-footer p {\n    font-size: 13px;\n    color: #888888;\n    margin-bottom: 10px;\n    line-height: 1.5;\n  }\n  /* Responsive */\n  @media only screen and (max-width: 600px) {\n    .email-body, .email-header, .email-footer {\n      padding-left: 20px !important;\n      padding-right: 20px !important;\n    }\n  }\n</style>\n</head>\n<body>\n\n<div class=\"email-wrapper\">\n  <div class=\"email-content\">\n    \n    <div class=\"email-body\">\n      <h1>Action Required: Your payment failed</h1>\n      \n      <p>Hi {{ $('Stripe Event Trigger').item.json.data.object.last_payment_error.payment_method.billing_details.name }},</p>\n      \n      <p>It looks like we ran into a small hiccup while processing your recent payment. Don't worry\u2014this usually just happens due to an expired card, a typo, or a strict bank filter.</p>\n      \n      <p>To help get things back on track and make up for the inconvenience, we\u2019ve set up a custom <strong>5% discount</strong> for you to apply when you retry your payment.</p>\n\n      <div class=\"discount-box\">\n        <p>Use this promo code at checkout:</p>\n        <span class=\"discount-code\">{{ $json.id }}</span>\n      </div>\n\n      <div class=\"cta-container\">\n        <a href=\"https://www.blankarray.com/\" class=\"cta-button\">Update Payment Details</a>\n      </div>\n\n      <p>If you run into any issues or have questions, simply reply directly to this email and our support team will get it sorted out for you.</p>\n      \n      <p>Best regards,<br>\n      <strong>The Blankarray Team</strong></p>\n    </div>\n\n    <div class=\"email-footer\">\n      <p>You are receiving this email because you recently attempted a transaction at blankarray.</p>\n      <p>&copy; 2026 Blankarray. All rights reserved.</p>\n    </div>\n\n  </div>\n</div>\n\n</body>\n</html>",
        "options": {}
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.2,
      "position": [
        256,
        1232
      ],
      "id": "40c31cd0-1442-41b5-8c7d-25f6fb976eff",
      "name": "Send Coupon Email for New",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 3
          },
          "conditions": [
            {
              "id": "5717e36d-c4d4-4b29-a412-49ac6234e3a6",
              "leftValue": "={{ $('Fetch Contacts List').item.json.customFields[0].value }}",
              "rightValue": 2000,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": true,
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        -176,
        240
      ],
      "id": "b771294a-905e-4d85-b532-33d937e7775b",
      "name": "If High LTV Client"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 3
          },
          "conditions": [
            {
              "id": "5717e36d-c4d4-4b29-a412-49ac6234e3a6",
              "leftValue": "={{ $('Fetch Contacts List').item.json.customFields[0].value }}",
              "rightValue": 2000,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": true,
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        -192,
        1024
      ],
      "id": "01d8a689-725a-4b6c-9d44-1978fa3f20a2",
      "name": "If High LTV Client (New)"
    },
    {
      "parameters": {
        "operation": "update",
        "dataTableId": {
          "__rl": true,
          "value": "d5QC1syJrsgKlhaz",
          "mode": "list",
          "cachedResultName": "Payment_intent_failures",
          "cachedResultUrl": "/projects/S0V0gYYsL1xXfutM/datatables/d5QC1syJrsgKlhaz"
        },
        "filters": {
          "conditions": [
            {
              "keyName": "Email",
              "keyValue": "={{ $('Update Failure Count').item.json.Email }}"
            }
          ]
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "automated_in_last_30_days": true
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Email",
              "displayName": "Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "ContactID",
              "displayName": "ContactID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "StripePaymentIntentID",
              "displayName": "StripePaymentIntentID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "Amount",
              "displayName": "Amount",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "Currency",
              "displayName": "Currency",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "FailureCount",
              "displayName": "FailureCount",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "DiscountOffered",
              "displayName": "DiscountOffered",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "ErrorCode",
              "displayName": "ErrorCode",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "ErrorMessage",
              "displayName": "ErrorMessage",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "automated_in_last_30_days",
              "displayName": "automated_in_last_30_days",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "boolean",
              "readOnly": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        1216,
        256
      ],
      "id": "8189a134-3a58-4e69-8db8-5df8d5d131a1",
      "name": "Update Record with Event"
    },
    {
      "parameters": {
        "operation": "update",
        "dataTableId": {
          "__rl": true,
          "value": "d5QC1syJrsgKlhaz",
          "mode": "list",
          "cachedResultName": "Payment_intent_failures",
          "cachedResultUrl": "/projects/S0V0gYYsL1xXfutM/datatables/d5QC1syJrsgKlhaz"
        },
        "filters": {
          "conditions": [
            {
              "keyName": "Email",
              "keyValue": "={{ $('Add Payment Failure Record').item.json.Email }}"
            }
          ]
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "automated_in_last_30_days": true
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Email",
              "displayName": "Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "ContactID",
              "displayName": "ContactID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "StripePaymentIntentID",
              "displayName": "StripePaymentIntentID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "Amount",
              "displayName": "Amount",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "Currency",
              "displayName": "Currency",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "FailureCount",
              "displayName": "FailureCount",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "DiscountOffered",
              "displayName": "DiscountOffered",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "ErrorCode",
              "displayName": "ErrorCode",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "ErrorMessage",
              "displayName": "ErrorMessage",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "automated_in_last_30_days",
              "displayName": "automated_in_last_30_days",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "boolean",
              "readOnly": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        1200,
        1024
      ],
      "id": "a01f58f6-f7a8-43e4-95aa-a903fe0a49e4",
      "name": "Update New Record with Event"
    },
    {
      "parameters": {
        "operation": "update",
        "dataTableId": {
          "__rl": true,
          "value": "d5QC1syJrsgKlhaz",
          "mode": "list",
          "cachedResultName": "Payment_intent_failures",
          "cachedResultUrl": "/projects/S0V0gYYsL1xXfutM/datatables/d5QC1syJrsgKlhaz"
        },
        "filters": {
          "conditions": [
            {
              "keyName": "Email",
              "keyValue": "={{ $('Add Payment Failure Record').item.json.Email }}"
            }
          ]
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "automated_in_last_30_days": true
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Email",
              "displayName": "Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "ContactID",
              "displayName": "ContactID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "StripePaymentIntentID",
              "displayName": "StripePaymentIntentID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "Amount",
              "displayName": "Amount",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "Currency",
              "displayName": "Currency",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "FailureCount",
              "displayName": "FailureCount",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "DiscountOffered",
              "displayName": "DiscountOffered",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "ErrorCode",
              "displayName": "ErrorCode",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "ErrorMessage",
              "displayName": "ErrorMessage",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "automated_in_last_30_days",
              "displayName": "automated_in_last_30_days",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "boolean",
              "readOnly": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        480,
        1232
      ],
      "id": "ca6f56c1-23bb-43f2-8f8e-dc11f78ea47f",
      "name": "Update New Record After Email"
    },
    {
      "parameters": {
        "operation": "update",
        "dataTableId": {
          "__rl": true,
          "value": "d5QC1syJrsgKlhaz",
          "mode": "list",
          "cachedResultName": "Payment_intent_failures",
          "cachedResultUrl": "/projects/S0V0gYYsL1xXfutM/datatables/d5QC1syJrsgKlhaz"
        },
        "filters": {
          "conditions": [
            {
              "keyName": "Email",
              "keyValue": "={{ $('Update Failure Count').item.json.Email }}"
            }
          ]
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "automated_in_last_30_days": true
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Email",
              "displayName": "Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "ContactID",
              "displayName": "ContactID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "StripePaymentIntentID",
              "displayName": "StripePaymentIntentID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "Amount",
              "displayName": "Amount",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "Currency",
              "displayName": "Currency",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "FailureCount",
              "displayName": "FailureCount",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "DiscountOffered",
              "displayName": "DiscountOffered",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "ErrorCode",
              "displayName": "ErrorCode",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "ErrorMessage",
              "displayName": "ErrorMessage",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "automated_in_last_30_days",
              "displayName": "automated_in_last_30_days",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "boolean",
              "readOnly": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        496,
        464
      ],
      "id": "c5329dea-0937-4e86-9b03-a7affcc87c49",
      "name": "Update Record After Email"
    },
    {
      "parameters": {
        "resource": "task",
        "operation": "getAll",
        "contactId": "={{ $json.ContactID }}",
        "requestOptions": {}
      },
      "type": "n8n-nodes-base.highLevel",
      "typeVersion": 2,
      "position": [
        48,
        128
      ],
      "id": "bc493944-8065-4966-9c50-cd38dd481d2a",
      "name": "Fetch Existing Tasks",
      "alwaysOutputData": true,
      "credentials": {
        "highLevelOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "tasks",
        "options": {}
      },
      "type": "n8n-nodes-base.aggregate",
      "typeVersion": 1,
      "position": [
        272,
        128
      ],
      "id": "74ade7f4-c3f3-4fd6-91be-f093fa06a25b",
      "name": "Aggregate Existing Tasks"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 3
          },
          "conditions": [
            {
              "id": "afc08e03-4fac-4c33-920a-d2595f6f5237",
              "leftValue": "={{ $json.tasks?.some(task => new Date(task.dueDate).getTime() > Date.now() - 604800000 && task.completed === false) || false }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": true,
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        496,
        128
      ],
      "id": "2fdcad4b-2bff-40d2-b19a-4f5d44918fed",
      "name": "If Pending Tasks Exist"
    },
    {
      "parameters": {
        "resource": "task",
        "operation": "getAll",
        "contactId": "={{ $json.ContactID }}",
        "requestOptions": {}
      },
      "type": "n8n-nodes-base.highLevel",
      "typeVersion": 2,
      "position": [
        32,
        896
      ],
      "id": "114f1e48-285c-47e1-b556-f15b4b30653e",
      "name": "Fetch Existing Tasks for New",
      "credentials": {
        "highLevelOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "tasks",
        "options": {}
      },
      "type": "n8n-nodes-base.aggregate",
      "typeVersion": 1,
      "position": [
        256,
        896
      ],
      "id": "6e57eee5-6056-44c3-af34-21d2c486d7a7",
      "name": "Aggregate Existing Tasks for New"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 3
          },
          "conditions": [
            {
              "id": "afc08e03-4fac-4c33-920a-d2595f6f5237",
              "leftValue": "={{ $json.tasks?.some(task => new Date(task.dueDate).getTime() > Date.now() - 604800000 && task.completed === false) || false }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": true,
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        480,
        896
      ],
      "id": "e66259ef-c1d6-47c0-b4e1-ddb31aedbaae",
      "name": "If Pending Tasks Exist for New"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "2aed159a-2abb-4df9-a7b1-fe017d6e6999",
              "leftValue": "={{ $json.automated_in_last_30_days }}",
              "rightValue": false,
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        -400,
        224
      ],
      "id": "4fcdcc8d-f11d-4572-b723-a82958c76559",
      "name": "If Already Automated Recently"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "2aed159a-2abb-4df9-a7b1-fe017d6e6999",
              "leftValue": "={{ $json.automated_in_last_30_days }}",
              "rightValue": false,
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        -416,
        1008
      ],
      "id": "04f7307d-aaf8-4491-a5af-0ae9f486640f",
      "name": "If Already Automated for New"
    },
    {
      "parameters": {
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "value": "d5QC1syJrsgKlhaz",
          "mode": "list",
          "cachedResultName": "Payment_intent_failures",
          "cachedResultUrl": "/projects/S0V0gYYsL1xXfutM/datatables/d5QC1syJrsgKlhaz"
        },
        "filters": {
          "conditions": [
            {
              "keyName": "Email",
              "keyValue": "={{ $json.email }}"
            }
          ]
        },
        "limit": 1
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        -1088,
        688
      ],
      "id": "28e11ab6-c4e5-4ed9-a13b-9833784cb153",
      "name": "Get Payment Failures Data"
    }
  ],
  "connections": {
    "Stripe Event Trigger": {
      "main": [
        [
          {
            "node": "Fetch Contacts List",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Contacts List": {
      "main": [
        [
          {
            "node": "If Contact Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Contact Exists": {
      "main": [
        [
          {
            "node": "Get Payment Failures Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Payment Failure Exists": {
      "main": [
        [
          {
            "node": "Update Failure Count",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Add Payment Failure Record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Task": {
      "main": [
        [
          {
            "node": "Create Calendar Event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Task for New Failure": {
      "main": [
        [
          {
            "node": "Create Calendar Event for New",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Failure Count": {
      "main": [
        [
          {
            "node": "If Already Automated Recently",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Payment Failure Record": {
      "main": [
        [
          {
            "node": "If Already Automated for New",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Calendar Event": {
      "main": [
        [
          {
            "node": "Update Record with Event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Calendar Event for New": {
      "main": [
        [
          {
            "node": "Update New Record with Event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Stripe Coupon": {
      "main": [
        [
          {
            "node": "Send Coupon Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Coupon Email": {
      "main": [
        [
          {
            "node": "Update Record After Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Stripe Coupon for New": {
      "main": [
        [
          {
            "node": "Send Coupon Email for New",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Coupon Email for New": {
      "main": [
        [
          {
            "node": "Update New Record After Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If High LTV Client": {
      "main": [
        [
          {
            "node": "Fetch Existing Tasks",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create Stripe Coupon",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If High LTV Client (New)": {
      "main": [
        [
          {
            "node": "Fetch Existing Tasks for New",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create Stripe Coupon for New",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Existing Tasks": {
      "main": [
        [
          {
            "node": "Aggregate Existing Tasks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Existing Tasks": {
      "main": [
        [
          {
            "node": "If Pending Tasks Exist",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Pending Tasks Exist": {
      "main": [
        [],
        [
          {
            "node": "Create Task",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Existing Tasks for New": {
      "main": [
        [
          {
            "node": "Aggregate Existing Tasks for New",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Existing Tasks for New": {
      "main": [
        [
          {
            "node": "If Pending Tasks Exist for New",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Pending Tasks Exist for New": {
      "main": [
        [],
        [
          {
            "node": "Create Task for New Failure",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Already Automated Recently": {
      "main": [
        [],
        [
          {
            "node": "If High LTV Client",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Already Automated for New": {
      "main": [
        [],
        [
          {
            "node": "If High LTV Client (New)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Payment Failures Data": {
      "main": [
        [
          {
            "node": "If Payment Failure Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "meta": {
    "templateCredsSetupCompleted": true
  }
}