{
  "name": "n8n workflow",
  "nodes": [
    {
      "id": "5a4c2536-9070-40b4-9db1-24e3b6f440fa",
      "name": "AI Agent3",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        224,
        1872
      ],
      "parameters": {
        "options": {
          "systemMessage": "__UKH_SECRET_0__"
        },
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "766b4958-6e0b-4d99-99ce-8fe98a44b019",
      "name": "Get Column Info2",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        368,
        2160
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 467321788,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA/edit#gid=467321788",
          "cachedResultName": "Columns"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA/edit?usp=drivesdk",
          "cachedResultName": "Sample Marketing Data"
        },
        "descriptionType": "manual",
        "toolDescription": "Extracts a sheet’s column metadata so downstream steps (querying, validation, docs) can rely on a clean, typed schema. It returns each column’s name, inferred data type, and human-readable description, plus helpful profiling hints."
      },
      "typeVersion": 4.7
    },
    {
      "id": "96e7c115-ecfa-40b1-90ac-96760588a56b",
      "name": "Simple Memory2",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        192,
        2144
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "e3fec4d3-f499-4a6e-ac00-70d2f784762c",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        16,
        2128
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "gpt-4o"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "09aab886-f1fd-447f-aded-70242aa27821",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -352,
        1440
      ],
      "parameters": {
        "color": 5,
        "width": 1584,
        "height": 1008,
        "content": "## 📬 Need Help or Want to Customize This?\n📧 [robert@ynteractive.com](mailto:robert@ynteractive.com)  \n🔗 [LinkedIn](https://www.linkedin.com/in/robert-breen-29429625/)"
      },
      "typeVersion": 1
    },
    {
      "id": "94911852-7bba-4178-a4bd-1461bf08d3db",
      "name": "Structured Output Parser1",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        528,
        2160
      ],
      "parameters": {
        "jsonSchemaExample": "{\n\t\"query\": \"sql query for google sheets\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "262e5d0d-c616-4332-a0ab-f1bc9d7225ef",
      "name": "OpenAI Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        880,
        1840
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "734f8a72-054b-4d04-bd9b-dc85ba160683",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -160,
        1744
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "be5f8fc5-0d06-4acf-8fa8-efca6310f0ec",
      "name": "Get Data from Google Sheet",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        640,
        1888
      ],
      "parameters": {
        "url": "={{ $json.output.query }}",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {}
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "71029e6d-3933-49a0-b31b-1461ef3a176f",
      "name": "Write into Table Output1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        864,
        1616
      ],
      "parameters": {
        "text": "={{ $json.data }}",
        "options": {
          "systemMessage": "write this into one table. output as dimensions, then metrics"
        },
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "43d7c1a8-0fc0-4877-ab9c-908c3836239a",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1920,
        1440
      ],
      "parameters": {
        "width": 752,
        "height": 1008,
        "content": "## Step-by-Step Setup Instructions\n\n\n### 1. Set Up OpenAI Connections\n\n#### Get API Key:\n1. Go to [OpenAI Platform](https://platform.openai.com/)\n2. Sign in or create an account\n3. Navigate to **API Keys** section\n4. Click **Create new secret key**\n5. Copy the generated API key\n6. **Important**: Add billing information and credits to your OpenAI account\n\n#### Configure Both OpenAI Nodes:\n1. **OpenAI Chat Model1 (GPT-4o)**:\n   - Click on the node\n   - Click **Create New Credential**\n   - Select **OpenAI API**\n   - Paste your API key\n   - Save the credential\n\n2. **OpenAI Chat Model2 (GPT-4.1 Mini)**:\n   - Apply the same OpenAI API credential\n   - This handles result formatting\n\n### 4. Set Up Google Sheets Connection\n\n#### Create OAuth2 Credentials:\n1. Go to [Google Cloud Console](https://console.cloud.google.com/)\n2. Create a new project or select existing one\n3. Enable the **Google Sheets API**\n4. Go to **Credentials** → **Create Credentials** → **OAuth 2.0 Client IDs**\n5. Set application type to **Web Application**\n6. Add authorized redirect URIs (get this from n8n credentials setup)\n7. Copy the **Client ID** and **Client Secret**\n\n#### Configure in n8n:\n1. Click on the **Get Column Info2** node\n2. Click **Create New Credential**\n3. Select **Google Sheets OAuth2 API**\n4. Enter your **Client ID** and **Client Secret**\n5. Complete the OAuth flow by clicking **Connect my account**\n6. Authorize the required permissions\n\n### 5. Prepare Your Google Sheet\n\n#### Option A: Use the Sample Data Sheet\n- Access the pre-configured sheet: [Sample Marketing Data](https://docs.google.com/spreadsheets/d/19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA/edit?usp=drivesdk)\n- Make a copy to your Google Drive\n- **Important**: Set sharing to \"Anyone with the link can view\"\n\n### 6. Configure Sheet References\n\n1. **Get Column Info2 Node**:\n   - Set **Document ID** to your Google Sheet ID\n   - Set **Sheet Name** to your columns metadata sheet (e.g., \"Columns\")\n   - This provides the AI with column letter mappings\n\n2. **HTTP Request Node**:\n   - No configuration needed - it uses dynamic URLs from the AI agent\n   - Ensure your sheet has proper sharing permissions\n\n### 7. Update System Prompt (If Using Custom Sheet)\n\nIf using your own Google Sheet, update the system prompt in the **AI Agent3** node:\n1. Replace the URL in the system message with your Google Sheet URL\n2. Update the GID (sheet ID) to match your data sheet\n3. Keep the same query structure format\n"
      },
      "typeVersion": 1
    },
    {
      "id": "0081f73b-ae42-424d-8cd1-9f9e0b30c64f",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1136,
        1440
      ],
      "parameters": {
        "width": 752,
        "height": 1008,
        "content": "\n\n### 5. Prepare Your Google Sheet\n\n#### Option A: Use the Sample Data Sheet\n- Access the pre-configured sheet: [Sample Marketing Data](https://docs.google.com/spreadsheets/d/19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA/edit?usp=drivesdk)\n- Make a copy to your Google Drive\n- **Important**: Set sharing to \"Anyone with the link can view\"\n\n### 6. Configure Sheet References\n\n1. **Get Column Info2 Node**:\n   - Set **Document ID** to your Google Sheet ID\n   - Set **Sheet Name** to your columns metadata sheet (e.g., \"Columns\")\n   - This provides the AI with column letter mappings\n\n2. **HTTP Request Node**:\n   - No configuration needed - it uses dynamic URLs from the AI agent\n   - Ensure your sheet has proper sharing permissions\n\n### 7. Update System Prompt (If Using Custom Sheet)\n\nIf using your own Google Sheet, update the system prompt in the **AI Agent3** node:\n1. Replace the URL in the system message with your Google Sheet URL\n2. Update the GID (sheet ID) to match your data sheet\n3. Keep the same query structure format\n"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "AI Agent3": {
      "main": [
        [
          {
            "node": "Get Data from Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory2": {
      "ai_memory": [
        [
          {
            "node": "AI Agent3",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Get Column Info2": {
      "ai_tool": [
        [
          {
            "node": "AI Agent3",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent3",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Write into Table Output1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser1": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent3",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Get Data from Google Sheet": {
      "main": [
        [
          {
            "node": "Write into Table Output1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {},
  "active": false
}
