This n8n workflow turns your Telegram bot into a smart, multi-modal AI assistant that accepts text , documents , images , and audio messages, interprets them using OpenAI models, and responds instantly with context-aware answers.
It integrates a Supabase vector database to store document embeddings and retrieve relevant information before sending a prompt to OpenAI — enabling a full RAG experience
Most support bots can only handle basic text input. This workflow:
Run the “Add to Supabase Vector DB” workflow manually to upload a document from your google drive and embed it into your vector database. This powers the Telegram chatbot’s ability to answer questions using your content.
Telegram Trigger captures the user message (Text, Image, Voice, Document)
Message Router routes input by type using a Switch node
Each type is handled separately:
Voice → Translate recording to text (.ogg, .mp3)
Image → Analyze image to text.
Text → Sent directly to AI Agent (.txt).
Document → Parsed (e.g. .docx to .txt) accordingly.
Before routing documents by type, the Supported Document File Types node first checks if the file extension is allowed. If not supported, it exits early with an error message — preventing unnecessary processing.
Supported documents are then routed using the Document Router node, and converted to text for further processing.
.jpg .jpeg .png .webp .pdf .doc .docx .xls .xlsx .json .xml.
Uploaded documents are vectorized using OpenAI Embeddings. Embeddings are stored in Supabase with metadata. On new questions, the chatbot:
* Extracts question intent
* Queries Supabase for semantically similar chunks
* Ranks retrieved chunks to find the most relevant match.
* Injects them into the prompt for OpenAI.
* OpenAI generates a grounded response based on actual document content.
5. Response is sent to the Telegram user with content awareness.
.json workflow file.
![Build a Customer Support Agent with Grok-4, Google Docs, and Telegram [RAG]](/_next/image?url=%2Fimages%2Fworkflows%2Fworkflow-default.png&w=3840&q=75)
