GenAiHub

Last checked 8 October 2026 — responded normally.

Run a RAG Messenger chatbot with Facebook, Google Drive, Supabase, OpenAI and OpenRouter

Quick overview

Live
Open / InstallLast updated October 8, 2026

Description

Quick overview This workflow powers a Facebook Messenger chatbot that batches incoming user messages, answers with an OpenRouter chat model using RAG retrieval from a Supabase vector store, and keeps the knowledge base synced from PDFs in Google Drive (add, update, and delete). How it works Receives Facebook Messenger webhook requests (including the initial webhook verification challenge) and ignores messages sent by the page itself. Extracts the sender, page, and message text, then stores each incoming message in an n8n Data Table keyed by the sender ID. Re-checks the sender’s pending messages until the latest message is at least 10 seconds old, then combines all pending messages into a single prompt. Sends the combined prompt to an AI agent backed by an OpenRouter chat model, using Supabase Vector Store retrieval as a tool and Postgres chat memory for conversation context. Posts the agent’s response back to the user through the Facebook Graph API. Triggers on new PDFs in a specified Google Drive folder, downloads and extracts text, chunks the content, generates OpenAI embeddings, and inserts the vectors into a Supabase documents table. Triggers on updated PDFs in a specified Google Drive folder, deletes existing vectors matching the file name, then re-downloads, re-extracts, re-chunks, re-embeds, and re-indexes the updated content in Supabase. Triggers when a file appears in a Google Drive Trash folder, deletes matching vectors from Supabase, and then deletes the file from Google Drive. Setup Create a Facebook Page and Meta app, configure the Messenger webhook to point to this workflow’s webhook URL, and add Facebook Graph API credentials with permission to send messages. Connect Google Drive OAuth and set the correct folder IDs for the “new file”, “updated file”, and “trash” triggers. Set up Supabase (with pgvector) and a documents table, then add Supabase API credentials used for vector upserts and deletes. Add an OpenAI API key for embeddings and an OpenRouter API key for the chat model used by the AI agent. Provide a Postgres database for chat memory and ensure the n8n Data Table named conversations exists for temporary message batching storage. An n8n automation workflow template by MADIAD.

Community Metrics

Views
0
Avg Rating
N/A
Ratings
0
Likes
0
Comments
—

Author

MADIAD

Platform

web

Pricing model

free

Categories

  • Automation
  • AI

Tags

  • n8n
  • workflow
  • google-drive
  • facebook-graph-api
  • supabase
  • code
  • ai-agent
  • embeddings-openai
  • supabase-vector-store
  • default-data-loader

Capabilities

  • 10 nodes

Information

TypeWorkflow
Sourcen8n
AddedOctober 6, 2026

Comments

?

Others in the same category, ranked by how often they are opened.