Library / RAG & Knowledge Bases
RAG & Knowledge Bases
Run a RAG Messenger chatbot with Facebook, Google Drive, Supabase, OpenAI and OpenRouter
When something happens in a connected app, it answers questions from your own knowledge base with OpenAI / ChatGPT and OpenRouter using Postgres, Supabase, Data Table, Facebook / Instagram.
What it does
# Facebook Messenger RAG Chatbot with Message Batching ## Self-Updating Knowledge Base with Google Drive ## Who's it for Teams and solo builders who want to build a Facebook Messenger AI chatbot that can answer questions using their own documents. The workflow combines a RAG knowledge base with message batching, allowing the chatbot to handle users who send multiple messages in quick succession before generating a response. Google Drive is used as the document source, while Supabase stores the vectorized knowledge used by the AI Agent. ## How it works The workflow is organized into four parts: ### Part 1 — Messenger Chat with Message Batching This is the main chatbot flow. * Receives incoming messages from Facebook Messenger. * Temporarily stores incoming messages. * Waits until the user stops sending messages. * Combines consecutive messages into a single prompt. * Sends the combined prompt to the AI RAG Agent. * Searches the knowledge base for relevant information. * Maintains conversation context through chat memory. * Sends the generated response back through the Facebook Graph API. For example, if a user sends: text What is the registration process? What documents do I need? And how long does it take? Instead of processing each message separately, the workflow waits for the user to stop sending messages and combines them into one request. This helps reduce unnecessary AI requests and gives the AI Agent the complete context of what the user is asking. ### Part 2 — Ingest New Files This part supports the RAG knowledge base. When a new file is added to the configured Google Drive folder, the workflow: 1. Downloads the file. 2. Extracts the document text. 3. Splits the content into chunks. 4. Generates embeddings. 5. Stores the vectors in Supabase. This allows newly added documents to become available to the chatbot without manually updating the vector database. ### Part 3 — Update Existing Files This part keeps the RAG knowledge base synchronized when a document is modified. When an existing file is updated, the workflow: 1. Removes the previous vectors associated with the file. 2. Downloads the updated version. 3. Extracts and chunks the new content. 4. Generates new embeddings. 5. Re-indexes the updated content in Supabase. The chatbot can therefore retrieve information from the latest version of the document. ### Part 4 — Delete Files This part keeps th
The steps
- New PDF added to Drive folder
- Download the PDF
- Extract text from PDF
- Index into vector database
- PDF updated in Drive folder
- Remove outdated vectors
- Download updated PDF
- Extract text from updated PDF
- Tag with file ID and name 01
- Tag with file ID and name 02
- Split into document chunks 02
- Split into document chunks 01
- Embeddings OpenAI 01
- Embeddings OpenAI 02
36 steps in total.
Similar automations
RAG & Knowledge BasesReply to Facebook comments using RAG with Google Drive, Supabase, OpenAI and Postgres33 stepsAI Agents & AssistantsSell clothing on Facebook Messenger with Gemini, Stripe, and an admin app306 stepsSocial Media PublishingReceive and send WhatsApp, Instagram and Messenger messages through Fiwano4 stepsRAG & Knowledge BasesSync a Telegram RAG chatbot with Google Drive using OpenAI and Supabase25 steps