{"id": "fa2TGWrY9rPurC30", "name": "Agent Access Control Template", "nodes": [{"id": "77771654-bfb9-4c34-b644-d4d6eeb15d37", "name": "Simple Memory", "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow", "position": [560, 260], "parameters": {"sessionKey": "={{ $('Telegram Trigger').item.json.message.from.id }}", "sessionIdType": "customKey"}, "typeVersion": 1.3}, {"id": "f1ef483e-4f84-40c7-957d-191a54ffb80e", "name": "OpenAI Chat Model", "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi", "position": [360, 260], "parameters": {"model": {"__rl": true, "mode": "list", "value": "gpt-4o", "cachedResultName": "gpt-4o"}, "options": {}}, "credentials": {"openAiApi": {"id": "X7Jf0zECd3IkQdSw", "name": "OpenAi (octionicsolutions)"}}, "typeVersion": 1.2}, {"id": "c6ba00c9-8ca2-4cf0-9e2c-24ead9eb7c1b", "name": "Check permissions", "type": "@n8n/n8n-nodes-langchain.code", "position": [960, 260], "parameters": {"code": {"supplyData": {"code": "const { DynamicTool } = require(\"@langchain/core/tools\");\nconst connectedTools = await this.getInputConnectionData('ai_tool', 0);\nconst allowedTools = $input.item.json.allowed_tools;\n\nconst noTool = (tool) => {\n return new DynamicTool({\n name: tool.getName(),\n description: tool.description,\n func: async () => {\n return \"Tell the user 'You are not authorized to use this tool'.\";\n },\n });\n}\n\nreturn connectedTools.map(connectedTool => {\n const permissionGranted = allowedTools.includes(connectedTool.getName());\n return permissionGranted ? connectedTool : noTool(connectedTool);\n});"}}, "inputs": {"input": [{"type": "ai_tool", "required": true}]}, "outputs": {"output": [{"type": "ai_tool"}]}}, "typeVersion": 1}, {"id": "db15e298-b8d0-4096-b606-18bc8d43bb39", "name": "Telegram Trigger", "type": "n8n-nodes-base.telegramTrigger", "position": [-240, -120], "webhookId": "4410accd-63e4-4c38-ad0b-26874f5eb673", "parameters": {"updates": ["message"], "additionalFields": {}}, "credentials": {"telegramApi": {"id": "3paV9xW2WWlusvsq", "name": "octionictest_bot"}}, "typeVersion": 1.2}, {"id": "3df9b9f5-c0a2-4905-95aa-285b492f2ec0", "name": "Set input", "type": "n8n-nodes-base.set", "position": [420, 0], "parameters": {"options": {}, "assignments": {"assignments": [{"id": "9ea62c8f-984b-4c05-8e40-549d8035c4d3", "name": "name", "type": "string", "value": "={{ $json.name }}"}, {"id": "bf74b2c4-f0d1-458a-9044-5cb1b62722e6", "name": "granted_roles", "type": "array", "value": "={{ $json.granted_roles