{
  "name": "FlowPantry - 5-touch follow-up for leads who don't reply",
  "nodes": [
    {
      "id": "7986be52-64ad-4370-bf6d-d1b8e8bea88b",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        300
      ],
      "parameters": {
        "httpMethod": "POST",
        "path": "nurture-start",
        "responseMode": "onReceived",
        "options": {}
      },
      "webhookId": "d569a720-14ab-4cb2-a22c-d1df3fe8b377"
    },
    {
      "id": "d085f1da-11bd-49d3-b64c-2976fd8c01c5",
      "name": "Normalize lead",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        240,
        300
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "return $input.all().map(i=>{const b=i.json.body||i.json;return {json:{name:(b.name||'there').split(' ')[0],phone:b.phone,email:b.email,source:b.source||'web form',message:b.message||''}}}).filter(i=>i.json.phone);"
      }
    },
    {
      "id": "ad0b09e8-020d-4d29-95f3-edc02582862d",
      "name": "Touch 1 SMS",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        480,
        300
      ],
      "parameters": {
        "method": "POST",
        "url": "=https://api.twilio.com/2010-04-01/Accounts/{{$env.TWILIO_ACCOUNT_SID}}/Messages.json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth",
        "sendBody": true,
        "contentType": "form-urlencoded",
        "bodyParameters": {
          "parameters": [
            {
              "name": "To",
              "value": "={{$json.phone}}"
            },
            {
              "name": "From",
              "value": "={{$env.TWILIO_FROM_NUMBER}}"
            },
            {
              "name": "Body",
              "value": "=Hi {{$json.name}}, {{$env.BUSINESS_NAME}} here. Got a minute to chat about your request? Reply STOP to opt out."
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "d0508cb8-924f-45b4-be37-907322d902f6",
      "name": "Wait 1 day",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        720,
        300
      ],
      "parameters": {
        "amount": 1,
        "unit": "days"
      }
    },
    {
      "id": "cf0a6474-cff1-421d-b810-b0f2420f153b",
      "name": "Check status 1",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        960,
        300
      ],
      "parameters": {
        "url": "={{$env.STATUS_URL}}?email={{$('Normalize lead').item.json.email}}",
        "options": {}
      }
    },
    {
      "id": "bfa9f08f-1ba9-4604-bcc2-91a88adbacb5",
      "name": "Stop if replied 1",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1200,
        300
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "return $input.all().filter(i=>!i.json.replied);"
      }
    },
    {
      "id": "94159b83-2a5e-4854-96b8-b141563da464",
      "name": "Touch 2 email",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1440,
        300
      ],
      "parameters": {
        "method": "POST",
        "url": "https://api.resend.com/emails",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({from: $env.FROM_EMAIL, to: $('Normalize lead').item.json.email, subject: 'Quick question, '+$('Normalize lead').item.json.name, html: '<p>Still interested? Grab a time here: '+$env.BOOKING_URL+'</p>'}) }}",
        "options": {}
      }
    },
    {
      "id": "c13386cf-174d-4c63-a7e6-153f600d89ee",
      "name": "Wait 2 days",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1680,
        300
      ],
      "parameters": {
        "amount": 2,
        "unit": "days"
      }
    },
    {
      "id": "b203756c-2964-4e0a-ad17-359fbaf994ac",
      "name": "Check status 2",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1920,
        300
      ],
      "parameters": {
        "url": "={{$env.STATUS_URL}}?email={{$('Normalize lead').item.json.email}}",
        "options": {}
      }
    },
    {
      "id": "c767defb-b9ec-48a3-96e0-0d65f8eaf447",
      "name": "Stop if replied 2",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2160,
        300
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "return $input.all().filter(i=>!i.json.replied);"
      }
    },
    {
      "id": "033520cd-ac58-405c-a16e-f2ac04813f34",
      "name": "Touch 3 SMS",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2400,
        300
      ],
      "parameters": {
        "method": "POST",
        "url": "=https://api.twilio.com/2010-04-01/Accounts/{{$env.TWILIO_ACCOUNT_SID}}/Messages.json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth",
        "sendBody": true,
        "contentType": "form-urlencoded",
        "bodyParameters": {
          "parameters": [
            {
              "name": "To",
              "value": "={{$('Normalize lead').item.json.phone}}"
            },
            {
              "name": "From",
              "value": "={{$env.TWILIO_FROM_NUMBER}}"
            },
            {
              "name": "Body",
              "value": "=Hi {{$('Normalize lead').item.json.name}}, just checking in. Happy to answer any questions. Book here: {{$env.BOOKING_URL}}"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "995ab5ee-3e04-4831-bfd4-3f8fadadc8ac",
      "name": "Wait 2 more days",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        2640,
        300
      ],
      "parameters": {
        "amount": 2,
        "unit": "days"
      }
    },
    {
      "id": "201668e8-73fc-4e74-8c24-979d2de8fc19",
      "name": "Check status 3",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2880,
        300
      ],
      "parameters": {
        "url": "={{$env.STATUS_URL}}?email={{$('Normalize lead').item.json.email}}",
        "options": {}
      }
    },
    {
      "id": "e4e2e47f-051f-4d7e-9671-68ab10836d8b",
      "name": "Stop if replied 3",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        3120,
        300
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "return $input.all().filter(i=>!i.json.replied);"
      }
    },
    {
      "id": "ca38f9a6-f257-4a82-8c3b-13001a1a110f",
      "name": "Touch 4 email",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        3360,
        300
      ],
      "parameters": {
        "method": "POST",
        "url": "https://api.resend.com/emails",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({from: $env.FROM_EMAIL, to: $('Normalize lead').item.json.email, subject: 'A few answers to common questions', html: '<p>Here is what most customers ask us before booking... '+$env.BOOKING_URL+'</p>'}) }}",
        "options": {}
      }
    },
    {
      "id": "f17a80ed-2f7c-4be7-a698-d577442678ca",
      "name": "Wait 2 days more",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        3600,
        300
      ],
      "parameters": {
        "amount": 2,
        "unit": "days"
      }
    },
    {
      "id": "10396dce-778e-41f9-8eab-d72f67c1f0b2",
      "name": "Check status 4",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        3840,
        300
      ],
      "parameters": {
        "url": "={{$env.STATUS_URL}}?email={{$('Normalize lead').item.json.email}}",
        "options": {}
      }
    },
    {
      "id": "7b8c76e1-5f6e-4495-8bb5-8d425c5aff4a",
      "name": "Stop if replied 4",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        4080,
        300
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "return $input.all().filter(i=>!i.json.replied);"
      }
    },
    {
      "id": "4599e688-867d-4506-a1f1-06f22fcb1533",
      "name": "Touch 5 breakup SMS",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        4320,
        300
      ],
      "parameters": {
        "method": "POST",
        "url": "=https://api.twilio.com/2010-04-01/Accounts/{{$env.TWILIO_ACCOUNT_SID}}/Messages.json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth",
        "sendBody": true,
        "contentType": "form-urlencoded",
        "bodyParameters": {
          "parameters": [
            {
              "name": "To",
              "value": "={{$('Normalize lead').item.json.phone}}"
            },
            {
              "name": "From",
              "value": "={{$env.TWILIO_FROM_NUMBER}}"
            },
            {
              "name": "Body",
              "value": "=Hi {{$('Normalize lead').item.json.name}}, should I close out your request? Just reply YES to keep it open."
            }
          ]
        },
        "options": {}
      }
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Normalize lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize lead": {
      "main": [
        [
          {
            "node": "Touch 1 SMS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Touch 1 SMS": {
      "main": [
        [
          {
            "node": "Wait 1 day",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 1 day": {
      "main": [
        [
          {
            "node": "Check status 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check status 1": {
      "main": [
        [
          {
            "node": "Stop if replied 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Stop if replied 1": {
      "main": [
        [
          {
            "node": "Touch 2 email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Touch 2 email": {
      "main": [
        [
          {
            "node": "Wait 2 days",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 2 days": {
      "main": [
        [
          {
            "node": "Check status 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check status 2": {
      "main": [
        [
          {
            "node": "Stop if replied 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Stop if replied 2": {
      "main": [
        [
          {
            "node": "Touch 3 SMS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Touch 3 SMS": {
      "main": [
        [
          {
            "node": "Wait 2 more days",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 2 more days": {
      "main": [
        [
          {
            "node": "Check status 3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check status 3": {
      "main": [
        [
          {
            "node": "Stop if replied 3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Stop if replied 3": {
      "main": [
        [
          {
            "node": "Touch 4 email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Touch 4 email": {
      "main": [
        [
          {
            "node": "Wait 2 days more",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 2 days more": {
      "main": [
        [
          {
            "node": "Check status 4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check status 4": {
      "main": [
        [
          {
            "node": "Stop if replied 4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Stop if replied 4": {
      "main": [
        [
          {
            "node": "Touch 5 breakup SMS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {}
}