{
  "nodes": [
    {
      "parameters": {
        "content": "# The allrounder assistant\n- for batch requests\n- eliminates copy-pasting",
        "height": 176,
        "width": 544,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        96,
        -48
      ],
      "typeVersion": 1,
      "id": "9154bdd2-d9a8-41e2-8f2e-185278444089",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=\"text\": \"# DATA EXTRACTION TASK\n\nYou are a precise data extraction specialist. Your task is to analyze the provided text and extract specific information into the exact JSON structure required.\n\n## SOURCE DATA:\n<source_text>\n{{JSON.stringify($json, null, 2)}}\n</source_text>\n\n## CRITICAL INSTRUCTIONS:\n1. **READ CAREFULLY**: Analyze the entire source text thoroughly before extracting any information\n2. **ACCURACY FIRST**: Extract information exactly as stated in the source - do not estimate, round, or modify values\n3. **REQUIRED FIELDS**: Fill ALL JSON fields - never leave empty strings or null values\n4. **DEFAULT VALUES**: Do not leave any of the JSON entries empty. use \"-\" or \"0\" or \"F\" instead.\n\n## EXPECTED OUTPUT FORMAT:\n- is given.\n\n## QUALITY CHECK:\n- Verify each extracted value against the source text\n- Ensure no information is fabricated or estimated\n- Double-check numerical values for accuracy\n- Confirm all fields are filled (no empty values)\n\nStart here.",
        "hasOutputParser": true,
        "batching": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.7,
      "position": [
        240,
        208
      ],
      "id": "876f8081-6936-43a1-b1a2-fa66938f8339",
      "name": "process row",
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "options": {
          "reset": false
        }
      },
      "id": "13fa4174-e093-4597-95ba-f5a917f31af9",
      "name": "Loop1",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -96,
        128
      ]
    },
    {
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"monthly_cost\": {\n      \"type\": \"integer\",\n      \"description\": \"Monthly cost in dollars (use base rate if range given)\"\n    },\n    \"facility_size\": {\n      \"type\": \"string\",\n      \"description\": \"Approximate size of facility\"\n    },\n    \"medical_services\": {\n      \"type\": \"boolean\",\n      \"description\": \"On-site nursing or medical care mentioned\"\n    },\n    \"specialized_dementia_care\": {\n      \"type\": \"boolean\",\n      \"description\": \"Dementia/Alzheimer's programs mentioned\"\n    },\n    \"staff_ratio_mentioned\": {\n      \"type\": \"boolean\",\n      \"description\": \"Staff-to-resident ratios mentioned\"\n    },\n    \"overall_suitability_score\": {\n      \"type\": \"integer\",\n      \"minimum\": 1,\n      \"maximum\": 10,\n      \"description\": \"Overall suitability score\"\n    },\n    \"red_flags\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"string\"\n      },\n      \"description\": \"Concerning elements\"\n    }\n  },\n  \"required\": [\"monthly_cost\", \"cost_range\", \"medical_services\", \"overall_suitability_score\"],\n  \n  \"enum_values\": {\n    \"availability_status\": [\"immediate\", \"within_month\", \"1_3_months\", \"waiting_list\", \"no_availability\"],\n    \"cost_range\": [\"under_3000\", \"3000_4000\", \"4000_5000\", \"5000_7000\", \"over_7000\"],\n    \"facility_size\": [\"small\", \"medium\", \"large\", \"very_large\"]\n  }\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        384,
        304
      ],
      "id": "0784ddfc-8640-45a4-957f-57e4636c04cc",
      "name": "SO1"
    },
    {
      "parameters": {
        "model": "openai/gpt-oss-120b",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGroq",
      "typeVersion": 1,
      "position": [
        304,
        304
      ],
      "id": "565f8d13-65e7-4fa1-99f6-82b6c05ba05c",
      "name": "LLM1",
      "credentials": {
        "groqApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -224,
        -64
      ],
      "id": "01ff10c0-b553-49aa-80d9-0a93bc3bc7c0",
      "name": "Trigger1"
    },
    {
      "parameters": {
        "content": "items looping",
        "height": 208,
        "width": 422,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        224,
        160
      ],
      "typeVersion": 1,
      "id": "0d7eb3ab-43c0-4db7-8b36-f09d2c27e121",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "8c9e5a3d-2f1b-4e6a-9c8d-7b5a4f3e2d1c",
              "leftValue": "={{ $json.Email_Response }}",
              "rightValue": 0,
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "11f702b2-2d18-4b35-824d-5a293399d0ee",
      "name": "format validation",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        64,
        208
      ]
    },
    {
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n      \"availability_status\": {\n          \"type\": \"string\",\n          \"description\": \"When they have openings available\"\n      },\n      \"cost_range\": {\n          \"type\": \"string\",\n          \"description\": \"Cost category for easy comparison\",\n          \"enum\": [\"under_3000\", \"3000_4000\", \"4000_5000\", \"5000_7000\", \"over_7000\"]\n      },\n      \"cognitive_stimulation_programs\": {\n          \"type\": \"string\",\n          \"description\": \"Mental stimulation activities or programs offered\"\n      },\n      \"facility_size\": {\n          \"type\": \"string\",\n          \"description\": \"Approximate size of facility\"\n      },\n      \"required\": [\"availability_status\", \"cost_range\", \"cognitive_stimulation_programs\"]\n  }\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        -112,
        672
      ],
      "id": "79ded492-16cc-43e2-b7c6-1006e58ae9c5",
      "name": "SO",
      "disabled": true
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/13_rsLrDZhf-I3LmjzyhV9nHDcXXzTReBYorf3czow1c/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Response_ID": "={{ $('format validation').item.json.Response_ID }}"
          },
          "matchingColumns": [
            "Response_ID"
          ],
          "schema": [
            {
              "id": "Response_ID",
              "displayName": "Response_ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Facility_Name",
              "displayName": "Facility_Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Date_Sent",
              "displayName": "Date_Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Date_Received",
              "displayName": "Date_Received",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Email_Response",
              "displayName": "Email_Response",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "availability_status",
              "displayName": "availability_status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "cost_range",
              "displayName": "cost_range",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "specialized_dementia_care",
              "displayName": "specialized_dementia_care",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "cognitive_stimulation_programs",
              "displayName": "cognitive_stimulation_programs",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "public_transport_connections",
              "displayName": "public_transport_connections",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "medical_services",
              "displayName": "medical_services",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "staff_ratio",
              "displayName": "staff_ratio",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true,
              "readOnly": true,
              "removed": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "id": "64dd108d-7143-4d7d-be74-911ef74b47c3",
      "name": "Write_Excel1",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        400,
        656
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "disabled": true
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "sheetName": {
          "__rl": true,
          "value": "",
          "mode": "list",
          "cachedResultName": "",
          "cachedResultUrl": ""
        }
      },
      "id": "f0b4aa4e-b4d8-47bb-88e8-e32466f23b8d",
      "name": "Read Excel1",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        16,
        656
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "disabled": true
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "186b90da-f161-4f4d-8d94-ac9502f6429b",
              "leftValue": "={{ $json.row_number }}",
              "rightValue": 2,
              "operator": {
                "type": "number",
                "operation": "gte"
              }
            },
            {
              "id": "c41503c0-a340-4617-a615-68b957975fa3",
              "leftValue": "={{ $json.row_number }}",
              "rightValue": 100,
              "operator": {
                "type": "number",
                "operation": "lt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        -256,
        128
      ],
      "id": "0240cb8f-4543-4a5c-987f-5be5aeb32e56",
      "name": "Select Range"
    },
    {
      "parameters": {
        "content": "### Only modify these objects\n",
        "height": 224,
        "width": 736,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -128,
        608
      ],
      "typeVersion": 1,
      "id": "0d665d62-cc61-46ea-9156-f25bfd84881b",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "186b90da-f161-4f4d-8d94-ac9502f6429b",
              "leftValue": "={{ $json.row_number }}",
              "rightValue": 11,
              "operator": {
                "type": "number",
                "operation": "gte"
              }
            },
            {
              "id": "c41503c0-a340-4617-a615-68b957975fa3",
              "leftValue": "={{ $json.row_number }}",
              "rightValue": 13,
              "operator": {
                "type": "number",
                "operation": "lt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        192,
        656
      ],
      "id": "6ea0359c-ecc7-4ed3-9363-1d4500268af9",
      "name": "Select Range1",
      "disabled": true
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "YOUR_BILLING_LEDGER_SHEET_ID",
          "mode": "list",
          "cachedResultName": "Billing_Ledger",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_BILLING_LEDGER_SHEET_ID/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "",
          "mode": "list",
          "cachedResultName": "",
          "cachedResultUrl": ""
        }
      },
      "id": "3dfcf2da-b9b8-47f0-b75e-879b66822ec4",
      "name": "Read Excel",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        -96,
        -64
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/13_rsLrDZhf-I3LmjzyhV9nHDcXXzTReBYorf3czow1c/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "cost_range": "={{ $json.output.cost_range }}",
            "specialized_dementia_care": "={{ $json.output.specialized_dementia_care }}",
            "public_transport_connections": "={{ $json.output.public_transport_connections }}",
            "medical_services": "={{ $json.output.medical_services }}",
            "staff_ratio": "={{ $json.output.staff_ratio }}",
            "Response_ID": "={{ $('format validation1').item.json.Response_ID }}"
          },
          "matchingColumns": [
            "Response_ID"
          ],
          "schema": [
            {
              "id": "Response_ID",
              "displayName": "Response_ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Facility_Name",
              "displayName": "Facility_Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Date_Sent",
              "displayName": "Date_Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Date_Received",
              "displayName": "Date_Received",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Email_Response",
              "displayName": "Email_Response",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "availability_status",
              "displayName": "availability_status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "cost_range",
              "displayName": "cost_range",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "specialized_dementia_care",
              "displayName": "specialized_dementia_care",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "cognitive_stimulation_programs",
              "displayName": "cognitive_stimulation_programs",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "public_transport_connections",
              "displayName": "public_transport_connections",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "medical_services",
              "displayName": "medical_services",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "staff_ratio",
              "displayName": "staff_ratio",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true,
              "readOnly": true,
              "removed": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "id": "a453044f-7d76-493a-a201-cff025fa0e32",
      "name": "Write_Excel",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        528,
        208
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "process row": {
      "main": [
        [
          {
            "node": "Write_Excel",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop1": {
      "main": [
        [],
        [
          {
            "node": "format validation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SO1": {
      "ai_outputParser": [
        [
          {
            "node": "process row",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "LLM1": {
      "ai_languageModel": [
        [
          {
            "node": "process row",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Trigger1": {
      "main": [
        [
          {
            "node": "Read Excel",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "format validation": {
      "main": [
        [
          {
            "node": "process row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Select Range": {
      "main": [
        [
          {
            "node": "Loop1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Excel": {
      "main": [
        [
          {
            "node": "Select Range",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write_Excel": {
      "main": [
        [
          {
            "node": "Loop1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}