AutomationFlowsAI & RAG › Answer Hr and It Policy Questions on Telegram with Openai and Postgres Pgvector

Answer Hr and It Policy Questions on Telegram with Openai and Postgres Pgvector

ByRedowan Ahmed Farhan @redowanfarhan on n8n.io

This workflow builds a searchable HR policy knowledge base from a PDF and runs a Telegram helpdesk bot that answers employee questions from that content, handling both text messages and voice notes via OpenAI transcription and retrieval from a Postgres PGVector vector store.…

Event trigger★★★★☆ complexityAI-powered26 nodesHTTP RequestVector Store PgvectorOpenAI EmbeddingsDocument Default Data LoaderText Splitter Recursive Character Text SplitterTelegram TriggerOpenAITelegram
AI & RAG Trigger: Event Nodes: 26 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #16706 — 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
{
  "id": "eZ0ezrp3Vf0EDjgM",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "HR & IT Helpdesk Chatbot with Audio Transcription",
  "tags": [],
  "nodes": [
    {
      "id": "f16052bb-04f7-418f-b6e6-629a4244448f",
      "name": "When clicking \u2018Test workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        144,
        -240
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "8019bfbe-38c0-4366-91d6-a25b860b08ca",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        320,
        -240
      ],
      "parameters": {
        "url": "https://s3.amazonaws.com/scschoolfiles/656/employee_handbook_print_1.pdf",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "75a14f13-9efa-41f8-87a2-215007e8ede1",
      "name": "Extract from File",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        496,
        -240
      ],
      "parameters": {
        "options": {},
        "operation": "pdf"
      },
      "typeVersion": 1
    },
    {
      "id": "f2c59a99-eefe-415f-8eb4-b0f81775a386",
      "name": "Create HR Policies",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePGVector",
      "position": [
        832,
        -160
      ],
      "parameters": {
        "mode": "insert",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "239bf34f-ceb1-4ed8-9cd3-dd4d2d64fad8",
      "name": "Embeddings OpenAI",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        816,
        64
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "d03a1d74-67c8-4f32-bc99-bc4127989b49",
      "name": "Default Data Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        976,
        80
      ],
      "parameters": {
        "options": {},
        "jsonData": "={{ $('Extract from File').item.json.text }}",
        "jsonMode": "expressionData"
      },
      "typeVersion": 1
    },
    {
      "id": "c4963eec-c02b-40b3-a2c4-0c10779bca89",
      "name": "Recursive Character Text Splitter",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        1072,
        304
      ],
      "parameters": {
        "options": {},
        "chunkSize": 2000
      },
      "typeVersion": 1
    },
    {
      "id": "0195b6d9-3f06-4e41-99ef-a45f88e59381",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        1456,
        -16
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "02b9e164-82df-4194-aa7f-707ee730adcc",
      "name": "Verify Message Type",
      "type": "n8n-nodes-base.switch",
      "position": [
        1664,
        -16
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Text",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "array",
                      "operation": "contains",
                      "rightType": "any"
                    },
                    "leftValue": "={{ $json.message.keys()}}",
                    "rightValue": "text"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Audio",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "d16eb899-cccb-41b6-921e-172c525ff92c",
                    "operator": {
                      "type": "array",
                      "operation": "contains",
                      "rightType": "any"
                    },
                    "leftValue": "={{ $json.message.keys()}}",
                    "rightValue": "voice"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "typeVersion": 3.2,
      "alwaysOutputData": false
    },
    {
      "id": "91dfe2c0-3fc4-4323-85b3-49748ef97e7b",
      "name": "OpenAI",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        2384,
        128
      ],
      "parameters": {
        "options": {},
        "resource": "audio",
        "operation": "transcribe",
        "binaryPropertyName": "=data"
      },
      "typeVersion": 1.8
    },
    {
      "id": "83de159d-c9c6-4ff4-941d-f1afa632af05",
      "name": "Telegram1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2160,
        128
      ],
      "parameters": {
        "fileId": "={{ $json.message.voice.file_id }}",
        "resource": "file",
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "8b7672e0-cc05-495d-9d79-628f131600f0",
      "name": "Unsupported Message Type",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2240,
        304
      ],
      "parameters": {
        "text": "I'm not able to process this message type.",
        "chatId": "={{ $json.message.chat.id }}",
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "5737b33b-1e0d-494f-896d-dc9948c7c40d",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2896,
        80
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "options": {
          "systemMessage": "You are a helpful assistant for HR and employee policies"
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "facc12f9-d8ed-4734-abac-10d92324b835",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2832,
        480
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "d1480d43-0582-45ba-b71a-4658c3fbdc09",
      "name": "Postgres Chat Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "position": [
        3088,
        480
      ],
      "parameters": {
        "sessionKey": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "fb2b51ea-c5e6-4ee6-833f-abef74f6abea",
      "name": "Answer questions with a vector store",
      "type": "@n8n/n8n-nodes-langchain.toolVectorStore",
      "position": [
        3392,
        208
      ],
      "parameters": {
        "name": "hr_employee_policies",
        "description": "data for HR and employee policies"
      },
      "typeVersion": 1
    },
    {
      "id": "cde2a74a-cd1f-4104-a055-3c6534d8f738",
      "name": "Postgres PGVector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePGVector",
      "position": [
        3248,
        416
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "b5404eaa-3e7a-4592-b459-c506911b51a3",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        3664,
        416
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "9268e604-3c47-4bf7-86f2-6a12bf95cce5",
      "name": "Embeddings OpenAI1",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        3328,
        560
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "6dd5386a-9950-47b4-823f-925d4882c1ce",
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        4032,
        240
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "={{ $('Telegram Trigger').first().json.message.chat.id }}",
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "8b792a6c-5017-43d5-adb8-fbcfefaed64c",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        2160,
        -64
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "403b336f-87ce-4bef-a5f2-1640425f8198",
              "name": "text",
              "type": "string",
              "value": "={{ $json.message.text }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "0c130eb5-d5b8-4fae-a692-78260599bab6",
      "name": "Main Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -576,
        -256
      ],
      "parameters": {
        "color": 7,
        "width": 560,
        "height": 1484,
        "content": "## \ud83e\udd16 HR & IT Helpdesk Chatbot with Audio Transcription\n\nA Telegram chatbot that answers employee HR and IT questions from your company policy documents, accepting both typed text and voice messages. Voice notes are transcribed automatically before answering, and a Postgres vector store grounds every reply in real policy content.\n\n**Perfect for:** HR and IT support teams who want to deflect repetitive policy questions through a self-serve Telegram bot.\n\n---\n\n## How it works\n\n1. **When clicking 'Test workflow'** \u2014 Manually triggers the one-time knowledge base build.\n2. **HTTP Request** \u2014 Downloads the source policy document.\n3. **Extract from File** \u2014 Extracts raw text from the downloaded file.\n4. **Create HR Policies** \u2014 Inserts the policy text into the Postgres PGVector store.\n5. **Embeddings OpenAI** \u2014 Generates the vectors used when storing policy chunks.\n6. **Default Data Loader** \u2014 Loads the extracted document for embedding.\n7. **Recursive Character Text Splitter** \u2014 Splits the document into overlapping chunks.\n8. **Telegram Trigger** \u2014 Listens for incoming employee messages.\n9. **Verify Message Type** \u2014 Routes each message into text, voice, or unsupported.\n10. **Edit Fields** \u2014 Passes a text message straight to the agent. *(text path)*\n11. **Telegram1** \u2014 Downloads the voice file from Telegram. *(voice path)*\n12. **OpenAI** \u2014 Transcribes the voice note into text. *(voice path)*\n13. **Unsupported Message Type** \u2014 Replies that the format is not supported. *(fallback path)*\n14. **AI Agent** \u2014 Generates the answer using the chat model, memory, and vector tool.\n15. **OpenAI Chat Model** \u2014 The LLM powering the agent.\n16. **Postgres Chat Memory** \u2014 Stores conversation history per user.\n17. **Answer questions with a vector store** \u2014 Retrieval tool the agent calls for policy lookups.\n18. **Postgres PGVector Store** \u2014 The vector database queried at answer time.\n19. **OpenAI Chat Model1** \u2014 Summarizes retrieved chunks inside the vector tool.\n20. **Embeddings OpenAI1** \u2014 Embeds the user query for retrieval.\n21. **Telegram** \u2014 Sends the final answer back to the employee.\n\n---\n\n## Setup (~15 minutes)\n\n1. **OpenAI API** \u2014 Add your key in *Embeddings OpenAI*, *OpenAI*, *OpenAI Chat Model*, *OpenAI Chat Model1*, and *Embeddings OpenAI1*.\n2. **Postgres / PGVector** \u2014 Add database credentials in *Create HR Policies*, *Postgres PGVector Store*, and *Postgres Chat Memory*.\n3. **Telegram** \u2014 Add your bot token in *Telegram Trigger*, *Telegram1*, *Telegram*, and *Unsupported Message Type*.\n4. **Policy source** \u2014 Set the document URL in *HTTP Request*, then run the manual trigger once to build the knowledge base.\n> Run the ingestion path before going live, or the bot has no policies to answer from. Voice transcription uses OpenAI Whisper and incurs per-minute API cost."
      },
      "typeVersion": 1
    },
    {
      "id": "73128558-42c6-4769-b85e-55ca4334b790",
      "name": "Section: Knowledge Base Ingestion",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32,
        -416
      ],
      "parameters": {
        "color": 5,
        "width": 1300,
        "height": 916,
        "content": "## 1\ufe0f\u20e3 Knowledge Base Ingestion\n\nTriggered manually, the **HTTP Request** node downloads your policy document and **Extract from File** pulls out its text. **Create HR Policies** then writes that content into a Postgres vector store, using **Embeddings OpenAI** to vectorize the chunks produced by the **Recursive Character Text Splitter** and **Default Data Loader**. Run this once to build the searchable knowledge base."
      },
      "typeVersion": 1
    },
    {
      "id": "364c1be8-5eeb-47f0-ace2-fa35b40c71b4",
      "name": "Section: Telegram Intake & Transcription",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1360,
        -224
      ],
      "parameters": {
        "color": 3,
        "width": 1312,
        "height": 720,
        "content": "## 2\ufe0f\u20e3 Telegram Intake & Transcription\n\nThe **Telegram Trigger** receives every incoming message and **Verify Message Type** routes it down one of three paths. Text messages flow through **Edit Fields**, voice notes are downloaded by **Telegram1** and transcribed to text by **OpenAI** (Whisper), and anything else is rejected by **Unsupported Message Type**."
      },
      "typeVersion": 1
    },
    {
      "id": "d4287903-1942-4601-b9c9-7e8394d6ccf5",
      "name": "Section: AI Agent & RAG Retrieval",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2704,
        -208
      ],
      "parameters": {
        "color": 6,
        "width": 1200,
        "height": 928,
        "content": "## 3\ufe0f\u20e3 AI Agent & RAG Retrieval\n\nThe **AI Agent** answers each question using the **OpenAI Chat Model** and remembers context through **Postgres Chat Memory**. When a policy lookup is needed it calls **Answer questions with a vector store**, which queries the **Postgres PGVector Store** via **Embeddings OpenAI1** and **OpenAI Chat Model1** to ground the reply in real policy text."
      },
      "typeVersion": 1
    },
    {
      "id": "d53d9cd4-061b-49ab-ad0e-05a153be73b9",
      "name": "Section: Reply to User",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3936,
        80
      ],
      "parameters": {
        "color": 4,
        "width": 360,
        "height": 360,
        "content": "## 4\ufe0f\u20e3 Reply to User\n\nThe final **Telegram** node sends the agent's completed answer back to the employee in the same chat."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "57d2b4e4-c0ef-42ff-8aab-247f092a11ee",
  "nodeGroups": [],
  "connections": {
    "OpenAI": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram1": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Verify Message Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Create HR Policies",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Create HR Policies",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI1": {
      "ai_embedding": [
        [
          {
            "node": "Postgres PGVector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Answer questions with a vector store",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Create HR Policies",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Verify Message Type": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Telegram1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Unsupported Message Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Postgres PGVector Store": {
      "ai_vectorStore": [
        [
          {
            "node": "Answer questions with a vector store",
            "type": "ai_vectorStore",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Test workflow\u2019": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Answer questions with a vector store": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}
Pro

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

About this workflow

This workflow builds a searchable HR policy knowledge base from a PDF and runs a Telegram helpdesk bot that answers employee questions from that content, handling both text messages and voice notes via OpenAI transcription and retrieval from a Postgres PGVector vector store.…

Source: https://n8n.io/workflows/16706/ — 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

This workflow implements an advanced AI automation agent (OpenClaw Agent) that interacts with users through Telegram and integrates multiple AI models, external tools, and cloud services to automate c

Telegram Trigger, Telegram, OpenAI +21
AI & RAG

Alfred (funcional). Uses gmailTool, googleCalendarTool, gmail, embeddingsOpenAi. Event-driven trigger; 83 nodes.

Gmail Tool, Google Calendar Tool, Gmail +24
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