RAG AI Agent for Documents in Google Drive → Pinecone → OpenAI Chat (n8n workflow)
This n8n workflow implements a Retrieval-Augmented Generation (RAG) pipeline + AI agent, allowing users to drop documents into a Google Drive folder and then ask questions about them via a chatbot. New files are indexed automatically to a Pinecone vector store using OpenAI embeddings; the AI agent loads relevant chunks at query time and answers using context plus memory.
Service | Purpose in Workflow | Setup Link | What you need / steps |
---|---|---|---|
Google Drive (OAuth2) | Trigger new file events & download the file | https://docs.n8n.io/integrations/builtin/credentials/google/oauth-generic/ | Create a Google Cloud OAuth app, grant it Drive scopes, get client ID & secret, configure redirect URI, paste into n8n credentials. |
Pinecone | Vector database for embeddings | https://docs.n8n.io/integrations/builtin/credentials/pinecone/ | Sign up at Pinecone, in dashboard create an index, get API key + environment, paste into n8n credential. |
OpenAI | Embeddings + chat model | https://docs.n8n.io/integrations/builtin/credentials/openai/ | Log in to OpenAI, generate a secret API key, paste into n8n credentials. |
You’ll configure these under n8n → Credentials → New Credential, matching credential names referenced in your workflow nodes.
Here’s a step-by-step of what happens inside your workflow (matching your JSON):
(This path only runs when new files arrive)
(Triggered by user chat via webhook)
To help understand how your workflow fits into what’s already out there, here are a few analogues:
What sets your workflow apart is your explicit combination: Google Drive → automatic ingestion → chat agent with tool integration + memory. Many templates show either ingestion or chat, but fewer show them combined cleanly with n8n’s AI Agent.
RAG AI Agent for Google Drive Documents (n8n workflow)
This workflow turns a Google Drive folder into a live, queryable knowledge base. Drop PDF, docx, or text files into the folder → new documents are automatically indexed into a Pinecone vector store using OpenAI embeddings → you can ask questions via a webhook chat interface and the AI agent will retrieve relevant text, combine it with memory, and answer in context.
Credentials needed
- Google Drive OAuth2 (see: https://docs.n8n.io/integrations/builtin/credentials/google/oauth-generic/)
- Pinecone (see: https://docs.n8n.io/integrations/builtin/credentials/pinecone/)
- OpenAI (see: https://docs.n8n.io/integrations/builtin/credentials/openai/)
How it works
- Drive trigger picks up new files
- Download, split, embed, insert into Pinecone
- Chat webhook triggers AI Agent
- Agent retrieves relevant chunks + memory
- Agent uses OpenAI model to craft answer
This is built on the core RAG pattern (ingest → retrieve → generate) and enhanced by n8n’s AI Agent node for clean tool integration.
Inspiration & context
This approach follows best practices from existing n8n RAG tutorials and templates, such as the “Index Documents from Google Drive to Pinecone” ingestion workflow and “Build & Query RAG System” templates. (n8n)You're free to swap out the data source (e.g. Dropbox, S3) or vector DB (e.g. Qdrant) as long as you adjust the relevant nodes.
If you like, I can generate a polished Markdown README for you (with badges, diagrams, instructions) ready for GitHub/n8n community publishing. Do you want me to build that?