{
  "name": "ParquetReader",
  "nodes": [
    {
      "parameters": {
        "options": {
          "systemMessage": "Use this tool to search, inspect, and query the preconfigured ParquetReader file.\n\nThe file is already fixed in the tool configuration. Do not ask the user for `file_id`, do not generate a `file_id`, and do not try to search another file with this tool.\n\nAuthentication is already configured in the tool using the `X-API-Key` header. Do not ask the user for an API key and never include API keys in messages, query parameters, or request bodies.\n\nUse this tool when:\n- The user asks about contents of the configured file.\n- You need to find rows containing a value, keyword, ID, name, date, category, or other content.\n- You need to verify file contents before answering.\n- You need to inspect the schema before writing SQL.\n- You need to run a safe SQL `SELECT` query against the configured file.\n\nDo not use this tool when:\n- The user asks about a different file.\n- The user asks to upload, persist, delete, export, or download a file.\n- You would need to modify data.\n- You are tempted to answer from assumptions without searching.\n- You need to claim the whole file was analyzed but only paginated or preview results were returned.\n\nAvailable inputs:\n- `q`: case-insensitive full-text substring search across scalar columns.\n- `sql`: safe custom SQL query. Use `dataset` as the table name.\n- `sort`: sort expression like `column_name ASC` or `column_name DESC`.\n- `limit`: result limit, default `50`, min `1`, max `1000`.\n- `offset`: pagination offset, default `0`.\n- `dialect`: SQL dialect for `sql`. Use `duckdb` for SQL you generate unless another dialect is explicitly required.\n- `meta`: keep `true` when schema, counts, or access metadata are useful.\n\nSearch guidance:\n- Use `q` for broad keyword/value searches.\n- Use `sql` for column-specific filters, counts, grouping, aggregation, sorting, or comparisons.\n- If the user asks an analytical question, prefer SQL.\n- If you do not know the schema yet, first call this tool with `limit=1`, `offset=0`, `meta=true`, and no `q` or `sql` to inspect available columns and types.\n- Only use columns that exist in the returned `schema`.\n- Use the exact column names and casing from `schema.column_name`.\n\nSQL rules:\n- Only use safe `SELECT` or CTE SQL.\n- Query from `dataset`.\n- Do not use `INSERT`, `UPDATE`, `DELETE`, `CREATE`, `DROP`, `ALTER`, `COPY`, `INSTALL`, external reads, or system tables.\n- Use double quotes for column identifiers, for example `\"Pclass\"`, `\"Survived\"`, `\"PassengerId\"`.\n- Never use single quotes for column names. Single quotes are only for string values.\n- Correct: `GROUP BY \"Pclass\" ORDER BY \"Pclass\"`.\n- Incorrect: `GROUP BY 'Pclass' ORDER BY 'Pclass'`.\n- Numeric columns such as `BIGINT` or `DOUBLE` should be compared to numeric values without quotes, for example `\"Pclass\" = 1`.\n- Text columns such as `VARCHAR` should be compared to string values in single quotes, for example `\"Sex\" = 'female'`.\n- For case-insensitive text matching, use `ILIKE`, for example `\"Name\" ILIKE '%smith%'`.\n- When using SQL generated by the agent, set `dialect` to `duckdb`.\n\nGood SQL examples:\n- `SELECT * FROM dataset WHERE \"Sex\" = 'female' LIMIT 20`\n- `SELECT \"Pclass\", COUNT(*) AS total FROM dataset GROUP BY \"Pclass\" ORDER BY \"Pclass\"`\n- `SELECT COUNT(*) AS total, SUM(\"Survived\") AS survived, ROUND(100.0 * SUM(\"Survived\") / COUNT(*), 2) AS survival_rate_pct FROM dataset`\n\nResponse handling:\n- Use only `data` as returned row evidence.\n- Use `schema` to understand column names and column types.\n- Use `meta_data.rows_filtered` as the matching row count when present.\n- If `data` is empty or `meta_data.rows_filtered` is `0`, say no matching rows were found.\n- If `purchase_required=true`, explain that results may be limited to the accessible preview/sample.\n- Never invent rows, columns, totals, or conclusions not present in the response.\n- Do not claim the entire file was analyzed unless the response and access level support that claim.\n- If a SQL query fails because of a column name, type, binder, grouping, or ordering error, inspect the schema and retry with corrected identifiers and types.",
          "maxIterations": 10,
          "enableStreaming": true
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        208,
        0
      ],
      "id": "ffc35e30-b2f6-4613-bc7d-68114cb31b9a",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5-mini"
        },
        "builtInTools": {},
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        96,
        208
      ],
      "id": "f81b2a46-75c6-4214-864c-5c20093545b5",
      "name": "OpenAI Chat Model",
      "notesInFlow": true,
      "credentials": {
        "openAiApi": {
          "id": "nl9LPhFLI30o0gnt",
          "name": "OpenAI account"
        }
      },
      "notes": "Add your own API key to the Chat Model node before running this workflow, so it can use your own AI provider connection."
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.4,
      "position": [
        -256,
        0
      ],
      "id": "b68a124c-b61b-468c-812f-dab017738a4c",
      "name": "When chat message received",
      "webhookId": "b7979fd9-c1d1-4890-9e83-c439531de55b"
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.4,
      "position": [
        288,
        240
      ],
      "id": "3cf37cc0-360e-4a91-b66f-2f1ace1e9291",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "url": "=https://api.parquetreader.com/parquet/search/{{ $json.FILE_ID }}",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "q",
              "value": "={{$fromAI(\"q\")}}"
            },
            {
              "name": "sort",
              "value": "={{$fromAI(\"sort\")}}"
            },
            {
              "name": "limit",
              "value": "={{$fromAI(\"limit\")}}"
            },
            {
              "name": "offset",
              "value": "={{$fromAI(\"offset\")}}"
            },
            {
              "name": "sql",
              "value": "={{$fromAI(\"sql\")}}"
            },
            {
              "name": "dialect",
              "value": "={{$fromAI(\"dialect\")}}"
            },
            {
              "name": "meta",
              "value": "={{$fromAI(\"meta\")}}"
            }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-API-Key",
              "value": "={{ $json.API_KEY }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequestTool",
      "typeVersion": 4.4,
      "position": [
        448,
        224
      ],
      "id": "7d1c0980-474d-47ee-bfd6-740faa66c175",
      "name": "ParquetReader Search"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "9a48d539-04d1-4499-8c88-296bb3989ff1",
              "name": "API_KEY",
              "value": "sk_...",
              "type": "string"
            },
            {
              "id": "0980ee6b-1a49-4f29-9a98-4743339163aa",
              "name": "FILE_ID",
              "value": "1234..",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -32,
        0
      ],
      "id": "4e12f89f-bd3c-446f-a712-88cb9ef80ffa",
      "name": "Mandatory Fields",
      "notesInFlow": true,
      "notes": "You need to replace `file_id` and `api_key` with your own values before this node can access your data."
    },
    {
      "parameters": {
        "content": "## Setup Required\n\nBefore running this workflow, update the required fields:\n\n1. **Mandatory Fields node**\n   Add your own ParquetReader `file_id` and `api_key`.\n\n2. **Chat Model node**\n   Add your own AI provider API key, such as OpenAI, Anthropic, or another supported provider.\n\nOnce configured, the AI Agent can search your ParquetReader file and answer questions about your data.\n\n> Never share or publish workflows with real API keys included.\n",
        "height": 256,
        "width": 688
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -272,
        -320
      ],
      "id": "e44375b7-7da9-430a-ac3a-a9c0af45f395",
      "name": "Sticky Note"
    }
  ],
  "pinData": {},
  "connections": {
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Mandatory Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "ParquetReader Search": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Mandatory Fields": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate"
  },
  "versionId": "4ed822bc-a79c-4c92-b09c-4625d9951359",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "bd16b0bbd93a857f377ec09360f3f48c4235b75fc4f562fe80f5288dbb009b7d"
  },
  "nodeGroups": [],
  "id": "bZMBHzbcruV4Q6Dc",
  "tags": []
}