{
  "name": "Sanitize Google Drive markdown text with a local Ollama model",
  "nodes": [
    {
      "id": "dbf53eba-3804-4593-9600-48ef5f817e60",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -288,
        -176
      ],
      "parameters": {
        "width": 464,
        "height": 864,
        "content": "## Sanitize text with a local Ollama model\n\nThis n8n workflow sanitizes text from markdown documents stored in a google drive folder. It uses a local Ollama model to identify and remove Personally Ide"
      }
    },
    {
      "id": "e6a18b46-5902-4887-910e-8b2e17b47804",
      "name": "return_files_in_folder",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        512,
        -16
      ]
    },
    {
      "id": "14e8fdc1-80f0-4e08-be95-b8122406202d",
      "name": "split_files_item",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        720,
        -16
      ]
    },
    {
      "id": "5b62fd9e-0a0f-4b02-a50b-4987a5204ac8",
      "name": "select_markdown_files",
      "type": "n8n-nodes-base.filter",
      "position": [
        912,
        -16
      ]
    },
    {
      "id": "91290eff-9838-48d2-9ff6-d3d831efd827",
      "name": "download_drive_files",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        464,
        320
      ]
    },
    {
      "id": "f8721b54-3fce-49d1-906c-8f5d66f523dd",
      "name": "text_from_markdown",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        640,
        320
      ]
    },
    {
      "id": "1661df62-85f1-4401-bd93-2c2e73360631",
      "name": "combine_all_text",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        832,
        320
      ]
    },
    {
      "id": "a27810ee-39be-4e77-b85e-5a884406de3b",
      "name": "chunk_text_for_local_llm",
      "type": "n8n-nodes-base.code",
      "position": [
        480,
        608
      ]
    },
    {
      "id": "348cc5c3-6783-44ac-b7d9-96867f72ec10",
      "name": "Basic LLM Chain",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        672,
        608
      ]
    },
    {
      "id": "b53b7ecf-ece9-42bf-8364-8b9e35559d7f",
      "name": "Ollama Model",
      "type": "@n8n/n8n-nodes-langchain.lmOllama",
      "position": [
        768,
        768
      ]
    },
    {
      "id": "a60822c2-6826-4e5e-a114-99f1fb315063",
      "name": "parse_json_text_with_flag",
      "type": "n8n-nodes-base.set",
      "position": [
        1024,
        608
      ]
    },
    {
      "id": "b6e6bac8-9f88-4eaf-bb95-2896a760a064",
      "name": "join_text_chunks",
      "type": "n8n-nodes-base.set",
      "position": [
        1664,
        608
      ]
    },
    {
      "id": "e8390461-09ef-4f88-be0a-c0ed4f9923b1",
      "name": "create_cleaned_text_file",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1856,
        608
      ]
    },
    {
      "id": "dc8e675a-6240-4fdb-89b9-26b973dd465d",
      "name": "on_subfolder_created",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        256,
        -16
      ]
    },
    {
      "id": "8c1f00ca-f188-4536-8542-d4d8d5736aba",
      "name": "log_text_with_pii_flag (optional)",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1552,
        272
      ]
    },
    {
      "id": "83e25cee-b0ab-4454-9fb9-bc570a1ab6fc",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        -96
      ],
      "parameters": {
        "width": 672,
        "height": 272,
        "content": "### 1. Retrieves filenames from the google drive folder and filters for markdown (.md) files."
      }
    },
    {
      "id": "d5f6145a-ea46-4ecd-871c-dd865bea2e1f",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        544
      ],
      "parameters": {
        "width": 688,
        "height": 352,
        "content": "### 3. Chunks the text, sends it to the Ollama model, and parses the JSON response."
      }
    },
    {
      "id": "2fc8a3a2-2f8f-4f42-a217-bba89c2010cd",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        240
      ],
      "parameters": {
        "width": 688,
        "height": 240,
        "content": "### 2. Downloads the markdown files and combines the extracted text."
      }
    },
    {
      "id": "0fb33e0d-6378-4005-a959-8418b6a79900",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1424,
        160
      ],
      "parameters": {
        "width": 384,
        "height": 288,
        "content": "### 4b. Logs the model responses, including the flag indicating whether PII information was found. (optional)."
      }
    },
    {
      "id": "dbee8ecd-a8c4-4fca-9490-ba77b3fde993",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1440,
        528
      ],
      "parameters": {
        "width": 576,
        "height": 288,
        "content": "### 4a. Combines the model responses and creates a new markdown file in the google drive folder."
      }
    },
    {
      "id": "19daaf82-f162-4c9d-823b-eee7f1d10500",
      "name": "combine_chunk_text",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1472,
        608
      ]
    }
  ],
  "connections": {
    "Ollama Model": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain": {
      "main": [
        [
          {
            "node": "parse_json_text_with_flag",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "combine_all_text": {
      "main": [
        [
          {
            "node": "chunk_text_for_local_llm",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "join_text_chunks": {
      "main": [
        [
          {
            "node": "create_cleaned_text_file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "split_files_item": {
      "main": [
        [
          {
            "node": "select_markdown_files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "combine_chunk_text": {
      "main": [
        [
          {
            "node": "join_text_chunks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "text_from_markdown": {
      "main": [
        [
          {
            "node": "combine_all_text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "download_drive_files": {
      "main": [
        [
          {
            "node": "text_from_markdown",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "on_subfolder_created": {
      "main": [
        [
          {
            "node": "return_files_in_folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "select_markdown_files": {
      "main": [
        [
          {
            "node": "download_drive_files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "return_files_in_folder": {
      "main": [
        [
          {
            "node": "split_files_item",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "chunk_text_for_local_llm": {
      "main": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "create_cleaned_text_file": {
      "main": [
        []
      ]
    },
    "parse_json_text_with_flag": {
      "main": [
        [
          {
            "node": "log_text_with_pii_flag (optional)",
            "type": "main",
            "index": 0
          },
          {
            "node": "combine_chunk_text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "log_text_with_pii_flag (optional)": {
      "main": [
        []
      ]
    }
  }
}