{
  "nodes": [
    {
      "id": "98950cec-38f2-4bb6-87f2-225ae7251c4c",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -960,
        112
      ],
      "parameters": {
        "options": {},
        "formTitle": "Test Form",
        "formFields": {
          "values": [
            {
              "fieldLabel": "First Name",
              "requiredField": true
            },
            {
              "fieldLabel": "Last Name",
              "requiredField": true
            },
            {
              "fieldLabel": "Email",
              "requiredField": true
            },
            {
              "fieldType": "dropdown",
              "fieldLabel": "Budget",
              "fieldOptions": {
                "values": [
                  {
                    "option": "0-1000"
                  },
                  {
                    "option": "1000+"
                  },
                  {
                    "option": "0-100"
                  }
                ]
              },
              "requiredField": true
            },
            {
              "fieldLabel": "Message"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "71a3c48f-48ba-4532-82b9-77c95c85e2d9",
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -960,
        368
      ],
      "parameters": {
        "columns": {
          "value": {
            "Email": "={ { $json.Email } }",
            "Budget": "={ { $json.Budget } }",
            "Called": "FALSE",
            "Message": "={ { $json.Message } }",
            "Rejected": "={ { $if( $json.Budget == \"1000+\", \"FALSE\", \"TRUE\") } }",
            "Last Name": "={ { $json['Last Name'] } }",
            "First Name": "={ { $json['First Name'] } }",
            "submittedAt": "={ { $today} }"
          }
        },
        "operation": "appendOrUpdate",
        "sheetName": "Sheet1",
        "documentId": "$env.GOOGLE_SHEET_ID"
      },
      "typeVersion": 4.5,
      "alwaysOutputData": false
    },
    {
      "id": "062f9ffa-97d8-441f-9639-4cb7911ab593",
      "name": "Filter",
      "type": "n8n-nodes-base.filter",
      "position": [
        -960,
        240
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "ea08ed8a-56e6-4ab8-ab5f-72f30427cffa",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={ { $json.Budget } }",
              "rightValue": "0-100"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "1e3d36e9-3950-4092-aa90-26a284781f20",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        -960,
        496
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "362424ed-4d9a-46ef-8dda-3dd7c373d9f6",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={ { $('On form submission').item.json.Budget } }",
                    "rightValue": "0-1000"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "514dc66e-9528-411f-a617-3e64e1d8c9a7",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={ { $('On form submission').item.json.Budget } }",
                    "rightValue": "1000+"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "f6203441-3b59-4f16-ac67-a0c6282a683a",
      "name": "Gmail1",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -720,
        352
      ],
      "parameters": {
        "sendTo": "={ { $('On form submission').item.json.Email } }",
        "message": "=Hey  { { $('On form submission').item.json['First Name'] } },\\n\\nThanks for inquiring with our services, can you book a call on my calendar link here:\\nhttps://calendly.com/your-calendly-link\\n\\nBest,\\nYour Name",
        "options": {
          "appendAttribution": false
        },
        "subject": "Hey, thanks for inquiring with us",
        "emailType": "text"
      },
      "typeVersion": 2.1
    },
    {
      "id": "254cff56-6317-4784-b647-6ebb2b8e2723",
      "name": "Gmail2",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -544,
        112
      ],
      "parameters": {
        "sendTo": "={ { $env.ADMIN_EMAIL } }",
        "message": "=New Lead\\n\\nName: { { $('On form submission').item.json['First Name'] } } { { $('On form submission').item.json['Last Name'] } }\\nEmail: { { $('On form submission').item.json.Email } }\\nBudget: { { $('On form submission').item.json.Budget } }\\nMessage: { { $('On form submission').item.json.Message } }\\n",
        "options": {
          "appendAttribution": false
        },
        "subject": "New Lead",
        "emailType": "text"
      },
      "typeVersion": 2.1
    },
    {
      "id": "e208a08b-59dd-4d0a-bb8c-c0460da3f5de",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -224,
        176
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 20
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7e67b596-f9aa-49e4-ae07-d5602466bba9",
      "name": "Google Sheets1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -224,
        304
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={ { $today } }",
              "lookupColumn": "submittedAt"
            }
          ]
        },
        "sheetName": "Sheet1",
        "documentId": "$env.GOOGLE_SHEET_ID"
      },
      "typeVersion": 4.5,
      "alwaysOutputData": false
    },
    {
      "id": "0b391289-7746-46a7-96f4-636a87109308",
      "name": "Filter1",
      "type": "n8n-nodes-base.filter",
      "position": [
        -16,
        400
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "9d637327-f114-4457-ae65-c8fdb71f2d03",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={ { $json.Called } }",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "Filter2",
      "type": "n8n-nodes-base.filter",
      "position": [
        -16,
        192
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "7108fcd1-b850-45b5-90ad-a1904490137b",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              },
              "leftValue": "={ { $json.Called } }",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "c0c978d9-4b17-4b79-9360-9ef7028c8d73",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        256,
        192
      ],
      "parameters": {
        "jsCode": "const people = items[0].json.data;\n\nconst textOutput = people.map(person =>\n  `Name: ${person[\"First Name\"]} ${person[\"Last Name\"]}\\n` + \n  `Email: ${person[\"Email\"]}\\n` + \n  `Budget: ${person[\"Budget \"]}\\n` + \n  `Message: ${person[\"Message\"]}`\n).join(\"\\n\\n\");\n\nreturn [{ json: { text: textOutput } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "2427ad1f-250b-4695-97c5-677ee4ee8551",
      "name": "Gmail4",
      "type": "n8n-nodes-base.gmail",
      "position": [
        384,
        192
      ],
      "parameters": {
        "message": "={ { $json.text } }",
        "options": {
          "appendAttribution": false
        },
        "subject": "Uncalled Leads",
        "emailType": "text"
      },
      "typeVersion": 2.1
    }
  ],
  "connections": {
    "On form submission": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Gmail",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gmail1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail1": {
      "main": [
        [
          {
            "node": "Gmail2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Google Sheets1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets1": {
      "main": [
        [
          {
            "node": "Filter1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Filter2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter1": {
      "main": [
        [
          {
            "node": "Google Sheets2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail4": {
      "main": [
        [
          {
            "node": "Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets2": {
      "main": [
        [
          {
            "node": "Filter2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter2": {
      "main": [
        [
          {
            "node": "Gmail4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}