{
  "name": "Access control for AI agents (RBAC) using Airtable and Telegram",
  "nodes": [
    {
      "id": "77771654-bfb9-4c34-b644-d4d6eeb15d37",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        560,
        260
      ]
    },
    {
      "id": "f1ef483e-4f84-40c7-957d-191a54ffb80e",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        360,
        260
      ]
    },
    {
      "id": "c6ba00c9-8ca2-4cf0-9e2c-24ead9eb7c1b",
      "name": "Check permissions",
      "type": "@n8n/n8n-nodes-langchain.code",
      "position": [
        960,
        260
      ]
    },
    {
      "id": "db15e298-b8d0-4096-b606-18bc8d43bb39",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -240,
        -120
      ]
    },
    {
      "id": "3df9b9f5-c0a2-4905-95aa-285b492f2ec0",
      "name": "Set input",
      "type": "n8n-nodes-base.set",
      "position": [
        420,
        0
      ]
    },
    {
      "id": "a5af8184-4a17-447e-96d3-809c6bd131f3",
      "name": "Get user permissions",
      "type": "n8n-nodes-base.airtable",
      "position": [
        -20,
        -120
      ]
    },
    {
      "id": "4abf80e7-9b1f-4ef0-b742-da29e1208b78",
      "name": "When Executed by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        0,
        800
      ]
    },
    {
      "id": "10129d31-3446-47a0-aacd-3bd584b0bd79",
      "name": "Settings",
      "type": "n8n-nodes-base.set",
      "position": [
        220,
        800
      ]
    },
    {
      "id": "c45f4258-8ef6-4bf6-878f-5e86ac577712",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        340,
        1060
      ]
    },
    {
      "id": "e5cf82bc-c9a8-474e-bbeb-201e3431fa36",
      "name": "Simple Memory1",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        540,
        1060
      ]
    },
    {
      "id": "e9fd93c9-c008-470b-885a-4287950b9c3d",
      "name": "Check permissions1",
      "type": "@n8n/n8n-nodes-langchain.code",
      "position": [
        740,
        1060
      ]
    },
    {
      "id": "f791deb0-9ebe-4451-8a1f-3119547dd576",
      "name": "list_granted_roles",
      "type": "@n8n/n8n-nodes-langchain.toolCode",
      "position": [
        1000,
        460
      ]
    },
    {
      "id": "ab0c6dae-6259-4be1-b0df-e3276cafb938",
      "name": "list_allowed_tools",
      "type": "@n8n/n8n-nodes-langchain.toolCode",
      "position": [
        1160,
        460
      ]
    },
    {
      "id": "76529936-80ea-4f94-9a06-bae3b6ea0ce3",
      "name": "calculator",
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "position": [
        860,
        460
      ]
    },
    {
      "id": "fd7f4875-6838-4b53-9167-4a22d4f5f27f",
      "name": "Wikipedia",
      "type": "@n8n/n8n-nodes-langchain.toolWikipedia",
      "position": [
        760,
        260
      ]
    },
    {
      "id": "0dc5c3e6-b9d2-4a96-9539-dae86dc171a6",
      "name": "get_coordinates",
      "type": "@n8n/n8n-nodes-langchain.toolHttpRequest",
      "position": [
        800,
        1260
      ]
    },
    {
      "id": "e70a2cb2-832b-4741-85d2-c446be168ad4",
      "name": "get_weather",
      "type": "@n8n/n8n-nodes-langchain.toolHttpRequest",
      "position": [
        980,
        1260
      ]
    },
    {
      "id": "66c5568d-d2fe-4938-b577-b005a5c32e37",
      "name": "weather_agent",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        1360,
        460
      ]
    },
    {
      "id": "ffcf4df4-f969-4bc1-9393-0e7a4317626a",
      "name": "Weather Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        440,
        800
      ]
    },
    {
      "id": "eae759d7-fa4a-4993-bbcf-cc430f2dfa60",
      "name": "Unknown user",
      "type": "n8n-nodes-base.if",
      "position": [
        200,
        -120
      ]
    },
    {
      "id": "df377324-d57d-45ab-85c7-88446a07abcd",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        -260
      ],
      "parameters": {
        "width": 220,
        "height": 300,
        "content": "## Choose Base\nCopy [this Airtable Template](https://airtable.com/appi5nijuvzQbZLJJ/shr8OkLysG1VtlCiz) into your workspace and select that Base here"
      }
    },
    {
      "id": "b1ddd130-07fa-47e3-ba24-7b4e85f94b6a",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1280,
        300
      ],
      "parameters": {
        "width": null,
        "height": 300,
        "content": "## Choose workflow\nSelect the current workflow as the workflow that should be called"
      }
    },
    {
      "id": "7d24fc8e-36e7-4087-88cc-7f1c725ce814",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        900,
        160
      ],
      "parameters": {
        "width": 380,
        "height": 220,
        "content": "Uses list of allowed tools gathered from Airtable to check for permissions and replaces denied tools with a fixed instruction to return a message to the user."
      }
    },
    {
      "id": "987b3372-1703-4284-a285-d2edfd032422",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        700,
        160
      ],
      "parameters": {
        "width": 200,
        "height": 220,
        "content": "Tools can also be connected without a permission check"
      }
    },
    {
      "id": "885b0117-bae1-4aac-a91f-e140259b32e2",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        580,
        -80
      ],
      "parameters": {
        "width": 380,
        "height": 240,
        "content": "Main agent with the instruction to always use the connected tools instead of general knowledge"
      }
    },
    {
      "id": "25f17f39-a777-4386-b14d-1ed7db3c54f4",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        360,
        -80
      ],
      "parameters": {
        "width": 220,
        "height": 240,
        "content": "Collects input and formats it using required keys"
      }
    },
    {
      "id": "a0abbeea-d9c1-4005-b996-d4e8e4fd97d3",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        720
      ],
      "parameters": {
        "width": 220,
        "height": 240,
        "content": "Collects and formats input from parent workflow / agent"
      }
    },
    {
      "id": "8e25e640-7b6d-4ca7-b3fd-06eac3cebbea",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        680,
        960
      ],
      "parameters": {
        "width": 380,
        "height": 220,
        "content": "Uses the same technique as the main agent to check for permissions using the same parameters which were passed to this sub-agent."
      }
    },
    {
      "id": "1168726e-2a39-40f6-aea6-77c12dc2b37b",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        380,
        720
      ],
      "parameters": {
        "width": 380,
        "height": 240,
        "content": "Sub-agent with specific role to handle weather information. Also having the instruction to strictly only use the connected tools."
      }
    },
    {
      "id": "e65e1ea3-c773-4e65-8c49-b9f7fe75df28",
      "name": "Reply: unknown user",
      "type": "n8n-nodes-base.telegram",
      "position": [
        420,
        -240
      ]
    },
    {
      "id": "aa5937b9-22d2-4719-9d51-00f7d28beb43",
      "name": "Reply with results",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1020,
        0
      ]
    },
    {
      "id": "623328d8-e9ad-431e-b3ca-df0cdbcb7430",
      "name": "Main Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        640,
        0
      ]
    },
    {
      "id": "cacefd8b-082c-43a4-9e25-fb497d0d8dd9",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        500,
        160
      ],
      "parameters": {
        "width": 200,
        "height": 220,
        "content": "Be aware, that previous responses may still exist after permission changes"
      }
    },
    {
      "id": "802ba649-b56e-4e90-a780-a3a1935a7907",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        960
      ],
      "parameters": {
        "width": 200,
        "height": 220,
        "content": "Uses different session ID (suffix), since every agent needs its own memory"
      }
    },
    {
      "id": "b82c9149-e583-4c98-a6d8-c92080fd44ba",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -300,
        -200
      ],
      "parameters": {
        "width": 220,
        "height": 240,
        "content": "Listens to messages directly sent to the bot"
      }
    },
    {
      "id": "b74fcbc1-aa66-440a-9a75-340858bba6c5",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        140,
        -200
      ],
      "parameters": {
        "width": 220,
        "height": 240,
        "content": "Checks if the user was found in Airtable"
      }
    }
  ],
  "connections": {
    "Settings": {
      "main": [
        [
          {
            "node": "Weather Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set input": {
      "main": [
        [
          {
            "node": "Main Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wikipedia": {
      "ai_tool": [
        [
          {
            "node": "Main Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Main Agent": {
      "main": [
        [
          {
            "node": "Reply with results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "calculator": {
      "ai_tool": [
        [
          {
            "node": "Check permissions",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "get_weather": {
      "ai_tool": [
        [
          {
            "node": "Check permissions1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Unknown user": {
      "main": [
        [
          {
            "node": "Reply: unknown user",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Main Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "weather_agent": {
      "ai_tool": [
        [
          {
            "node": "Check permissions",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory1": {
      "ai_memory": [
        [
          {
            "node": "Weather Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "get_coordinates": {
      "ai_tool": [
        [
          {
            "node": "Check permissions1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Get user permissions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check permissions": {
      "ai_tool": [
        [
          {
            "node": "Main Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Main Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Check permissions1": {
      "ai_tool": [
        [
          {
            "node": "Weather Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Weather Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "list_allowed_tools": {
      "ai_tool": [
        [
          {
            "node": "Check permissions",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "list_granted_roles": {
      "ai_tool": [
        [
          {
            "node": "Check permissions",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get user permissions": {
      "main": [
        [
          {
            "node": "Unknown user",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}