{
  "name": "Praxica Zoho + Vapi Database Reactivation",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 10 * * 2"
            }
          ]
        }
      },
      "id": "1",
      "name": "Every Tuesday at 10AM",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.1,
      "position": [400, 400]
    },
    {
      "parameters": {
        "operation": "search",
        "module": "Leads",
        "criteria": "(Last_Activity_Time:less_than:{{ $now.minus({ days: 90 }).toISO() }})",
        "options": {}
      },
      "id": "2",
      "name": "Find Stale Leads",
      "type": "n8n-nodes-base.zohoCrm",
      "typeVersion": 1,
      "position": [600, 400]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.vapi.ai/call",
        "authentication": "headerAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{\n  \"phoneNumberId\": \"your_vapi_phone_number_id\",\n  \"assistantId\": \"your_vapi_assistant_id\",\n  \"customer\": {\n    \"number\": \"{{ $json[\"Phone\"] }}\",\n    \"name\": \"{{ $json[\"First_Name\"] }}\"\n  },\n  \"assistantOverrides\": {\n    \"variableValues\": {\n      \"company\": \"Sharplight\"\n    }\n  }\n}",
        "options": {}
      },
      "id": "3",
      "name": "Trigger Vapi Call",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [850, 400]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "vapi-callback",
        "options": {}
      },
      "id": "4",
      "name": "Vapi Outcome Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [400, 650]
    },
    {
      "parameters": {
        "operation": "update",
        "module": "Leads",
        "id": "={{ $json[\"body\"][\"customer\"][\"number\"] }}",
        "fieldsToUpdate": {
          "Lead_Status": "={{ $json[\"body\"][\"analysis\"][\"success\"] ? 'Interested' : 'Not Interested' }}"
        }
      },
      "id": "5",
      "name": "Update Zoho Status",
      "type": "n8n-nodes-base.zohoCrm",
      "typeVersion": 1,
      "position": [650, 650]
    },
    {
      "parameters": {
        "operation": "create",
        "module": "Notes",
        "fields": {
          "Note_Content": "={{ $json[\"body\"][\"transcript\"] }}",
          "Parent_Id": "={{ $node[\"Update Zoho Status\"].json[\"id\"] }}",
          "Note_Title": "Vapi AI Call Transcript"
        }
      },
      "id": "6",
      "name": "Add Call Transcript",
      "type": "n8n-nodes-base.zohoCrm",
      "typeVersion": 1,
      "position": [900, 650]
    }
  ],
  "connections": {
    "Every Tuesday at 10AM": {
      "main": [
        [
          {
            "node": "Find Stale Leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find Stale Leads": {
      "main": [
        [
          {
            "node": "Trigger Vapi Call",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Vapi Outcome Webhook": {
      "main": [
        [
          {
            "node": "Update Zoho Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Zoho Status": {
      "main": [
        [
          {
            "node": "Add Call Transcript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
