Library / RAG & Knowledge Bases
RAG & Knowledge Bases
Reply to Facebook comments using RAG with Google Drive, Supabase, OpenAI and Postgres
When an API call/webhook arrives, it answers questions from your own knowledge base with OpenAI / ChatGPT and OpenRouter using Postgres, Supabase, Facebook / Instagram, Google Drive.
What it does
# ENTERPRISE RAG ECOSYSTEM: AI FACEBOOK COMMENT AUTO-REPLY & DRIVE KNOWLEDGE SYNC ## Executive Summary & Architecture Overview This production-grade n8n automation ecosystem bridges the gap between static enterprise documentation (Google Drive) and real-time social media customer engagement (Facebook Pages). By combining a self-updating Retrieval-Augmented Generation (RAG) pipeline with an intelligent AI Agent, Postgres Persistent Memory, and Supabase Vector Store, this system ensures your Facebook Fanpage responds to customer comments instantly, accurately, and with precise context. --- ## Prerequisites & Credentials Setup Before running or publishing this workflow, ensure you have configured the following credentials in your n8n instance: 1. OpenRouter API Account: Required to power the AI Agent LLM model. 2. OpenAI API Account: Required for generating document embeddings (Embeddings OpenAI / Embed the query). 3. Supabase Account & Vector Store Setup: - Create a Supabase project and enable pgvector. - You need to create the vector table named documents. Follow the official guide here: Supabase LangChain AI Integration Guide. 4. PostgreSQL Database Account: - Required for Postgres Chat Memory to isolate conversation history per user per post. 5. Google Drive OAuth2 API: - Required to monitor the watched folders (Google Drive Trigger & file operations). 6. Facebook Graph API Account: - Requires a Page Access Token with permissions: pages_manage_posts, pages_read_engagement, and pages_messaging (or comment management permissions). --- ## Facebook Webhook & n8n Webhook Configuration Guide To receive real-time comments from your Facebook Page, you must set up a Meta App and configure the n8n Webhook node: 1. Configure n8n Webhook: - Refer to the official n8n Webhook Node Documentation for detailed configuration options (such as handling challenge verification methods and routing). 2. Configure Meta for Developers: - Go to Meta for Developers and create/select your app. - Add the Webhooks product and select Page subscription. - Callback URL: Paste your n8n Webhook production URL. - Verify Token: Enter the secret token matching your configuration. - Subscribe to the feed (or comments) field. 3. Once verified, the webhook will automatically handle Meta's initial verification challenge (hub.challenge) and process incoming comment events. --- ## Detailed Breakdown o
The steps
- Webhook
- Respond to Webhook
- AI Agent
- OpenRouter Chat Model
- Extract Comment Data
- Set Challenge Variable
- Filter: Is Comment Event
- Filter: Ignore Page Self-Comments
- Get Post Content
- Send Reply Comment
- End / Ignore Self-Comment
- End / Not a Comment
- New PDF added to Drive folder
- Download the PDF
33 steps in total.
Similar automations
RAG & Knowledge BasesRun a RAG Messenger chatbot with Facebook, Google Drive, Supabase, OpenAI and OpenRouter36 stepsSocial Media PublishingReply to Instagram Comments with Direct Messages12 stepsAI Agents & AssistantsCreate Facebook photo posts from Telegram albums using OpenRouter AI18 stepsSocial Media PublishingDraft Instagram comments from top hashtag posts with OpenAI and Google Sheets12 steps