{
  "nodes": [
    {
      "id": "9c9c4619-6e83-4a31-b783-c1250540b6ff",
      "name": "Get yesterday dates",
      "type": "n8n-nodes-base.code",
      "position": [
        380,
        480
      ],
      "parameters": {
        "jsCode": "function formatToSupabaseTimestamp(date) {\n  const iso = date.toISOString();\n  const [datePart, ms = \"000\"] = iso.split('.')[1]?.split('Z') || [\"000\"];\n  const paddedMicro = (ms + \"000000\").slice(0, 6);\n  return iso.replace(/\\.\\d+Z/, `.${paddedMicro}+00:00`);\n}\n\nconst now = new Date();\n\nconst yesterday = new Date(now);\nyesterday.setDate(now.getDate() - 1);\nyesterday.setHours(0, 0, 0, 0);\n\nconst start = new Date(yesterday);\nconst end = new Date(yesterday);\nend.setHours(23, 59, 59, 999);\n\nreturn [\n  {\n    json: {\n      isoStart: formatToSupabaseTimestamp(start),\n      isoEnd: formatToSupabaseTimestamp(end)\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "381fac0c-25bc-4322-980d-009012378923",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        660,
        320
      ],
      "parameters": {
        "width": 360,
        "height": 340,
        "content": "## Fetch All Users\nThis step fetches all users from your database and filters them based on the selected date range (e.g., yesterday, last 7 days, etc.)."
      },
      "typeVersion": 1
    },
    {
      "id": "d216b2d6-ae67-451f-923d-5bd07f847b00",
      "name": "Append row for semi-qualified",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1560,
        120
      ],
      "parameters": {
        "columns": {
          "value": {
            "ID": "={{ $('Date Filtered Users').item.json.id }}",
            "Name ": "={{ $('Date Filtered Users').item.json.first_name }}",
            "Email ": "={{ $('Date Filtered Users').item.json.email }}",
            "created_at": "={{ $('Date Filtered Users').item.json.created_at}}"
          },
          "schema": [
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Name ",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Name ",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email ",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Email ",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "created_at",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "created_at",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "message",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "message",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "payload",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "payload",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "ID"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ZfV7CLtXKzNtiQcF_9XgHUwyVn467hpYrwFaQ3Hfhmc/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1ZfV7CLtXKzNtiQcF_9XgHUwyVn467hpYrwFaQ3Hfhmc",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ZfV7CLtXKzNtiQcF_9XgHUwyVn467hpYrwFaQ3Hfhmc/edit?usp=drivesdk",
          "cachedResultName": "database fetch "
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "dbb1cba5-658e-4065-b8d7-5d7dc0d994aa",
      "name": "Fetch all users from database",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        680,
        120
      ],
      "parameters": {
        "url": "ADD YOUR DATABASE URL",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "apikey",
              "value": "ADD YOUR DATABASE ANON KEY"
            },
            {
              "name": "Authorization",
              "value": "ADD YOUR SERVICE ROLE KEY (ADD bearer BEFORE SR KEY)"
            }
          ]
        }
      },
      "typeVersion": 4
    },
    {
      "id": "1281e124-bf06-4dae-a232-2142d566fb20",
      "name": "Date Filtered Users",
      "type": "n8n-nodes-base.code",
      "position": [
        880,
        120
      ],
      "parameters": {
        "jsCode": "const isoStart = $items(\"Get yesterday dates\")[0].json.isoStart;\nconst isoEnd = $items(\"Get yesterday dates\")[0].json.isoEnd;\n\nreturn items\n  .filter(item => {\n    const createdAt = new Date(item.json.created_at);\n    const start = new Date(isoStart);\n    const end = new Date(isoEnd);\n    return createdAt >= start && createdAt <= end;\n  })\n  .map(item => {\n    const [first_name, ...rest] = item.json.full_name.split(' ');\n    const last_name = rest.join(' ') || '';\n    return {\n      json: {\n        id: item.json.id,\n        first_name: first_name,\n        last_name: last_name,\n        email: item.json.email,\n        created_at: item.json.created_at\n      }\n    };\n  });\n"
      },
      "typeVersion": 2
    },
    {
      "id": "f54a17c0-b64c-4da7-b9d6-4e52768db0a9",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 1820,
        "height": 700,
        "content": "## **OnboardTrigger:  Signup to Saleshandy Sequence**\nAutomatically connects your new application signups from the database to a targeted Saleshandy email sequence. This ensures every new user receives timely, personalized outreach, whether it\u2019s for onboarding, nudging them to purchase a plan, or sharing any custom message. "
      },
      "typeVersion": 1
    },
    {
      "id": "79afa502-655d-4431-8fca-f32ec7abdb51",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        20,
        280
      ],
      "parameters": {
        "height": 320,
        "content": "## Trigger this workflow to reach every new signup \u2014> daily.\n\nMake it part of your everyday routine to automatically fetch leads from your app, add them to a Saleshandy sequence, and send timely emails to engage, nurture, and encourage them to become paying customers"
      },
      "typeVersion": 1
    },
    {
      "id": "266fdde0-d952-4a11-bc7f-8bc52b5845ec",
      "name": "Trigger Everyday",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        100,
        120
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "4b47add8-1967-4769-a355-58b88151d147",
      "name": "Add new signup to Saleshandy's Sequence",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1200,
        520
      ],
      "parameters": {
        "url": "https://open-api.saleshandy.com/v1/sequences/prospects/import-with-field-name",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"prospectList\": [\n    {\n      \"First Name\": \"{{ $json['first_name']}}\",\n      \"Email\": \"{{ $json['email']}}\"\n    }\n  ],\n  \"stepId\": \"ADD YOUR SALESHANDY SEQUENCE ID\",\n  \"verifyProspects\": false,\n  \"conflictAction\": \"overwrite\"\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key",
              "value": "ADD YOUR SALESHANDY API KEY"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "dae2032f-b0f1-4d41-ad01-d01748e12fad",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        120
      ],
      "parameters": {
        "height": 200,
        "content": "## Date Generator\nGenerates **yesterday\u2019s date** for filtering signups in the next steps.\n\n**Note:** You can update this to any range; day, week, or month, as needed."
      },
      "typeVersion": 1
    },
    {
      "id": "06b5b4d0-a5cb-4fd8-84b2-5462a91d70bd",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1100,
        100
      ],
      "parameters": {
        "width": 320,
        "height": 400,
        "content": "## Connect to Saleshandy's Sequence \nThis step connects to your Saleshandy sequence, allowing you to automatically send customized emails to your new users as part of your outreach flow."
      },
      "typeVersion": 1
    },
    {
      "id": "76700793-0958-495d-8d6d-d4d2b98bd976",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        680,
        440
      ],
      "parameters": {
        "color": 3,
        "width": 320,
        "height": 200,
        "content": "## What you need to update:\nMake sure to update the node with your actual:\n**Database URL**\n**Public Anon Key**\n**Service Role Key**\nThese are required to authenticate and query your database correctly."
      },
      "typeVersion": 1
    },
    {
      "id": "a10100f0-5c60-4320-bcb7-b07dfd7fb153",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        340,
        340
      ],
      "parameters": {
        "color": 3,
        "width": 180,
        "height": 80,
        "content": "by default Yesterday's date is set"
      },
      "typeVersion": 1
    },
    {
      "id": "c7b44a55-ec88-4ba3-94b5-dcbd5be785ba",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1120,
        280
      ],
      "parameters": {
        "color": 3,
        "width": 280,
        "height": 200,
        "content": "## What you need to update:\nAdd the following values to this node for it to work correctly:\n**Saleshandy API Key**\n**Your Sequence ID** (retrieved from your Saleshandy sequence)"
      },
      "typeVersion": 1
    },
    {
      "id": "a7dec1af-92fb-4a1b-8576-8fedb3fe5fdf",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1480,
        300
      ],
      "parameters": {
        "width": 320,
        "height": 340,
        "content": "## Append to Google Sheets\nThis step appends your latest user data to a selected Google Sheet for tracking, analysis, or backup."
      },
      "typeVersion": 1
    },
    {
      "id": "21032964-c416-4a79-8169-b1ae8a437b51",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1500,
        420
      ],
      "parameters": {
        "color": 3,
        "width": 280,
        "height": 200,
        "content": "## What you need to update:\nConnect your Google Sheets account\n**Select the target sheet**\nEnsure the sheet has the following columns:\n**ID, Name, Email, Created_at**"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Trigger Everyday": {
      "main": [
        [
          {
            "node": "Get yesterday dates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Date Filtered Users": {
      "main": [
        [
          {
            "node": "Add new signup to Saleshandy's Sequence",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get yesterday dates": {
      "main": [
        [
          {
            "node": "Fetch all users from database",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch all users from database": {
      "main": [
        [
          {
            "node": "Date Filtered Users",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add new signup to Saleshandy's Sequence": {
      "main": [
        [
          {
            "node": "Append row for semi-qualified",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}