💬 Reply to Facebook comments with OpenRouter, Supabase, Postgres and Google Drive
⚡ 50 views · 💬 Support Chatbots
💡 Pro Tip — If you’ve run into Facebook’s Graph API permission restrictions, ScraperNode is a community node that scrapes pages, groups, posts, and comments directly — no app review needed.
Description
Quick overview
This workflow auto-replies to Facebook Page comments using an OpenRouter-powered AI Agent with Postgres chat memory and a Supabase vector knowledge base, while keeping that knowledge base synced from PDFs in Google Drive (new, updated, and deleted files).
How it works
- Receives Meta webhook requests and returns the
hub.challengevalue to complete Facebook webhook verification when required. - Extracts the incoming Facebook comment details, ignores non-comment events, and skips comments authored by the Page itself to prevent reply loops.
- Fetches the original Facebook post message via the Facebook Graph API to provide context for the reply.
- Uses an AI Agent backed by an OpenRouter chat model, Postgres chat memory (per post and user), and a Supabase vector-store retrieval tool to draft a concise response.
- Posts the AI-generated text back to Facebook as a reply to the specific comment via the Facebook Graph API.
- Monitors Google Drive folders for PDF creations, updates, and “trash” events, then extracts text, generates OpenAI embeddings, and inserts or deletes matching vectors in Supabase to keep the knowledge base in sync.
Setup
- Create and connect Facebook Graph API credentials, subscribe your Facebook App/Page to the webhook, and configure Meta to call this workflow’s webhook URL.
- Add an OpenRouter API credential and select the model you want the AI Agent to use.
- Add Postgres credentials and ensure the database is reachable for storing chat history sessions.
- Add Supabase credentials, create a
documentstable for vector storage, and ensure the vector store configuration matches your embeddings. - Add Google Drive OAuth credentials and update the folder IDs to the Drive folders you want to watch for new PDFs, updated PDFs, and trashed files.
🔗 Nodes Used
Webhook, Google Drive, Facebook Graph API, Google Drive Trigger, Supabase, AI Agent
📥 Import
Download workflow.json and import into n8n:
Workflow menu → Import from File