{
  "name": "2. Welcome Email Sequence \u2014 HubSpot \u2192 Gmail",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 24,
              "triggerAtHour": 9
            }
          ]
        }
      },
      "id": "node-schedule",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "resource": "engagement",
        "operation": "getAll",
        "returnAll": true,
        "filters": {}
      },
      "id": "node-hubspot1",
      "name": "HubSpot",
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 2,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "cond1",
              "leftValue": "={{ $json.title }}",
              "rightValue": "Send email day",
              "operator": {
                "type": "string",
                "operation": "contains"
              }
            }
          ],
          "combinator": "and"
        }
      },
      "id": "node-filter",
      "name": "Filter",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2,
      "position": [
        680,
        300
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "https://docs.google.com/document/d/TODO/export?format=txt",
        "options": {}
      },
      "id": "node-http",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        900,
        300
      ]
    },
    {
      "parameters": {
        "language": "javaScript",
        "jsCode": "const dayMatch = $input.first().json.title.match(/day\\s*(\\d+)/i);\nconst dayNum = dayMatch ? dayMatch[1] : \"1\";\nconst fullText = $input.last().json.body || $input.last().json.data || \"\";\n// Split by \"## Day X\" markers\nconst sections = fullText.split(/##\\s*Day\\s*\\d+/i);\nconst sectionIndex = parseInt(dayNum);\nconst emailContent = sections[sectionIndex] || sections[1] || \"\";\nconst subjectMatch = emailContent.match(/Subject:\\s*(.+)/i);\nconst subject = subjectMatch ? subjectMatch[1].trim() : `Pals By Design \u2014 Day ${dayNum}`;\nconst body = emailContent.replace(/Subject:.*\\n/i, '').trim();\nreturn [{ json: { subject, body, day: dayNum } }];"
      },
      "id": "node-code",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1120,
        300
      ]
    },
    {
      "parameters": {
        "sendTo": "TODO",
        "subject": "={{ $json.subject }}",
        "message": "={{ $json.body }}",
        "options": {}
      },
      "id": "node-gmail",
      "name": "Gmail",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1340,
        300
      ]
    },
    {
      "parameters": {
        "resource": "task",
        "operation": "update",
        "taskId": "={{ $('HubSpot').item.json.id }}",
        "updateFields": {
          "status": "COMPLETED"
        }
      },
      "id": "node-hubspot2",
      "name": "HubSpot1",
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 2,
      "position": [
        1560,
        300
      ]
    }
  ],
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "HubSpot",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HubSpot": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail": {
      "main": [
        [
          {
            "node": "HubSpot1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {}
}