{
  "name": "FlowPantry - Text new web-form leads within 60 seconds",
  "nodes": [
    {
      "id": "539296b7-29ef-48bb-8bbb-f049483fa4d2",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        300
      ],
      "parameters": {
        "httpMethod": "POST",
        "path": "new-lead",
        "responseMode": "onReceived",
        "options": {}
      },
      "webhookId": "de71c4aa-eada-4c5d-ad94-898987cf06b5"
    },
    {
      "id": "76ac206c-d33f-4db9-b371-e9dca0065758",
      "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": "73e13411-dd9a-4642-84c2-143bd54b09a6",
      "name": "Text the lead",
      "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}}, thanks for reaching out to {{$env.BUSINESS_NAME}}! We got your request and will call you shortly. Reply here anytime. Reply STOP to opt out."
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "cb1fb867-996a-4b65-bbe9-0a3afb3be612",
      "name": "Alert owner",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        720,
        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": "={{$env.OWNER_PHONE}}"
            },
            {
              "name": "From",
              "value": "={{$env.TWILIO_FROM_NUMBER}}"
            },
            {
              "name": "Body",
              "value": "=New lead: {{$('Normalize lead').item.json.name}} {{$('Normalize lead').item.json.phone}} via {{$('Normalize lead').item.json.source}}: {{$('Normalize lead').item.json.message}}"
            }
          ]
        },
        "options": {}
      }
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Normalize lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize lead": {
      "main": [
        [
          {
            "node": "Text the lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Text the lead": {
      "main": [
        [
          {
            "node": "Alert owner",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {}
}