{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "5496c2ac-9017-47e4-9c7f-666e08008ae2",
      "name": "New File Trigger",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "notes": "Triggers when a new file is created in the specified Google Drive folder",
      "position": [
        480,
        1296
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyX",
              "unit": "minutes",
              "value": 15
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1FHG5g1T1CyctyPwwVsc64E-uIOlMLcTl",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1FHG5g1T1CyctyPwwVsc64E-uIOlMLcTl",
          "cachedResultName": "Qdranttest"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "a70a0164-2aef-419d-b289-9ad150204c41",
      "name": "Download File",
      "type": "n8n-nodes-base.googleDrive",
      "notes": "Downloads the file from Google Drive",
      "position": [
        720,
        1296
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "e34f840a-2282-4f70-8e96-5ed82b4527fd",
      "name": "Move to Processed Folder",
      "type": "n8n-nodes-base.googleDrive",
      "notes": "Moves the processed file to the 'Qdrant Ready' folder",
      "position": [
        1360,
        1296
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Download File').item.json.id }}"
        },
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive",
          "cachedResultUrl": "https://drive.google.com/drive/my-drive",
          "cachedResultName": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "18ULhOgNCVhhbD0hvtCKBVoBGiCYQ8Dfp",
          "cachedResultUrl": "https://drive.google.com/drive/folders/18ULhOgNCVhhbD0hvtCKBVoBGiCYQ8Dfp",
          "cachedResultName": "Qdrant \u0433\u043e\u0442\u043e\u0432\u043e"
        },
        "operation": "move"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "f20a76ba-27f4-4719-8522-5baa43254f26",
      "name": "Load Document Data",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "notes": "Loads binary data from the file for processing",
      "position": [
        976,
        1472
      ],
      "parameters": {
        "options": {},
        "dataType": "binary"
      },
      "typeVersion": 1
    },
    {
      "id": "2c24bf63-4e8a-4364-8206-29e674d794cd",
      "name": "Split Text into Chunks",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "notes": "Splits document text into chunks of 3000 characters with 300 character overlap",
      "position": [
        960,
        1600
      ],
      "parameters": {
        "options": {},
        "chunkSize": 3000,
        "chunkOverlap": 300
      },
      "typeVersion": 1
    },
    {
      "id": "b1b3c4f8-cc1d-4d72-b24f-e41157780bce",
      "name": "Insert into Qdrant",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
      "notes": "Inserts document embeddings into Qdrant vector database",
      "position": [
        1024,
        1296
      ],
      "parameters": {
        "mode": "insert",
        "options": {},
        "qdrantCollection": {
          "__rl": true,
          "mode": "list",
          "value": "Test-youtube-adept-ecom",
          "cachedResultName": "Test-youtube-adept-ecom"
        },
        "embeddingBatchSize": 100
      },
      "credentials": {
        "qdrantApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "6002eaf2-5fe5-40d8-aa98-a218b1b4edd3",
      "name": "Telegram Message Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "notes": "Triggers when a new message is received in Telegram",
      "position": [
        560,
        688
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d790616b-48ae-4942-ac29-c2212b7245e9",
      "name": "Filter Authorized User",
      "type": "n8n-nodes-base.filter",
      "notes": "Filters messages to only allow authorized user (chat ID 26899549)",
      "position": [
        816,
        688
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "9305ec69-4e34-4103-80d8-4f57c4bc52b7",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $json.message.chat.id }}",
              "rightValue": 26899549
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "babb633c-8642-4148-af59-f82aa911b506",
      "name": "OpenAI Embeddings",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "notes": "Generates embeddings for vector storage and retrieval",
      "position": [
        1248,
        1520
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "017367c9-eae7-4b87-9767-545dc16be347",
      "name": "Send Response to Telegram",
      "type": "n8n-nodes-base.telegram",
      "notes": "Sends AI-generated response back to Telegram chat",
      "position": [
        1440,
        688
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "={{ $('Telegram Message Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "46aa9b8d-9e1d-4030-83a5-7c972bc9e206",
      "name": "Qdrant Knowledge Base",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
      "notes": "Retrieves relevant information from Qdrant vector database as a tool for AI agent",
      "position": [
        1248,
        976
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "options": {},
        "toolDescription": "\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u044d\u0442\u0443 \u0431\u0430\u0437\u0443 \u0437\u043d\u0430\u043d\u0438\u0439, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f",
        "qdrantCollection": {
          "__rl": true,
          "mode": "list",
          "value": "Test-youtube-adept-ecom",
          "cachedResultName": "Test-youtube-adept-ecom"
        },
        "includeDocumentMetadata": false
      },
      "credentials": {
        "qdrantApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "0a8ba3f7-46f9-4485-ae39-72336cab4c9a",
      "name": "AI Agent1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "notes": "Processes user messages using AI with access to vector database knowledge base",
      "position": [
        1088,
        688
      ],
      "parameters": {
        "text": "={{ $json.message.text }}",
        "options": {
          "systemMessage": "=You are an expert in business process automation using N8N, specializing in e-commerce and AI integration. \n\nYOUR COMMUNICATION STYLE:\n\n1. Tone and mood:\n- Friendly and energetic, but professional\n   - You sound like an experienced practitioner, not a theorist.\n   - Sharing personal experiences and real-life cases\n- Inspiring and motivating the audience to act\n\n2. Visual design:\n- You actively use emojis for visual accents (\ud83d\ude80 \u26a1\ufe0f \u2728 \ud83d\udca1 \ud83d\udd25 \ud83d\udc4b)\n- You use emojis logically: at the beginning, to attract attention, to mark lists, for emotional accents\n- The average number of emojis: 6-10 per post\n\n3. Content structure:\n- You start with a bright headline or a hook that attracts attention\n   - Use short paragraphs (2-4 sentences)\n- Use structured lists with emoji markers (\u2728, \ud83c\udfaf, \ud83d\udccc)\n- Highlight key thoughts in bold or capital letters\n- End with a call to action or a question for engagement\n\n4. Language and presentation:\n   - Explain complex technical concepts in simple, understandable language\n- Avoid unnecessary jargon, but use professional terminology where necessary\n   - You give specific examples and figures (not abstractions)\n- You use metaphors and analogies to explain complex things\n\n5. Content and Value:\n   - You always provide practical benefits: you teach, share insights, and offer solutions\n   - You focus on real problems and their solutions\n- You show \"how\" (step-by-step instructions), not just \"what\"\n- You honestly talk about the pitfalls and nuances\n\n6. Audience engagement:\n- Asking thought-provoking questions\n   - Use calls to action (CTA)\n- Encourage discussion in the comments\n   - You create interactivity (voting, challenges, conditions for bonuses)\n\n7. Text formatting:\n- Use bold highlighting for section headings\n   - You use bulleted lists for transfers\n   - Add empty lines between semantic blocks\n- Group related information\n   \n   IMPORTANT for Telegram:\n- DO NOT use quotation marks around quotes - they look ugly\n   - Put quotes in italics or just a new line with indentation.\n   - Avoid long blocks of text in quotation marks\n   - Instead of \"(c) Source\" use \"\u2014 Source\" at the end of the quote\n\nYOUR MAIN TOPICS:\n- n8n and business process automation\n- Integration of AI and neural networks into workflow\n- E-commerce and marketing\n- Practical cases and workflow\n- Training materials and tutorials\n- News and updates in the automation world\n- Personal experience and insights\n\nEXAMPLES OF TYPICAL ELEMENTS OF YOUR POSTS:\n- \"Friends, hello everyone! \ud83d\udc4b\"\n- \"What awaits you in the video:\"\n- \"I think it's important!\"\n- \"I'll be glad to hear your comments!\"\n- \"If this post gets X likes, then...\"\n- \"Useful links:\"\n- Hashtags at the end of posts\n\nUSING THE QDRANT VECTOR STORE:\n- You have access to the Qdrant Vector Store tool\n- ALWAYS use it before generating content to search for relevant information.\n- First formulate a search query based on the topic of the post\n- Search the vector database for similar posts, cases, and examples\n- Use the information you find to enrich your answer.\n- If there is relevant data in the database, be sure to use it in the post.\n- It helps to maintain consistency of style and use proven formulations.\n\nThe algorithm of operation:\n1. You receive a request from the user\n2. You create a search query for Qdrant (keywords of the topic)\n3. Looking for relevant posts/materials in the vector database\n4. Analyze the results you found\n5. You generate a post using information from the database + your knowledge\n6. You give the final result\n\nimportant:\n- You don't just share information, you build a community.\n- Your goal is to help people solve real problems through automation\n- You show that complex things can be explained simply.\n- You inspire people to experiment and create their own solutions.\n- Vector knowledge base is your reliable assistant for generating high-quality content"
        },
        "promptType": "define"
      },
      "typeVersion": 3
    },
    {
      "id": "d4d61680-f231-4a58-9bab-ff3831b75595",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "notes": "Fine-tuned GPT-4.1 model for generating content",
      "position": [
        1056,
        976
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "ft:gpt-4.1-2025-04-14:aimagine:adept3:CrV9Ir4p",
          "cachedResultName": "ft:gpt-4.1-2025-04-14:aimagine:adept3:CrV9Ir4p"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "140df8cd-b802-4687-b07d-21ce4fa52ebf",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -48,
        480
      ],
      "parameters": {
        "width": 448,
        "height": 896,
        "content": "# How it works\n\nThis workflow creates an intelligent Telegram bot with a knowledge base powered by Qdrant vector database. It has two independent flows:\n\n**Document Processing Flow** automatically monitors a Google Drive folder, downloads new files, splits them into chunks, generates embeddings, and stores them in Qdrant. Processed files are moved to a \"Ready\" folder.\n\n**Telegram Chat Flow** receives messages, filters authorized users, and uses an AI Agent with access to the vector database to answer questions. The bot maintains conversation history per chat and uses a fine-tuned GPT-4.1 model.\n\n# Setup steps\n\n1. **Google Drive:** Add OAuth2 credentials to all Google Drive nodes. Create two folders (incoming/processed) and update folder IDs.\n2. **Qdrant:** Add API credentials and create a collection. Update collection name in both Qdrant nodes.\n3. **OpenAI:** Add API credentials. Optionally replace the fine-tuned model with standard GPT-4.\n4. **Telegram:** Create a bot via @BotFather, add credentials, and update the authorized chat ID in the filter node.\n5. Activate the workflow and test by uploading a file and sending a Telegram message.\n\n# Customization\n\nModify the system prompt in the AI Agent node to customize your bot's personality and expertise domain."
      },
      "typeVersion": 1
    },
    {
      "id": "cbc312cc-e573-4cea-bdbb-370a4269d793",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        1168
      ],
      "parameters": {
        "color": 7,
        "width": 1152,
        "height": 640,
        "content": "## Document Processing Flow\n\nMonitors Google Drive \u2192 Downloads files \u2192 Splits text \u2192 Creates embeddings \u2192 Stores in Qdrant \u2192 Moves to processed folder"
      },
      "typeVersion": 1
    },
    {
      "id": "d8d03518-dac3-49f1-942f-902b52a50533",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        480
      ],
      "parameters": {
        "color": 7,
        "width": 1152,
        "height": 384,
        "content": "## Telegram Chat Flow\n\nReceives messages \u2192 Filters authorized users \u2192 AI Agent with vector search \u2192 Generates response \u2192 Sends to Telegram"
      },
      "typeVersion": 1
    },
    {
      "id": "442eec9e-55f6-4d7a-ab11-0c58cf1a3115",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        880
      ],
      "parameters": {
        "color": 7,
        "width": 1152,
        "height": 272,
        "content": "## AI Components\n\nFine-tuned GPT-4.1 model, conversation memory per chat, OpenAI embeddings, and Qdrant knowledge base retrieval tool"
      },
      "typeVersion": 1
    },
    {
      "id": "f994cbde-baf0-44ea-bdad-3dc7541d62ac",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        720,
        608
      ],
      "parameters": {
        "color": 3,
        "width": 288,
        "height": 256,
        "content": "\u26a0\ufe0f Update this chat ID to your own Telegram user ID to authorize yourself. Find your ID by messaging @userinfobot"
      },
      "typeVersion": 1
    },
    {
      "id": "920b4a69-8d22-41c2-927d-3f0fd0768bb6",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1232,
        272
      ],
      "parameters": {
        "width": 352,
        "height": 208,
        "content": "@[youtube](7oDXXBYKKps)"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "AI Agent1": {
      "main": [
        [
          {
            "node": "Send Response to Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File": {
      "main": [
        [
          {
            "node": "Insert into Qdrant",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "New File Trigger": {
      "main": [
        [
          {
            "node": "Download File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Embeddings": {
      "ai_embedding": [
        [
          {
            "node": "Insert into Qdrant",
            "type": "ai_embedding",
            "index": 0
          },
          {
            "node": "Qdrant Knowledge Base",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Insert into Qdrant": {
      "main": [
        [
          {
            "node": "Move to Processed Folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Load Document Data": {
      "ai_document": [
        [
          {
            "node": "Insert into Qdrant",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Qdrant Knowledge Base": {
      "ai_tool": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Filter Authorized User": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Text into Chunks": {
      "ai_textSplitter": [
        [
          {
            "node": "Load Document Data",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Message Trigger": {
      "main": [
        [
          {
            "node": "Filter Authorized User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}