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.