Skip to content

In n8n, copy this file and paste it onto the canvas, or use Import from File.

{
  "name": "03 - Google Sheets Lead Tracker (starter)",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "lead",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "m03-webhook",
      "name": "New Lead",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        100
      ],
      "webhookId": "course-03-lead"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "n1",
              "name": "email",
              "value": "={{ String($json.body.email ?? '').trim().toLowerCase() }}",
              "type": "string"
            },
            {
              "id": "n2",
              "name": "name",
              "value": "={{ String($json.body.name ?? '').trim() }}",
              "type": "string"
            },
            {
              "id": "n3",
              "name": "source",
              "value": "={{ String($json.body.source ?? 'website').trim().toLowerCase() }}",
              "type": "string"
            },
            {
              "id": "n4",
              "name": "updated_at",
              "value": "={{ $now.toISO() }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "m03-normalize",
      "name": "Normalize",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        100
      ]
    },
    {
      "parameters": {
        "content": "## Your task\n1. Create a Google Sheet with a **Leads** tab and headers: `email, name, source, updated_at` (see assets/leads-template.csv).\n2. Add an IF that rejects leads without a name or a valid email (regex).\n3. Valid → Google Sheets **Append or Update Row**, matching on `email` → respond `{status:'saved'}`.\n4. Invalid → respond 400 with an error message.\n\nTest: `./test/test.sh` then `WITH_CREDS=1 ./test/test.sh`",
        "height": 260,
        "width": 420
      },
      "id": "starter-task-note",
      "name": "Your Task",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        -340
      ]
    }
  ],
  "connections": {
    "New Lead": {
      "main": [
        [
          {
            "node": "Normalize",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize": {
      "main": [
        []
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  }
}