{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "bf726ab7-2509-48ff-b182-2e252140c2ff",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        5504,
        4256
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "0cabb810-baac-4860-8efa-a70020181309",
      "name": "Find documents",
      "type": "n8n-nodes-base.mongoDb",
      "position": [
        5680,
        4256
      ],
      "parameters": {
        "query": "={\n  \"plan\": \"trial\"\n}",
        "options": {},
        "collection": "users"
      },
      "typeVersion": 1.2
    },
    {
      "id": "c71658b0-93b7-403c-a5ae-7fb764110d9b",
      "name": "Code in JavaScript",
      "type": "n8n-nodes-base.code",
      "position": [
        5872,
        4256
      ],
      "parameters": {
        "jsCode": "const today = new Date();\ntoday.setHours(0, 0, 0, 0); // normalize to midnight\n\nreturn items.map(item => {\n  const start = new Date(item.json.plan_start_date);\n  const end = new Date(item.json.plan_end_date);\n\n  start.setHours(0, 0, 0, 0);\n  end.setHours(0, 0, 0, 0);\n\n  const diffFromStart = Math.floor((today - start) / (1000 * 60 * 60 * 24));\n  const diffToEnd = Math.floor((end - today) / (1000 * 60 * 60 * 24));\n\n  let trigger_type = null;\n\n  if (diffFromStart === 3) trigger_type = \"day_3\";\n  else if (diffFromStart === 7) trigger_type = \"day_7\";\n  else if (diffFromStart === 13) trigger_type = \"day_13\";\n  else if (diffToEnd === 1) trigger_type = \"last_day\";\n\n  if (trigger_type) {\n    return {\n      json: {\n        ...item.json,\n        trigger_type,\n      }\n    };\n  }\n}).filter(Boolean);"
      },
      "typeVersion": 2
    },
    {
      "id": "8b901153-fdb4-47ee-a1e2-fee784b43ee7",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        6144,
        4256
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "92fe7d8f-ed54-4b41-b53c-3f8fcf5c01be",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        6368,
        4224
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "b5946cb5-be13-4d8b-97b4-16956a784b44",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.trigger_type }}",
                    "rightValue": "day_3"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "347fc24c-95ee-42aa-9e3c-ad02e33428c9",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.trigger_type }}",
                    "rightValue": "day_7"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "5520a26b-6a28-4141-bbf4-7e37cec1079c",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.trigger_type }}",
                    "rightValue": "day_13"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "3cc30190-7990-4077-9637-89e6f03a84d0",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.trigger_type }}",
                    "rightValue": "last_day"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.4
    },
    {
      "id": "1eaed7c1-fde9-48cb-827e-59b7650cefa7",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        6816,
        4224
      ],
      "parameters": {
        "numberInputs": 4
      },
      "typeVersion": 3.2
    },
    {
      "id": "f891dc78-12dc-4788-b930-613bcdd2f177",
      "name": "Send day 3 email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        6592,
        3968
      ],
      "parameters": {
        "sendTo": "={{ $json.email }}",
        "message": "=<!DOCTYPE html>\n<html>\n<body style=\"font-family: Arial, sans-serif; line-height: 1.6; color: #333;\">\n  <p>Hi {{$json.name}},</p>\n\n  <p>Welcome to <strong>RecruitEase</strong>!</p>\n\n  <p>It's been a couple of days since you started your trial. Have you explored how easy hiring can be?</p>\n\n  <ul>\n    <li>Post job openings in minutes</li>\n    <li>Automatically analyze resumes with AI</li>\n    <li>Shortlist candidates using smart fit scoring</li>\n  </ul>\n\n  <p>Most recruiters see results within their first few job postings.</p>\n\n<p>\n    <a href=\"{{app_link}}\" style=\"background:#4CAF50;color:#fff;padding:10px 15px;text-decoration:none;border-radius:5px;\">\n      Start Hiring Now\n    </a>\n  </p>\n\n  <p>If you need help, just reply to this email \u2014 we\u2019re here for you.</p>\n\n  <p>Best regards,<br>Team RecruitEase</p>\n</body>\n</html>",
        "options": {},
        "subject": "Start hiring smarter with RecruitEase"
      },
      "typeVersion": 2.2
    },
    {
      "id": "7614911e-e4c1-4aac-9570-699aa04ffe3f",
      "name": "Send day 7 mail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        6592,
        4160
      ],
      "parameters": {
        "sendTo": "{{ $json.email }}",
        "message": "=<!DOCTYPE html> <html> <body style=\"font-family: Arial, sans-serif; line-height: 1.6; color: #333;\">   <p>Hi {{$json.name}},</p>    <p>You\u2019re halfway through your <strong>RecruitEase</strong> trial \u2014 let\u2019s make it count.</p>    <ul>     <li>Evaluate candidates with AI-powered resume analysis</li>     <li>Get smart candidate suggestions instantly</li>     <li>Schedule interviews and track hiring status effortlessly</li>   </ul>    <p>RecruitEase helps you save time and make better hiring decisions.</p>    <p>     <a href=\"{{app_link}}\" style=\"background:#2196F3;color:#fff;padding:10px 15px;text-decoration:none;border-radius:5px;\">       Explore Features     </a>   </p>    <p>Need help? Just reply \u2014 we\u2019re here for you.</p>    <p>Best regards,<br>Team RecruitEase</p> </body> </html>",
        "options": {},
        "subject": "You're halfway there \u2014 unlock smarter hiring"
      },
      "typeVersion": 2.2
    },
    {
      "id": "9e0b3c3c-668e-4282-baf6-532e255354e8",
      "name": "Send day 13 mail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        6592,
        4352
      ],
      "parameters": {
        "sendTo": "={{ $json.email }}",
        "message": "=<!DOCTYPE html> <html> <body style=\"font-family: Arial, sans-serif; line-height: 1.6; color: #333;\">   <p>Hi {{$json.name}},</p>    <p>Your <strong>RecruitEase</strong> trial is about to end.</p>    <p>Before it expires, make sure you:</p>    <ul>     <li>Try resume analysis & fit scoring</li>     <li>Explore candidate recommendations</li>     <li>Experience automated hiring workflows</li>   </ul>    <p>     <a href=\"{{app_link}}\" style=\"background:#FF9800;color:#fff;padding:10px 15px;text-decoration:none;border-radius:5px;\">       Continue Now     </a>   </p>    <p>You\u2019re just one step away from transforming your hiring process.</p>    <p>Best regards,<br>Team RecruitEase</p> </body> </html>",
        "options": {},
        "subject": "Your RecruitEase trial is almost over"
      },
      "typeVersion": 2.2
    },
    {
      "id": "0914ef25-8817-416e-b694-5f99e93b464e",
      "name": "Send Last day email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        6592,
        4544
      ],
      "parameters": {
        "sendTo": "={{ $json.email }}",
        "message": "=<!DOCTYPE html> <html> <body style=\"font-family: Arial, sans-serif; line-height: 1.6; color: #333;\">   <p>Hi {{$json.name}},</p>    <p>This is your <strong>final day</strong> of the RecruitEase trial.</p>    <p>After today, your access will expire and your hiring workflow may be interrupted.</p>    <p>If you\u2019ve found value in simplifying recruitment with automation, now is the perfect time to upgrade.</p>    <p>     <a href=\"{{upgrade_link}}\" style=\"background:#f44336;color:#fff;padding:10px 15px;text-decoration:none;border-radius:5px;\">       Upgrade Now     </a>   </p>    <p>Continue hiring smarter, faster, and more efficiently with RecruitEase.</p>    <p>Best regards,<br>Team RecruitEase</p> </body> </html>",
        "options": {},
        "subject": "Last day \u2014 don\u2019t lose your hiring progress"
      },
      "typeVersion": 2.2
    },
    {
      "id": "f474438b-6111-41d2-bf83-48869bc9ff55",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4736,
        3712
      ],
      "parameters": {
        "width": 656,
        "height": 1008,
        "content": "# Automated SaaS Trial Expiry Nudge Sequence\n\nThis workflow automates follow-up emails for users during their SaaS trial period. It ensures timely engagement by sending personalized nudges at key intervals\u2014Day 3, Day 7, Day 13, and the final day before trial expiry. This helps improve user activation, retention, and conversion without manual tracking.\n\nThe workflow runs daily, checks user subscription data, and determines which stage each user is in. Based on this, it triggers the appropriate email communication. Each email is designed to guide users toward product adoption and encourage conversion before the trial ends.\n\n### How it works\n- Workflow runs daily at midnight  \n- User data is fetched from database/spreadsheet  \n- Trial dates are analyzed to determine stage  \n- Users are tagged (Day 3, 7, 13, Last Day)  \n- Loop processes each eligible user  \n- Relevant email is sent based on stage  \n\n### Setup\n- Configure Schedule Trigger (daily midnight).  \n- Connect your database or spreadsheet.  \n- Ensure plan start/end dates are available. \n- Connect Gmail account credentials (or any email provider).  \n- Emails are based on a demo SaaS \u2014 update content to match your product."
      },
      "typeVersion": 1
    },
    {
      "id": "7100a310-ea36-4793-b9dd-12ef2e358460",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6064,
        3712
      ],
      "parameters": {
        "color": 7,
        "width": 928,
        "height": 1008,
        "content": "## Step 2 : Send Stage-Based Nudge Emails\n\nLoops through filtered users and sends the appropriate email based on trial stage. "
      },
      "typeVersion": 1
    },
    {
      "id": "026919c7-514f-4f18-80f5-1a25108e7ae4",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5424,
        3712
      ],
      "parameters": {
        "color": 7,
        "width": 608,
        "height": 1008,
        "content": "## Step 1 : Fetch & Filter Trial Users\n\nRuns daily at midnight, retrieves user and plan data, and filters users based on their trial stage (Day 3, 7, 13, or last day before expiry)."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Send day 3 email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send day 7 mail",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send day 13 mail",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Last day email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find documents": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send day 7 mail": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Find documents",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send day 13 mail": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Send day 3 email": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Last day email": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 3
          }
        ]
      ]
    }
  }
}