{
  "name": "Twilio Callback - Ecotrustia Lead Gen",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "twilio-callback",
        "responseMode": "onReceived",
        "options": {}
      },
      "id": "node-webhook",
      "name": "Twilio Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        200,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "conditions": [
            {
              "leftValue": "={{ $json.body.Digits }}",
              "rightValue": "1",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "node-check-digits",
      "name": "Did User Press 1?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        420,
        300
      ]
    },
    {
      "parameters": {
        "operation": "read",
        "documentId": {
          "value": "YOUR_GOOGLE_SHEET_ID_HERE",
          "mode": "id"
        },
        "sheetName": {
          "value": "Leads",
          "mode": "name"
        },
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "Call SID",
              "lookupValue": "={{ $('Twilio Webhook').first().json.body.CallSid }}"
            }
          ]
        },
        "options": {}
      },
      "id": "node-read-sheet",
      "name": "Google Sheets - Lookup Lead by Call SID",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.4,
      "position": [
        640,
        200
      ]
    },
    {
      "parameters": {
        "sendTo": "={{ $json['Email'] || $json.email }}",
        "subject": "=Following up - {{ $json['Recommended Service'] || $json.recommended_service }} for {{ $json['Business Name'] || $json.business_name }}",
        "message": "=Hi,\n\nThank you for taking the time to speak with us today.\n\nAs discussed, we noticed that {{ $json.one_line_summary || $json['Notes'] || 'your website could benefit from some improvements' }}.\n\nAt Ecotrustia Solutions, we specialise in helping UK businesses grow online. Based on our review of your online presence, we recommend our {{ $json['Recommended Service'] || $json.recommended_service }} service.\n\nWhat we can do for you:\n- Professional, fast, mobile-friendly website\n- SEO to help you rank on Google UK\n- AI-powered chatbots and business automation\n- E-commerce solutions to sell online\n\nWe would love to put together a free proposal for you. Simply reply to this email or call us back and we will get started.\n\nBest regards,\nAhmed Ali Jawad\n\nwww.ecotrustia.com\n+44 XXXX XXXXXX",
        "options": {}
      },
      "id": "node-send-email",
      "name": "Gmail - Send Follow-up Email",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        860,
        200
      ]
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "value": "YOUR_GOOGLE_SHEET_ID_HERE",
          "mode": "id"
        },
        "sheetName": {
          "value": "Leads",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Client Interested": "Yes",
            "Notes": "=INTERESTED - Follow-up email sent {{ new Date().toLocaleDateString('en-GB') }}"
          }
        },
        "where": {
          "values": [
            {
              "column": "Place ID",
              "value": "={{ $json.place_id || $json['Place ID'] }}"
            }
          ]
        },
        "options": {}
      },
      "id": "node-flag-interested",
      "name": "Google Sheets - Flag Client as Interested",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.4,
      "position": [
        1080,
        200
      ]
    }
  ],
  "connections": {
    "Twilio Webhook": {
      "main": [
        [
          {
            "node": "Did User Press 1?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Did User Press 1?": {
      "main": [
        [
          {
            "node": "Google Sheets - Lookup Lead by Call SID",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Google Sheets - Lookup Lead by Call SID": {
      "main": [
        [
          {
            "node": "Gmail - Send Follow-up Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail - Send Follow-up Email": {
      "main": [
        [
          {
            "node": "Google Sheets - Flag Client as Interested",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {},
  "staticData": null,
  "tags": [
    {
      "name": "Ecotrustia Solutions"
    },
    {
      "name": "Twilio Webhook"
    }
  ]
}