RAG Chatbot with Supabase and TogetherAI
Ingests Google Docs into a vector database via Together AI and answers Telegram questions using only that retrieved context.
What it does
Get instant answers to your questions via Telegram by asking about content stored in your Google Docs. The agent pulls only the relevant information from those documents to provide accurate responses without needing external knowledge.
Step by step
- Configure the Google Docs trigger to fire on document updates and pass the raw text payload to the next step.
- Implement a fixed-size chunking algorithm with an overlap parameter to split document text into manageable segments.
- Send each text chunk to Together AI's embedding endpoint using an HTTP request with your API key in the header.
- Insert the resulting vectors and metadata into Supabase using the pgvector extension for vector storage.
Where the LLM does the work
- Generate a system prompt that strictly instructs the OpenRouter model to answer only using the provided context snippets.
- Craft the user message template that combines the retrieved context with the original Telegram query for coherent responses.
- Refine the chunking strategy if initial results show fragmented answers by adjusting overlap or chunk size dynamically.
Watch out for
Supabase vector search performance degrades without a proper index, so add an IVFFlat or HNSW index on the embedding column.
Google Docs API may return rich text HTML instead of plain text, so strip all HTML tags before chunking to avoid noise in embeddings.
Context window overflow occurs if too many chunks are retrieved, implement a relevance score threshold to filter out weak matches.
Tools that fit
OpenRouter Chat Model LLM LLM inference to generate answers from context
The agent brief
Everything your agent needs, including the gotchas. Copy it and go.
You are helping me build the following AI agent workflow. ## Goal RAG Chatbot with Supabase and TogetherAI: Ingests Google Docs into a vector database via Together AI and answers Telegram questions using only that retrieved context. ## Specification - What it does: Get instant answers to your questions via Telegram by asking about content stored in your Google Docs. The agent pulls only the relevant information from those documents to provide accurate responses without needing external knowledge. - Trigger: Triggered by an event (Event · on new Telegram message) - Autonomy: Fully hands-off - Expected setup effort: a few focused days - Tools/services involved: - Telegram: User interaction trigger and response delivery - Google Docs: Source document retrieval for training data - Supabase: Storing text chunks and vector embeddings - Together AI: Generating vector embeddings for text - OpenRouter Chat Model: LLM inference to generate answers from context ## Known pitfalls, handle each one explicitly in your implementation 1. Supabase vector search performance degrades without a proper index, so add an IVFFlat or HNSW index on the embedding column. 2. Google Docs API may return rich text HTML instead of plain text, so strip all HTML tags before chunking to avoid noise in embeddings. 3. Context window overflow occurs if too many chunks are retrieved, implement a relevance score threshold to filter out weak matches. ## Reference implementation https://n8n.io/workflows/5680 (workflow template) Fetch and inspect this before building. If it matches my stack, adapt it; if not, rebuild the pattern with my tools. ## Process requirements 1. Before building: ask me which of the listed tools I actually use and what my platform is (n8n / Make / code / other). Do not assume. 2. Adapt the pattern to my answers; do not force the reference stack. 3. Address every pitfall above; tell me how you handled each. 4. Provide a test plan I can run before letting this touch real data. 5. Ask before any step that sends messages, modifies data, or spends money. Source: https://usecasesforagents.com/use-case/rag-chatbot-with-supabase-and-togetherai/ via usecasesforagents.com
Frequently asked questions
Can I use a different Messaging than Telegram?
Yes. Telegram is only the example messaging in this recipe. The same flow works with ClickSend API, Discord, Google Chat and LINE Messaging API. Swap the messaging connection and keep the rest of the setup as written.
Want this running in your business?
This is what I do. I design and build AI agents like this one, and keep them running. If you want it set up for your team instead of doing it yourself, get in touch.
Who it's for
Built for developers who want the busywork around code automated, not the code itself.
Works just as well for personal use, no business context needed.