{
  "name": "Inventory Telegram Google Sheets Demo",
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.2,
      "position": [
        700,
        -360
      ],
      "id": "f8c3ec11-2211-4531-805e-780604a136bb",
      "name": "Telegram Trigger",
      "webhookId": "ad921f1d-6aee-4063-b33c-2a1b9cde041e",
      "credentials": {
        "telegramApi": {
          "id": "IR7xqx0ILwANdL7f",
          "name": "n8n bot"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.message.text }}",
        "options": {
          "systemMessage": "=You are Stocky, a helpful and efficient AI assistant embedded in a Telegram bot. You manage office supply inventory using a connected Google Sheet — and you can both read from and update the sheet.\n\nYour responsibilities:\n\n\nGreet as Stock (Ai Agent)\n\nUnderstand the user’s request and identify the relevant data point in the Google Sheet.\n\nRetrieve the most accurate, up-to-date information.\n\nUpdate the sheet when needed (e.g. logging new items, adjusting stock).\n\nRespond clearly and confidently in a friendly tone.\n\nIf the data isn’t available, politely inform the user and suggest how they can clarify their request.\n\n📋 Guidelines:\n\nOnly reference facts from the Google Sheet or this prompt.\n\nNever hallucinate or guess.\n\nUse bullet points for clarity when helpful.\n\nKeep replies focused — don’t reveal system logic or inner workings.\n\n"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.8,
      "position": [
        860,
        -360
      ],
      "id": "7cb56b9b-cdf7-4c87-bfb7-5621c3de77bd",
      "name": "Inventory AI Agent (Stocky)"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        720,
        -140
      ],
      "id": "d543bcab-4a7a-49d2-8d31-4aaa6ed27f3c",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "id": "MzIepidaRw9ZqcPB",
          "name": "OpenAi account Credentials"
        }
      }
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "10QlA66yCMnvRCR_Ge-ziCfUDz4mX6wF1NnnjOPt9PQw",
          "mode": "list",
          "cachedResultName": "Inventory",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10QlA66yCMnvRCR_Ge-ziCfUDz4mX6wF1NnnjOPt9PQw/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Office Supplies",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10QlA66yCMnvRCR_Ge-ziCfUDz4mX6wF1NnnjOPt9PQw/edit#gid=0"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.5,
      "position": [
        1000,
        -140
      ],
      "id": "c2aee5f9-58b2-4135-bf2a-247464671993",
      "name": "Get Stock Levels",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "ESD8JJHqd8A9NlNx",
          "name": "Google Sheets account (Kris)"
        }
      }
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "10QlA66yCMnvRCR_Ge-ziCfUDz4mX6wF1NnnjOPt9PQw",
          "mode": "list",
          "cachedResultName": "Inventory",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10QlA66yCMnvRCR_Ge-ziCfUDz4mX6wF1NnnjOPt9PQw/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Office Supplies",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10QlA66yCMnvRCR_Ge-ziCfUDz4mX6wF1NnnjOPt9PQw/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Item Name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Item_Name', ``, 'string') }}",
            "Item ID": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Item_ID', ``, 'string') }}",
            "Quantity in Stock": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Quantity_in_Stock', ``, 'string') }}",
            "Unit Price": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Unit_Price', ``, 'string') }}",
            "Supplier": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Supplier', ``, 'string') }}",
            "Reorder Amount": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Reorder_Amount', ``, 'string') }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Item Name",
              "displayName": "Item Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Item ID",
              "displayName": "Item ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Quantity in Stock",
              "displayName": "Quantity in Stock",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Unit Price",
              "displayName": "Unit Price",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Supplier",
              "displayName": "Supplier",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Reorder Amount",
              "displayName": "Reorder Amount",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.5,
      "position": [
        1160,
        -140
      ],
      "id": "401b8109-7cb1-4531-b24e-a44371b82a24",
      "name": "Update Inventory",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "ESD8JJHqd8A9NlNx",
          "name": "Google Sheets account (Kris)"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Telegram Trigger').item.json.message.chat.id }}"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        840,
        -140
      ],
      "id": "760ef65b-362b-4382-ae5d-8401ae8e22f5",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "text": "={{ $json.output }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1180,
        -360
      ],
      "id": "62938080-e086-4d4a-8d22-ddddeb24ba10",
      "name": "Telegram",
      "webhookId": "c50e46ab-d028-4dd3-9e7d-164ebd7b0786",
      "credentials": {
        "telegramApi": {
          "id": "IR7xqx0ILwANdL7f",
          "name": "n8n bot"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Inventory AI Agent (Stocky)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Inventory AI Agent (Stocky)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Get Stock Levels": {
      "ai_tool": [
        [
          {
            "node": "Inventory AI Agent (Stocky)",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Update Inventory": {
      "ai_tool": [
        [
          {
            "node": "Inventory AI Agent (Stocky)",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Inventory AI Agent (Stocky)",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Inventory AI Agent (Stocky)": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "94fc2083-bdfc-453f-9c8d-f6705eb31ce9",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "4aabc0aa2e160dafa4f9d9bcedde563b5af29598cd16960f637ae2fb99aea720"
  },
  "id": "3Oh9y8vDoGYp7cTW",
  "tags": []
}