{
  "id": "ZwLdirMz7WaPuc9u",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Sended - access permission",
  "tags": [],
  "nodes": [
    {
      "id": "c9472226-bbf2-48a8-b504-c2e0bac6fedc",
      "name": "No Operation, do nothing",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -48,
        -96
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "032bed96-34be-465f-90fd-a7e9c9fe4982",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1184,
        -112
      ],
      "parameters": {
        "height": 384,
        "content": "## Input data\nThread to connect Credential to connect with"
      },
      "typeVersion": 1
    },
    {
      "id": "8182317e-d432-48b4-ae2f-133200e4fdb2",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -912,
        -112
      ],
      "parameters": {
        "height": 384,
        "content": "## Table with a list of employees \nSelect the created Data table (you can choose either Google Sheets or Airtable)"
      },
      "typeVersion": 1
    },
    {
      "id": "c04f2648-5327-46d3-a49f-d88f85922ce5",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -640,
        -112
      ],
      "parameters": {
        "height": 384,
        "content": "## Employee access filter\nnames - access statuses"
      },
      "typeVersion": 1
    },
    {
      "id": "bf553e89-9301-48c1-93b7-c5ebe2ee302f",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -368,
        -112
      ],
      "parameters": {
        "height": 384,
        "content": "## Response when access is denied"
      },
      "typeVersion": 1
    },
    {
      "id": "4f8ca4cb-f15d-4743-8b26-76fee1e8478c",
      "name": "Permission",
      "type": "n8n-nodes-base.switch",
      "position": [
        -576,
        96
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Granted",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "f697ce64-74f6-4e00-a6e5-24107113995f",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.Access }}",
                    "rightValue": "Granted"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Denied",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "6ff5cad5-7ae5-40f6-8d67-a25b8951167d",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.Access }}",
                    "rightValue": "Denied"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.3
    },
    {
      "id": "f4f8be63-6023-4ea8-8f5f-3a8c67f75d42",
      "name": "Answer Denied",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -304,
        112
      ],
      "parameters": {
        "text": "Access dinied",
        "chatId": "={{ $('Input Data').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "8a0a7195-0cd0-4f10-8d63-a8f275b6f869",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1840,
        336
      ],
      "parameters": {
        "color": 2,
        "width": 640,
        "height": 528,
        "content": "## Description\n\n\ud83d\udcdd Access Control Flow \u2014 Quick Guide\n\nTelegram Trigger \u2014 receives a message from the user.\n\nUser Access Table \u2014 stores the list of users and their access status (granted / denied).\n\nCheck Access (IF Node) \u2014 verifies if the user is allowed to continue.\n\u2003- \u2705 Granted \u2192 workflow continues.\n\u2003- \u274c Denied \u2192 stops or skips the response.\n\n(Optional) \u2014 update the user\u2019s status in the table anytime to instantly revoke access.\n\n\ud83d\udca1 Use case:\nPerfect for restricting access to internal bots or automations only to your team members."
      },
      "typeVersion": 1
    },
    {
      "id": "538d0040-d075-4350-b888-8e75a85724bc",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1840,
        -112
      ],
      "parameters": {
        "color": 2,
        "width": 640,
        "height": 416,
        "content": "## [Video Tutorial](https://youtu.be/Blm7iamYaoA)\n@[youtube](Blm7iamYaoA)"
      },
      "typeVersion": 1
    },
    {
      "id": "e6a0b869-8c90-4a91-8301-fc3290c005be",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1120,
        96
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "aa1bada5-b182-4ddc-855a-9bcdf413f30c",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1184,
        304
      ],
      "parameters": {
        "color": 7,
        "width": 848,
        "height": 576,
        "content": "## Can be used\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "0b0798a7-9672-444b-b909-b70b59a4672f",
      "name": "Slack Trigger",
      "type": "n8n-nodes-base.slackTrigger",
      "position": [
        -1136,
        400
      ],
      "parameters": {
        "options": {},
        "trigger": [
          "any_event"
        ],
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "typeVersion": 1
    },
    {
      "id": "947b90c3-75e4-48ea-bfd5-ff7e51d51f5a",
      "name": "Get row(s) in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -848,
        336
      ],
      "parameters": {
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "6b3daa96-e27d-4808-905d-95f68fb1cde6",
      "name": "Get a record",
      "type": "n8n-nodes-base.airtable",
      "position": [
        -848,
        496
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "options": {}
      },
      "typeVersion": 2.1
    },
    {
      "id": "ad4f0fc1-6dea-4c04-ae52-0036b9b38480",
      "name": "Get a database page",
      "type": "n8n-nodes-base.notion",
      "position": [
        -848,
        672
      ],
      "parameters": {
        "pageId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "resource": "databasePage",
        "operation": "get"
      },
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "0fecf591-9ac2-4682-9fb2-dd9c306cc301",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        -576,
        416
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "34636f26-6207-4687-9e42-2bac831c57a8",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "506988e7-e20e-47a3-9425-06e2acfc02d3",
      "name": "Filter",
      "type": "n8n-nodes-base.filter",
      "position": [
        -576,
        608
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "b52c63b1-9c33-4a06-8c12-7b1f5e39dd35",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "fb2f871f-d2cb-48d3-bb67-2c3dd235006f",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2512,
        -400
      ],
      "parameters": {
        "width": 640,
        "height": 1264,
        "content": "## Instruction\n\n## 1. Connect Telegram Bot\nThis workflow starts with a Telegram Trigger node.\nIn Telegram, open @BotFather\n\nCreate a bot:\n/newbot\nFollow prompts \u2192 copy the Bot Token.\n\n## 2. In n8n:\nGo to Credentials \u2192 New \u2192 Telegram API.\nName it (e.g., \u201cTelegram Access Control\u201d).\nPaste your Bot Token.\n\nOpen the Telegram Trigger node:\nSelect your Telegram API credential.\nMake sure Updates: message is selected.\nClick \u201cTest Webhook\u201d and send a test message to your bot in Telegram.\nn8n should display your test message in the Test Webhook window.\n\u2705 Now your Telegram bot is connected.\n\n## 3. Prepare the Access Table\n\nYou can use one of several data sources:\nn8n Data Table (recommended for simplicity)\nGoogle Sheets\nAirtable\nNotion\nAdd records, for example:\nUserName\tAccess\njohndoe\tGranted\njanedoe\tDenied\n\nOpen the DataBase with employees node:\nChoose your new table under \u201cData Table ID\u201d.\nThe workflow will automatically find a record where:\nUserName == $json.message.from.username\nConfigure the Access Logic\n\n## 4. In the Permission (Switch) node:\n\nIf $json.Access = Granted \u2192 continues to the next step (No Operation node).\nIf $json.Access = Denied \u2192 sends a Telegram reply \u201cAccess denied\u201d.\nYou can customize:\nText of the denial message in Answer Denied node (text field).\nWhat happens on \u201cGranted\u201d output (e.g., connect your main workflow logic).\n\n## 5. Test the Flow\n\nActivate the workflow (set Active: ON).\nSend a Telegram message to your bot.\nThe flow will:\nCheck your Telegram username.\nLook it up in the data table.\nRespond \u201cAccess denied\u201d or continue (depending on Access value)."
      },
      "typeVersion": 1
    },
    {
      "id": "11357eba-2ed4-4739-b273-84fb2cc6a5f8",
      "name": "Database with employees",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        -848,
        96
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "UserName",
              "keyValue": "={{ $json.message.from.username }}"
            }
          ]
        },
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "59g2BfS1TctO7gzg"
        }
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "ff6351b4-120f-481d-a15a-ef1a168b646a",
  "connections": {
    "If": {
      "main": [
        []
      ]
    },
    "Permission": {
      "main": [
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Answer Denied",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get a record": {
      "main": [
        []
      ]
    },
    "Slack Trigger": {
      "main": [
        []
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Database with employees",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet": {
      "main": [
        []
      ]
    },
    "Database with employees": {
      "main": [
        [
          {
            "node": "Permission",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    }
  }
}