AutomationFlowsAI & RAG › Multi-department Support Bot with Slash Commands, Pinecone & Telegram

Multi-department Support Bot with Slash Commands, Pinecone & Telegram

Bymoosa @moosa on n8n.io

/billing - For payment and invoice questions /tech-support - For technical assistance /return-policy - For returns and refunds Command-based routing Direct department access via slash commands Tracks active conversations in PostgreSQL Pinecone vector stores for each department…

Event trigger★★★★★ complexityAI-powered52 nodesTelegramPinecone Vector StoreGoogle Drive TriggerGoogle DriveCohere EmbeddingsDocument Default Data LoaderText Splitter Character Text SplitterTelegram Trigger
AI & RAG Trigger: Event Nodes: 52 Complexity: ★★★★★ AI nodes: yes Added:

This workflow corresponds to n8n.io template #6010 — we link there as the canonical source.

This workflow follows the Agent → Documentdefaultdataloader recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "nodes": [
    {
      "id": "169a4b72-f521-4804-8707-4ae76d3d0c44",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        320,
        1180
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "35a9494a-ca0e-43da-bd95-fe07dd7806ca",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{$('Telegram Trigger').item.json.message.text}}",
                    "rightValue": "/ReturnPolicy"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "afb17bcd-17e4-4e68-96b3-2bbb6cd4fb82",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{$('Telegram Trigger').item.json.message.text}}",
                    "rightValue": "/TechSupport"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "8cb762a5-51de-4dba-b8fc-9a68f9ec06a1",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{$('Telegram Trigger').item.json.message.text}}",
                    "rightValue": "/billing"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "ed19a160-1fb9-4d93-92b8-9b8a1368567d",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{$('Telegram Trigger').item.json.message.text}}",
                    "rightValue": "asakjlkadjclsdja"
                  }
                ]
              }
            }
          ]
        },
        "options": {
          "fallbackOutput": 3
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "2655b5df-6785-439e-9783-618a06c8784b",
      "name": "return policy",
      "type": "n8n-nodes-base.telegram",
      "position": [
        620,
        1000
      ],
      "parameters": {
        "text": "lets talk return policy",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "forceReply": {
          "force_reply": false
        },
        "replyMarkup": "forceReply",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "32410d0b-32a5-4393-b82f-556faca60cae",
      "name": "talk technical",
      "type": "n8n-nodes-base.telegram",
      "position": [
        760,
        1180
      ],
      "parameters": {
        "text": "lets talk technical",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "0b0128f0-68fe-463e-add2-17020aee9ac1",
      "name": "billing",
      "type": "n8n-nodes-base.telegram",
      "position": [
        760,
        1380
      ],
      "parameters": {
        "text": "lets talk billing",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7c70d33d-88a8-47de-9285-87024c0252df",
      "name": "Pinecone Vector Store3",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        640,
        2360
      ],
      "parameters": {
        "mode": "insert",
        "options": {
          "pineconeNamespace": "billing"
        },
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "n8n-proj",
          "cachedResultName": "n8n-proj"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "d46f0633-3bd1-49e0-8b24-2a752032f727",
      "name": "Google Drive Trigger",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        180,
        2560
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "hour": 1,
              "mode": "everyMonth"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "id",
          "value": "1Ts06s4RSssNx8tfIqTbjFeWZL1Dno_xJ"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "fe91a6d9-f4ed-4592-9df6-25a73aafdc1d",
      "name": "Download file",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        400,
        2560
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "typeVersion": 3
    },
    {
      "id": "af0b032a-b100-48c6-9740-e9d5b62d336d",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        120,
        2300
      ],
      "parameters": {
        "width": 960,
        "height": 620,
        "content": "## billing upload"
      },
      "typeVersion": 1
    },
    {
      "id": "ee6c5ee5-74c3-4be1-91fe-7f62fa46bce2",
      "name": "Embeddings Cohere3",
      "type": "@n8n/n8n-nodes-langchain.embeddingsCohere",
      "position": [
        620,
        2580
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "fb0fb46c-a04f-451a-9793-822fa42049e9",
      "name": "Default Data Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        740,
        2600
      ],
      "parameters": {
        "options": {},
        "dataType": "binary",
        "textSplittingMode": "custom"
      },
      "typeVersion": 1.1
    },
    {
      "id": "bed21d2d-e317-45cb-9d07-a9d8a27fa45d",
      "name": "Character Text Splitter",
      "type": "@n8n/n8n-nodes-langchain.textSplitterCharacterTextSplitter",
      "position": [
        840,
        2780
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "9194bfa2-e59a-44e9-890a-ef354fcda7fc",
      "name": "Pinecone Vector Store4",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        640,
        3020
      ],
      "parameters": {
        "mode": "insert",
        "options": {
          "pineconeNamespace": "tech ques"
        },
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "n8n-proj",
          "cachedResultName": "n8n-proj"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "c693ae06-a195-4d6a-8053-3578a9d718ac",
      "name": "Google Drive Trigger1",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        180,
        3220
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "hour": 1,
              "mode": "everyMonth"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1Tz-YkUC4dN85YyBeb-MPmexomRPx2AtN",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1Tz-YkUC4dN85YyBeb-MPmexomRPx2AtN",
          "cachedResultName": "talk technical"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "a0bcf807-5131-42ea-bfca-274766d0932c",
      "name": "Download file1",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        400,
        3220
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "typeVersion": 3
    },
    {
      "id": "c59e303f-a3ba-4250-b3ca-40bde6c3a6df",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        100,
        2980
      ],
      "parameters": {
        "width": 1000,
        "height": 600,
        "content": "## technical questions"
      },
      "typeVersion": 1
    },
    {
      "id": "e4e79010-96cb-4e83-aab4-096af8996e1d",
      "name": "Embeddings Cohere4",
      "type": "@n8n/n8n-nodes-langchain.embeddingsCohere",
      "position": [
        620,
        3240
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "d845fa2f-121e-44ff-8936-e9bac8b834a7",
      "name": "Default Data Loader1",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        740,
        3260
      ],
      "parameters": {
        "options": {},
        "dataType": "binary",
        "textSplittingMode": "custom"
      },
      "typeVersion": 1.1
    },
    {
      "id": "5a1914a3-830c-442e-88a7-2971ff56834e",
      "name": "Character Text Splitter1",
      "type": "@n8n/n8n-nodes-langchain.textSplitterCharacterTextSplitter",
      "position": [
        840,
        3440
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "696b1cd1-da5f-4234-8efe-abc06138ac97",
      "name": "Pinecone Vector Store5",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        640,
        3880
      ],
      "parameters": {
        "mode": "insert",
        "options": {
          "pineconeNamespace": "return policy"
        },
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "n8n-proj",
          "cachedResultName": "n8n-proj"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "53bc8499-b513-41bc-8cd4-098284b3dabe",
      "name": "Google Drive Trigger2",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        180,
        3880
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "hour": 1,
              "mode": "everyMonth"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1bomT-vMmuKgjl_y6XTgwfCUvPMyq2iZf",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1bomT-vMmuKgjl_y6XTgwfCUvPMyq2iZf",
          "cachedResultName": "return policy"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5e07b0c2-8d71-40c3-a3c9-4fc772b30218",
      "name": "Download file2",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        400,
        3880
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "typeVersion": 3
    },
    {
      "id": "ca734c58-dc19-40e8-933f-dd68f023ae02",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        100,
        3860
      ],
      "parameters": {
        "width": 980,
        "height": 580,
        "content": "## return policy"
      },
      "typeVersion": 1
    },
    {
      "id": "fc503485-7187-44df-ba80-d1976dcff6b1",
      "name": "Embeddings Cohere5",
      "type": "@n8n/n8n-nodes-langchain.embeddingsCohere",
      "position": [
        620,
        4100
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "534c6970-b519-4e51-acba-bda3f85ea8b8",
      "name": "Default Data Loader2",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        740,
        4120
      ],
      "parameters": {
        "options": {},
        "dataType": "binary",
        "textSplittingMode": "custom"
      },
      "typeVersion": 1.1
    },
    {
      "id": "95ff3aca-f1a8-4f52-95c1-74412d5cabb8",
      "name": "Character Text Splitter2",
      "type": "@n8n/n8n-nodes-langchain.textSplitterCharacterTextSplitter",
      "position": [
        840,
        4300
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "95de976e-cb31-48d7-a160-dbc1f50ae83a",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        180,
        580
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "d0c5aee1-8e14-4400-8686-286800c35dd0",
      "name": "Send a text message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1560,
        180
      ],
      "parameters": {
        "text": "to connect to specific reply with their key:\nfor Billing: /billing\nfor Return Policy: /ReturnPolicy\nfor Tech Support: /TechSupport",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "2f5d1808-9c59-444c-ae26-252840bef07d",
      "name": "Switch1",
      "type": "n8n-nodes-base.switch",
      "position": [
        840,
        560
      ],
      "parameters": {
        "mode": "expression",
        "output": "={{ \n  $('Telegram Trigger').item.json.message.text === \"/start\" ? 0 :\n  $('Telegram Trigger').item.json.message.text === \"/end\" ? 3 :\n  ($json.active === \"true\" || $json.active === true)\n    ? ($json.department != null ? 2 : 4)\n    : 1\n}}\n",
        "numberOutputs": 5
      },
      "typeVersion": 3.2
    },
    {
      "id": "7cd8a4b2-0133-4f67-a99c-fb213e1fe114",
      "name": "Send a text message4",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1560,
        380
      ],
      "parameters": {
        "text": "reply with /start to get options. \nTo end chat reply with /end",
        "chatId": "={{ $('Telegram Trigger').item.json.message.from.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "9cae49e0-00f6-46b4-947a-a5373afd2db0",
      "name": "AI Agent3",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1300,
        580
      ],
      "parameters": {
        "text": "={{ $('Telegram Trigger').item.json.message.text }}",
        "options": {
          "systemMessage": "=You are a helpful assistant\n\n## job\n-your  job  is guide user on respective department\n- department: {{ $json.department }}\n\n## source\n- you can access data from respective vector store connected as tool\n## note\n- if user is on a department let say billing and asks questions for tech support respectully decline and ask user to end conversation with current department usind /end commant and start again\n- be precise in answers\n\n## signoff as john wick"
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "2f847e8b-5284-44f7-9c02-51b21afd6cd4",
      "name": "Pinecone Vector Store6",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        1300,
        820
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "options": {
          "pineconeNamespace": "return policy"
        },
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "n8n-proj",
          "cachedResultName": "n8n-proj"
        },
        "toolDescription": "vectore store for return policy."
      },
      "typeVersion": 1.3
    },
    {
      "id": "c479a97b-c4e3-4b2c-a81a-356121ad33ad",
      "name": "Embeddings Cohere6",
      "type": "@n8n/n8n-nodes-langchain.embeddingsCohere",
      "position": [
        1400,
        1000
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "f657fd84-8f76-4666-ad5e-d31cd9e94a6b",
      "name": "OpenRouter Chat Model3",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        1060,
        800
      ],
      "parameters": {
        "model": "deepseek/deepseek-chat-v3-0324:free",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "5fe9737c-3017-47c2-b6b6-aa432b7a40d8",
      "name": "Simple Memory3",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1180,
        800
      ],
      "parameters": {
        "sessionKey": "={{ $json.user_id }}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "1df2223b-10b0-4188-a096-0eab3ff7fbc3",
      "name": "Pinecone Vector Store7",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        1600,
        820
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "options": {
          "pineconeNamespace": "tech ques"
        },
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "n8n-proj",
          "cachedResultName": "n8n-proj"
        },
        "toolDescription": "vectore store for technical questions."
      },
      "typeVersion": 1.3
    },
    {
      "id": "0cfb6c6d-a8b7-431b-9eaf-14b2c5271a78",
      "name": "Embeddings Cohere7",
      "type": "@n8n/n8n-nodes-langchain.embeddingsCohere",
      "position": [
        1680,
        1000
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "bf4ab1b4-6759-432a-92f7-12e126e58f51",
      "name": "Pinecone Vector Store8",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        1900,
        820
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "options": {
          "pineconeNamespace": "billing"
        },
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "n8n-proj",
          "cachedResultName": "n8n-proj"
        },
        "toolDescription": "vectore store for billing data."
      },
      "typeVersion": 1.3
    },
    {
      "id": "5df4670c-f094-4473-a486-d0afdb2aa403",
      "name": "Embeddings Cohere8",
      "type": "@n8n/n8n-nodes-langchain.embeddingsCohere",
      "position": [
        1980,
        1000
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "9382e126-fc0d-4b06-a729-de2a43da77cb",
      "name": "Send a text message1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1960,
        580
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.from.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "8b2596d8-9f34-4ac3-8f26-bcecb2317f13",
      "name": "Execute a SQL query",
      "type": "n8n-nodes-base.postgres",
      "position": [
        -580,
        1080
      ],
      "parameters": {
        "query": "CREATE TABLE tg_user_sessions (\n    user_id BIGINT PRIMARY KEY,\n    department TEXT,\n    active BOOLEAN DEFAULT FALSE,\n    last_updated TIMESTAMP DEFAULT NOW()\n);\n",
        "options": {},
        "operation": "executeQuery"
      },
      "typeVersion": 2.6
    },
    {
      "id": "f3bb4192-e412-4008-9d40-d8144978a8b3",
      "name": "Execute a SQL query1",
      "type": "n8n-nodes-base.postgres",
      "position": [
        400,
        580
      ],
      "parameters": {
        "query": "INSERT INTO tg_user_sessions (user_id, active)\nSELECT {{ $json.message.from.id }}, FALSE\nWHERE NOT EXISTS (\n  SELECT 1 FROM tg_user_sessions WHERE user_id = {{ $json.message.from.id }}\n);\n",
        "options": {},
        "operation": "executeQuery"
      },
      "typeVersion": 2.6
    },
    {
      "id": "7b6b801f-5228-4b22-a9ca-d5190aef5d8a",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -660,
        1020
      ],
      "parameters": {
        "width": 320,
        "height": 220,
        "content": "## just to create table"
      },
      "typeVersion": 1
    },
    {
      "id": "ffb5945c-0faa-478d-a4c0-956f92ba6eca",
      "name": "Select rows from a table",
      "type": "n8n-nodes-base.postgres",
      "position": [
        620,
        580
      ],
      "parameters": {
        "limit": 1,
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tg_user_sessions",
          "cachedResultName": "tg_user_sessions"
        },
        "where": {
          "values": [
            {
              "value": "={{ $('Telegram Trigger').item.json.message.from.id }}",
              "column": "user_id"
            }
          ]
        },
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "options": {},
        "operation": "select"
      },
      "typeVersion": 2.6
    },
    {
      "id": "56fb3d1c-f76e-4c18-bcb8-1e2eb756945b",
      "name": "Execute a SQL query2",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1560,
        1180
      ],
      "parameters": {
        "query": "UPDATE tg_user_sessions\nSET active = FALSE,\n    department = NULL\nWHERE user_id = {{ $('Telegram Trigger').item.json.message.from.id }};\n",
        "options": {},
        "operation": "executeQuery"
      },
      "typeVersion": 2.6
    },
    {
      "id": "92887eea-2a12-4506-82f9-a8df748d4d0e",
      "name": "Send a text message2",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2280,
        1180
      ],
      "parameters": {
        "text": "to continue chat again send /start",
        "chatId": "={{ $('Telegram Trigger').item.json.message.from.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a0008611-10cb-4f0f-ba48-2e6fbf5bb601",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "width": 2680,
        "height": 1740,
        "content": "## main bot"
      },
      "typeVersion": 1
    },
    {
      "id": "10d2f6c6-a1d3-4282-85ee-f7463ccb7e3d",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        620
      ],
      "parameters": {
        "width": 380,
        "height": 260,
        "content": "## working\n\n- listens for messages\n- /start or /end for conversations\n- uses PostgreSQL for user choice of department\n- data stored in pinecone vector store of respective departments\n- pdf files in googledrive (pinecone will be updated when new pdf is added )"
      },
      "typeVersion": 1
    },
    {
      "id": "0dea67af-08b8-4f0e-a748-ce73e226e865",
      "name": "return policy1",
      "type": "n8n-nodes-base.postgres",
      "position": [
        840,
        1000
      ],
      "parameters": {
        "query": "UPDATE tg_user_sessions\nSET active = TRUE,\n    department = 'Return Policy'\nWHERE user_id ={{ $json.result.chat.id }};\n",
        "options": {},
        "operation": "executeQuery"
      },
      "typeVersion": 2.6
    },
    {
      "id": "282e945a-193b-4ea3-a8de-5bec72c4acfd",
      "name": "tech questions",
      "type": "n8n-nodes-base.postgres",
      "position": [
        980,
        1180
      ],
      "parameters": {
        "query": "UPDATE tg_user_sessions\nSET active = TRUE,\n    department = 'Tech Support'\nWHERE user_id ={{ $json.result.chat.id }};\n",
        "options": {},
        "operation": "executeQuery"
      },
      "typeVersion": 2.6
    },
    {
      "id": "862c87ae-abf8-42a7-8f9f-de637f66c4c5",
      "name": "billing1",
      "type": "n8n-nodes-base.postgres",
      "position": [
        980,
        1380
      ],
      "parameters": {
        "query": "UPDATE tg_user_sessions\nSET active = TRUE,\n    department = 'Billing'\nWHERE user_id ={{ $json.result.chat.id }};\n",
        "options": {},
        "operation": "executeQuery"
      },
      "typeVersion": 2.6
    },
    {
      "id": "26744059-ee41-42e5-8acd-83743612ef63",
      "name": "Execute a SQL query3",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1780,
        180
      ],
      "parameters": {
        "query": "UPDATE tg_user_sessions\nSET active = TRUE,\n    department = NULL\nWHERE user_id = {{ $('Telegram Trigger').item.json.message.from.id }};\n",
        "options": {},
        "operation": "executeQuery"
      },
      "typeVersion": 2.6
    },
    {
      "id": "2c8f329a-8c77-420b-b815-d3d75fdf40b5",
      "name": "Send a text message3",
      "type": "n8n-nodes-base.telegram",
      "position": [
        440,
        1500
      ],
      "parameters": {
        "text": "provide correct dpt|for Billing: /billing for Return Policy: /ReturnPolicy for Tech Support: /TechSupport",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    }
  ],
  "connections": {
    "Switch": {
      "main": [
        [
          {
            "node": "return policy",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "talk technical",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "billing",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send a text message3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch1": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send a text message4",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Agent3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Execute a SQL query2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "billing": {
      "main": [
        [
          {
            "node": "billing1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent3": {
      "main": [
        [
          {
            "node": "Send a text message1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download file": {
      "main": [
        [
          {
            "node": "Pinecone Vector Store3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "return policy": {
      "main": [
        [
          {
            "node": "return policy1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download file1": {
      "main": [
        [
          {
            "node": "Pinecone Vector Store4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download file2": {
      "main": [
        [
          {
            "node": "Pinecone Vector Store5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory3": {
      "ai_memory": [
        [
          {
            "node": "AI Agent3",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "talk technical": {
      "main": [
        [
          {
            "node": "tech questions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Execute a SQL query1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Cohere3": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store3",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Cohere4": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store4",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Cohere5": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store5",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Cohere6": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store6",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Cohere7": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store7",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Cohere8": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store8",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Pinecone Vector Store3",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Send a text message": {
      "main": [
        [
          {
            "node": "Execute a SQL query3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader1": {
      "ai_document": [
        [
          {
            "node": "Pinecone Vector Store4",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader2": {
      "ai_document": [
        [
          {
            "node": "Pinecone Vector Store5",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Execute a SQL query1": {
      "main": [
        [
          {
            "node": "Select rows from a table",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute a SQL query2": {
      "main": [
        [
          {
            "node": "Send a text message2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger": {
      "main": [
        [
          {
            "node": "Download file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger1": {
      "main": [
        [
          {
            "node": "Download file1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger2": {
      "main": [
        [
          {
            "node": "Download file2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model3": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent3",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Pinecone Vector Store6": {
      "ai_tool": [
        [
          {
            "node": "AI Agent3",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Pinecone Vector Store7": {
      "ai_tool": [
        [
          {
            "node": "AI Agent3",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Pinecone Vector Store8": {
      "ai_tool": [
        [
          {
            "node": "AI Agent3",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Character Text Splitter1": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader1",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Character Text Splitter2": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader2",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Select rows from a table": {
      "main": [
        [
          {
            "node": "Switch1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

/billing - For payment and invoice questions /tech-support - For technical assistance /return-policy - For returns and refunds Command-based routing Direct department access via slash commands Tracks active conversations in PostgreSQL Pinecone vector stores for each department…

Source: https://n8n.io/workflows/6010/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

A lightweight, self-hosted AI assistant built entirely in n8n. Multi-channel messaging (Telegram, WhatsApp, Gmail), persistent memory, task management, and autonomous work — all in a single visual wor

Telegram Trigger, OpenRouter Chat, Data Table +20
AI & RAG

Your AI workforce is ready. Are you?

Google Sheets Tool, Mcp Trigger, Google Drive +29
AI & RAG

This comprehensive workflow bundle is designed as a powerful starter kit, enabling you to build a multi-functional AI assistant on Telegram. It seamlessly integrates AI-powered voice interactions, an

Telegram Trigger, Telegram, OpenAI +19
AI & RAG

This n8n template automatically classifies incoming emails (Sales, Support, Internal, Finance, Promotions) and routes them to a dedicated OpenAI LLM Agent for processing. Depending on the category, th

OpenAI, Gmail, Text Classifier +16
AI & RAG

Auto repost job with RAG is a workflow designed to automatically extract, process, and publish job listings from monitored sources using Google Drive, OpenAI, Supabase, and WordPress. This integration

Google Drive, Supabase Vector Store, OpenAI Embeddings +12