Answer HR and IT policy questions on Telegram with OpenAI and Postgres PGVector

Go to Workflow
0 views
Built by Redowan Ahmed Farhan Redowan Ahmed Farhan
Created on July 28, 2026

Description

Quick overview
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.

How it works
Manually runs once to download an HR policy PDF over HTTP and extract its text.
Splits the extracted policy text into chunks, generates OpenAI embeddings, and inserts the vectors into a Postgres PGVector store.
Triggers on new Telegram messages sent to your bot.
Routes incoming Telegram updates by type, sending text directly to the assistant, transcribing voice messages with OpenAI, or replying that other formats are unsupported.
Uses an OpenAI chat model with Postgres-backed chat memory and a PGVector retrieval tool to answer questions grounded in the stored policy content.
Sends the final answer back to the user in Telegram.

Setup
Add an OpenAI API key for embeddings, chat completions, and audio transcription.
Set up a Postgres database with the PGVector extension enabled and add the Postgres credentials for both the vector store and chat memory.
Create a Telegram bot with BotFather, add the bot token credentials, and enable the Telegram Trigger so it can receive updates.
Replace the PDF URL with your own policy/handbook document and run the manual ingestion once to populate the vector store before using the bot.

Nodes Used (11)

AI Agent
@n8n/n8n-nodes-langchain.agent
Default Data Loader
@n8n/n8n-nodes-langchain.documentDefaultDataLoader
Embeddings OpenAI
@n8n/n8n-nodes-langchain.embeddingsOpenAi
HTTP Request
n8n-nodes-base.httpRequest
OpenAI
@n8n/n8n-nodes-langchain.openAi
OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi
Postgres Chat Memory
@n8n/n8n-nodes-langchain.memoryPostgresChat
Postgres PGVector Store
@n8n/n8n-nodes-langchain.vectorStorePGVector
Recursive Character Text Splitter
@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter
Telegram
n8n-nodes-base.telegram
Vector Store Question Answer Tool
@n8n/n8n-nodes-langchain.toolVectorStore