{
  "id": "yq7ESvzVZpvNaaIX",
  "name": "Lead Qualification",
  "tags": [],
  "nodes": [
    {
      "id": "f00a75d2-e25e-4a7f-8bc8-a7503838b331",
      "name": "Trigger: Schedule Lead Check",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1824,
        224
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "seconds"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "afa65b2b-48ea-4d6c-bd3f-65874286f1e2",
      "name": "Fetch FB Leads",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1568,
        224
      ],
      "parameters": {
        "url": "https://graph.facebook.com/v22.0/2056495664847309/leads?access_token=YOUR_TOKEN_HERE",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "f692d267-0065-4e89-8541-b836b4c33432",
      "name": "Extract Lead Info",
      "type": "n8n-nodes-base.set",
      "position": [
        -1392,
        224
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "25677c13-de86-48f8-872e-ec1ba36d3a3a",
              "name": "Name",
              "type": "string",
              "value": "={{ $json.data[0].field_data[0].values[0] }}"
            },
            {
              "id": "851a9164-36c6-4b94-858b-9e705e3edf2c",
              "name": "Phone Number",
              "type": "string",
              "value": "={{ $json.data[0].field_data[1].values[0] }}"
            },
            {
              "id": "92693a83-02c1-4cb9-9fac-e39eb27086f0",
              "name": "Email",
              "type": "string",
              "value": "={{ $json.data[0].field_data[2].values[0] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "da6bfd7e-8901-4bae-8f4c-b012c4ab1f45",
      "name": "Send WhatsApp Confirmation",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -112,
        96
      ],
      "parameters": {
        "url": "https://api.twilio.com/2010-04-01/Accounts/YOUR_TWILIO_ACCOUNT_SID/Messages.json",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "From",
              "value": "whatsapp:+1234567890"
            },
            {
              "name": "=To",
              "value": "=whatsapp:{{ $('Edit Fields2').item.json['Phone Number'] }}"
            },
            {
              "name": "Body",
              "value": "=Hi {{ $('Edit Fields2').item.json.Name }}, confirm yes or no"
            }
          ]
        },
        "genericAuthType": "httpBasicAuth"
      },
      "credentials": {
        "httpBasicAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "1ea859f3-d8c5-4ea2-a517-d45b8ee4bbcf",
      "name": "Receive WhatsApp Response",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1840,
        864
      ],
      "parameters": {
        "path": "custrep",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2
    },
    {
      "id": "8282e0e2-5209-46a7-b5af-41efb24fee8d",
      "name": "Classify Response (AI)",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1584,
        864
      ],
      "parameters": {
        "text": "=Role: WhatsApp Response Classifier  \nInstructions:\n1. Analyze the user's message strictly and classify into ONE of these categories:\n   - `confirmed` - If agreeing (e.g., \"Yes\", \"I\u2019m interested\", \"Sure\")\n   - `declined` - If refusing (e.g., \"No\", \"Not now\", \"Cancel\")\n   - `human_requested` - If asking for human help (e.g., \"Talk to agent\", \"Human please\")\n   - `invalid_response` - If message is unclear/nonsense (e.g., \"asdf\", \"Maybe tomorrow\")\n\n2. Generate an appropriate JSON response:\n```json\n{\n  \"status\": \"confirmed|declined|human_requested|invalid_response\",\n  \"reply\": \"Your tailored response here\",\n  \"suggestion\": \"Optional internal note for workflow\"\n   \n}\n**User Message to Classify**:\n {{ $json.body.Body }}\"",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "7f06495d-6e3c-406b-b55c-a928d4641e9d",
      "name": "Gemini LLM",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "notes": "Google Gemini model used to interpret WhatsApp replies.",
      "position": [
        -1632,
        1088
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash-lite-001"
      },
      "typeVersion": 1
    },
    {
      "id": "d3e3f1fb-8474-412e-b8ba-f80afc614958",
      "name": "Parse AI JSON Output",
      "type": "n8n-nodes-base.code",
      "position": [
        -1104,
        864
      ],
      "parameters": {
        "jsCode": "// Extract the JSON from the AI Agent's response\nconst aiResponse = $input.first().json.output;\n\ntry {\n    // Find and parse the JSON part\n    const jsonStart = aiResponse.indexOf('{');\n    const jsonEnd = aiResponse.lastIndexOf('}');\n    const jsonString = aiResponse.slice(jsonStart, jsonEnd + 1);\n    const parsedResponse = JSON.parse(jsonString);\n\n    // Return status for Switch node + original reply for later use\n    return {\n        status: parsedResponse.status,  // For Switch routing\n        reply: parsedResponse.reply,     // Original AI-generated reply\n        suggestion: parsedResponse.suggestion  // Optional (if needed)\n    };\n} catch (error) {\n    console.error(\"Failed to parse AI response:\", error);\n    return {\n        status: \"invalid_response\",\n        reply: \"Error: Could not process your request.\",  // Fallback reply\n        suggestion: \"Check AI Agent output formatting\"\n    };\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "70ced2b8-b2eb-4bba-9390-299ca1302336",
      "name": "Route by Classification",
      "type": "n8n-nodes-base.switch",
      "position": [
        -816,
        848
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "068cbb41-642f-48b1-960b-72c9d5538f3b",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "confirmed"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "758901e4-6160-4e80-83de-80cee676d0e8",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "declined"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "08262a2c-a679-4439-90b9-6051ee185e7c",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "human_requested"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "cee95e32-30a9-4b59-9a7f-51d03c41e794",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "=invalid_response"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "5cebcd48-ee20-4967-81f7-1bd1b3054f86",
      "name": "Reply: Confirmed",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -544,
        576
      ],
      "parameters": {
        "url": "https://api.twilio.com/2010-04-01/Accounts/ACYOUR_TWILIO_ACCOUNT_SID/Messages.json",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "From",
              "value": "={{ $('WHTSP-Webhook').item.json.body.To }}"
            },
            {
              "name": "To",
              "value": "={{ $('WHTSP-Webhook').item.json.body.From }}"
            },
            {
              "name": "Body",
              "value": "={{ $json.reply }}"
            }
          ]
        },
        "nodeCredentialType": "twilioApi"
      },
      "typeVersion": 4.2
    },
    {
      "id": "a8a9177c-58c6-44e5-bcba-f4cda4496bd1",
      "name": "Reply: Declined",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -528,
        864
      ],
      "parameters": {
        "url": "https://api.twilio.com/2010-04-01/Accounts/YOUR_TWILIO_ACCOUNT_SID/Messages.json",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "From",
              "value": "={{ $('WHTSP-Webhook').item.json.body.To }}"
            },
            {
              "name": "To",
              "value": "={{ $('WHTSP-Webhook').item.json.body.From }}"
            },
            {
              "name": "Body",
              "value": "={{ $json.reply }}"
            }
          ]
        },
        "nodeCredentialType": "twilioApi"
      },
      "typeVersion": 4.2
    },
    {
      "id": "4abca0e6-fbab-4b8a-9733-b8ab3ef417d9",
      "name": "Reply: Request Human",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -848,
        1232
      ],
      "parameters": {
        "url": "https://api.twilio.com/2010-04-01/Accounts/YOUR_TWILIO_ACCOUNT_SID/Messages.json",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "From",
              "value": "={{ $('WHTSP-Webhook').item.json.body.To }}"
            },
            {
              "name": "To",
              "value": "={{ $('WHTSP-Webhook').item.json.body.From }}"
            },
            {
              "name": "Body",
              "value": "={{ $json.reply }}"
            }
          ]
        },
        "nodeCredentialType": "twilioApi"
      },
      "typeVersion": 4.2
    },
    {
      "id": "8a1d25f0-327c-4f9d-9b9d-6bd24634775a",
      "name": "Reply: Invalid",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -928,
        1472
      ],
      "parameters": {
        "url": "https://api.twilio.com/2010-04-01/Accounts/YOUR_TWILIO_ACCOUNT_SID/Messages.json",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "From",
              "value": "={{ $('WHTSP-Webhook').item.json.body.To }}"
            },
            {
              "name": "To",
              "value": "={{ $('WHTSP-Webhook').item.json.body.From }}"
            },
            {
              "name": "Body",
              "value": "={{ $json.reply }}"
            }
          ]
        },
        "nodeCredentialType": "twilioApi"
      },
      "typeVersion": 4.2
    },
    {
      "id": "86af500c-fe09-4b48-8d62-07acebee1a34",
      "name": "Update CRM: Confirmed",
      "type": "n8n-nodes-base.zohoCrm",
      "position": [
        368,
        464
      ],
      "parameters": {
        "resource": "contact",
        "contactId": "={{ $json.data[0].details.id }}",
        "operation": "update",
        "updateFields": {
          "customFields": {
            "customFields": [
              {
                "value": "=Confirmed",
                "fieldId": "Status"
              }
            ]
          }
        }
      },
      "typeVersion": 1
    },
    {
      "id": "76c58115-86ab-4225-bfea-cec0f8073563",
      "name": "Create Zoho Contact",
      "type": "n8n-nodes-base.zohoCrm",
      "position": [
        -528,
        240
      ],
      "parameters": {
        "lastName": "={{ $('Edit Fields2').item.json.Name }}",
        "resource": "contact",
        "additionalFields": {
          "Email": "={{ $('Edit Fields2').item.json.Email }}",
          "Phone": "={{ $('Edit Fields2').item.json['Phone Number'] }}",
          "Full_Name": "={{ $('Edit Fields2').item.json.Name }}",
          "customFields": {
            "customFields": [
              {
                "value": "Pending",
                "fieldId": "Status"
              }
            ]
          }
        }
      },
      "typeVersion": 1
    },
    {
      "id": "087e62dd-aa83-4836-afb1-58286d2f9ea8",
      "name": "Find Confirmed Contact in Zoho",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -320,
        576
      ],
      "parameters": {
        "url": "=https://www.zohoapis.eu/crm/v2/Contacts/search",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "oAuth2Api",
        "queryParameters": {
          "parameters": [
            {
              "name": "phone",
              "value": "={{ $('WHTSP-Webhook').item.json.body.WaId }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "2f9252ca-387d-4310-a6dd-385ba3d59090",
      "name": "Find Declined Contact in Zoho",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -304,
        864
      ],
      "parameters": {
        "url": "=https://www.zohoapis.eu/crm/v2/Contacts/search",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "oAuth2Api",
        "queryParameters": {
          "parameters": [
            {
              "name": "phone",
              "value": "={{ $('WHTSP-Webhook').item.json.body.WaId }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "527913c8-f88d-47fd-88b5-0969f10a049e",
      "name": "Check Zoho Contact Exists",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        -1200,
        224
      ],
      "parameters": {
        "url": "=https://www.zohoapis.eu/crm/v2/Contacts/search",
        "options": {
          "response": {
            "response": {
              "responseFormat": "text"
            }
          }
        },
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "oAuth2Api",
        "queryParameters": {
          "parameters": [
            {
              "name": "phone",
              "value": "={{ $json['Phone Number'] }}"
            }
          ]
        }
      },
      "typeVersion": 4.2,
      "alwaysOutputData": false
    },
    {
      "id": "879dbf5f-340e-4f38-b5fd-68e872ef8d6a",
      "name": "If New Lead",
      "type": "n8n-nodes-base.if",
      "position": [
        -1008,
        224
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "521b81b8-7827-479f-8762-0859a066268f",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.data }}",
              "rightValue": "0"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "8aede2a1-8339-4e4d-b788-de7261910e18",
      "name": "Update CRM: Declined",
      "type": "n8n-nodes-base.zohoCrm",
      "position": [
        -32,
        864
      ],
      "parameters": {
        "resource": "contact",
        "contactId": "={{ $json.data[0].id }}",
        "operation": "update",
        "updateFields": {
          "customFields": {
            "customFields": [
              {
                "value": "Declined",
                "fieldId": "Status"
              }
            ]
          }
        }
      },
      "typeVersion": 1
    },
    {
      "id": "01c55418-28af-4634-bc8f-104506d98577",
      "name": "Assign CRM Owner",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        128,
        464
      ],
      "parameters": {
        "url": "=https://www.zohoapis.eu/crm/v2/Contacts/{{ $('HTTP Request3').item.json.data[0].id }}",
        "method": "PUT",
        "options": {},
        "jsonBody": "={\n  \"data\": [\n    {\n      \"Owner\": {\n        \"id\": \"{{ $json.Owner.id }}\"\n      }\n    }\n  ]\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "oAuth2Api"
      },
      "typeVersion": 4.2
    },
    {
      "id": "6ede6682-14a7-42b4-8337-f047c991ef86",
      "name": "Prepare Owner ID",
      "type": "n8n-nodes-base.set",
      "position": [
        -64,
        464
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "{\n  \"Owner\": {\n    \"id\": \"84561+1234567890\"\n  }\n}\n    \n"
      },
      "typeVersion": 3.4
    },
    {
      "id": "87158089-7c1e-4425-8d3e-2de044d3b63d",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1872,
        64
      ],
      "parameters": {
        "color": 3,
        "height": 304,
        "content": "Fires periodically to check Facebook Lead Ads for new leads."
      },
      "typeVersion": 1
    },
    {
      "id": "62967581-6cb2-4a24-85a0-5c3822d78c04",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1616,
        64
      ],
      "parameters": {
        "color": 4,
        "width": 160,
        "height": 304,
        "content": "Makes a request to Facebook Graph API to fetch new lead data."
      },
      "typeVersion": 1
    },
    {
      "id": "72d0be48-ee0b-41dd-96ce-e35356eb866d",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1440,
        64
      ],
      "parameters": {
        "color": 5,
        "width": 192,
        "height": 304,
        "content": "Extracts Name, Phone, and Email fields from Facebook lead data."
      },
      "typeVersion": 1
    },
    {
      "id": "9205d486-040d-4705-a611-5e33efe5db53",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1232,
        64
      ],
      "parameters": {
        "color": 4,
        "width": 176,
        "height": 304,
        "content": "Checks Zoho CRM if the contact already exists using phone number."
      },
      "typeVersion": 1
    },
    {
      "id": "14b5b815-da01-4dca-b499-1a3a934ad51e",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1040,
        64
      ],
      "parameters": {
        "color": 5,
        "width": 192,
        "height": 304,
        "content": "Routes based on whether the contact already exists in Zoho."
      },
      "typeVersion": 1
    },
    {
      "id": "41162fc3-11ea-41b3-9ef7-27bb1b3fe6b0",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -592,
        144
      ],
      "parameters": {
        "color": 4,
        "height": 240,
        "content": "Creates a new contact in Zoho CRM with lead info and 'Pending' status."
      },
      "typeVersion": 1
    },
    {
      "id": "4fb77b81-995e-4d23-84b8-90447b15681e",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        -32
      ],
      "parameters": {
        "color": 5,
        "height": 304,
        "content": "Sends WhatsApp message asking the lead to confirm interest."
      },
      "typeVersion": 1
    },
    {
      "id": "cdac857e-9c97-4e0f-a7a5-9fa35511c6ba",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1920,
        736
      ],
      "parameters": {
        "color": 3,
        "height": 288,
        "content": "Webhook to receive reply messages from Twilio/WhatsApp."
      },
      "typeVersion": 1
    },
    {
      "id": "402abe15-81a5-46ec-bfea-d73fbd3ce6fa",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1568,
        752
      ],
      "parameters": {
        "color": 6,
        "content": "Uses AI to classify user response into confirmed, declined, etc."
      },
      "typeVersion": 1
    },
    {
      "id": "e36e62c5-ec9f-4524-9f44-9de3d3488c19",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1184,
        720
      ],
      "parameters": {
        "color": 4,
        "height": 288,
        "content": "Parses the JSON output from AI Agent to extract status and reply."
      },
      "typeVersion": 1
    },
    {
      "id": "75d97c66-3e8d-472e-b1ac-0fc24edfea96",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        768
      ],
      "parameters": {
        "content": "Routes based on classification: confirmed, declined, human, or invalid."
      },
      "typeVersion": 1
    },
    {
      "id": "36300dd6-b9f5-413d-b534-032f7b9e3b26",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        1184
      ],
      "parameters": {
        "color": 5,
        "content": "Sends response when lead requests human interaction."
      },
      "typeVersion": 1
    },
    {
      "id": "d25aabf0-4ac5-4f72-8e93-28a3e136f852",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        1424
      ],
      "parameters": {
        "color": 4,
        "content": "Sends fallback response for unclear or invalid replies."
      },
      "typeVersion": 1
    },
    {
      "id": "3a6c0425-a1b0-46f3-985e-1791a93473ed",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -624,
        816
      ],
      "parameters": {
        "color": 4,
        "content": "Sends follow-up message for declined responses."
      },
      "typeVersion": 1
    },
    {
      "id": "dac4159b-598f-41cf-8ead-118a7691a46f",
      "name": "Sticky Note14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -368,
        816
      ],
      "parameters": {
        "color": 5,
        "content": "Search Zoho CRM for declined lead by phone."
      },
      "typeVersion": 1
    },
    {
      "id": "90702fe4-ce51-4c56-88f2-a98828d5a56b",
      "name": "Sticky Note15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        816
      ],
      "parameters": {
        "color": 4,
        "content": "Marks lead in Zoho CRM as 'Declined'."
      },
      "typeVersion": 1
    },
    {
      "id": "22442a01-2b9e-4e18-ab6b-fe4bcb4b3439",
      "name": "Sticky Note16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -640,
        512
      ],
      "parameters": {
        "color": 5,
        "content": "Sends follow-up message for confirmed leads."
      },
      "typeVersion": 1
    },
    {
      "id": "9b25ff71-2576-469d-babe-c321f6f693b0",
      "name": "Sticky Note17",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -384,
        512
      ],
      "parameters": {
        "color": 4,
        "width": 208,
        "content": "Search Zoho CRM for contact with confirmed phone number."
      },
      "typeVersion": 1
    },
    {
      "id": "cda55455-4bfb-402e-b502-fbef164333ff",
      "name": "Sticky Note18",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -128,
        400
      ],
      "parameters": {
        "color": 5,
        "width": 208,
        "content": "Sets the CRM owner ID before updating the record."
      },
      "typeVersion": 1
    },
    {
      "id": "494be752-b201-4db6-857d-904848876fdc",
      "name": "Sticky Note19",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        96,
        400
      ],
      "parameters": {
        "color": 4,
        "width": 176,
        "content": "Updates the contact's owner field in Zoho CRM."
      },
      "typeVersion": 1
    },
    {
      "id": "9d58a830-8419-4373-a06e-8597925ce9e4",
      "name": "Sticky Note20",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        288,
        400
      ],
      "parameters": {
        "color": 5,
        "width": 224,
        "content": "Updates Zoho CRM contact to mark as 'Confirmed'."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "a79818a9-3ddf-4a12-9eb9-5775d50e0665",
  "connections": {
    "Gemini LLM": {
      "ai_languageModel": [
        [
          {
            "node": "Classify Response (AI)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "If New Lead": {
      "main": [
        [],
        [
          {
            "node": "Create Zoho Contact",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send WhatsApp Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch FB Leads": {
      "main": [
        [
          {
            "node": "Extract Lead Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reply: Declined": {
      "main": [
        [
          {
            "node": "Find Declined Contact in Zoho",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Assign CRM Owner": {
      "main": [
        [
          {
            "node": "Update CRM: Confirmed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Owner ID": {
      "main": [
        [
          {
            "node": "Assign CRM Owner",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reply: Confirmed": {
      "main": [
        [
          {
            "node": "Find Confirmed Contact in Zoho",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Lead Info": {
      "main": [
        [
          {
            "node": "Check Zoho Contact Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse AI JSON Output": {
      "main": [
        [
          {
            "node": "Route by Classification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Classify Response (AI)": {
      "main": [
        [
          {
            "node": "Parse AI JSON Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Classification": {
      "main": [
        [
          {
            "node": "Reply: Confirmed",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Reply: Declined",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Reply: Request Human",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Reply: Invalid",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Zoho Contact Exists": {
      "main": [
        [
          {
            "node": "If New Lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receive WhatsApp Response": {
      "main": [
        [
          {
            "node": "Classify Response (AI)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger: Schedule Lead Check": {
      "main": [
        [
          {
            "node": "Fetch FB Leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find Declined Contact in Zoho": {
      "main": [
        [
          {
            "node": "Update CRM: Declined",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find Confirmed Contact in Zoho": {
      "main": [
        [
          {
            "node": "Prepare Owner ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}