Build a RAG system for PDF documents with Google Drive, Unstructured, and OpenAI
Needs changesWhat this workflow does
This AI workflow has 15 nodes and runs on Google Drive events (file created) (plus 1 other trigger). Along the way it connects OpenAI Chat Model, Pinecone Vector Store, Embeddings OpenAI and Google Drive. It also calls unstructured:8000 and api.openai.com over HTTP.
How it runs
Trigger: On Google Drive events (file created) (plus 1 other trigger).
- Google Drive: download
- Question & Answer (AI Agent): runs an AI agent, with model: OpenAI Chat Model; 1 tool (Pinecone Vector Store); memory: Simple Memory
- Unstructured Extract (HTTP Request): calls unstructured:8000 (POST)
- Map Data (Code): runs custom JavaScript code
- Pack (Code): runs custom JavaScript code
- HTTP OpenAI Embeddings (HTTP Request): calls api.openai.com (POST)
- Re-expand (Code): runs custom JavaScript code
- Prepare Data for Upsert (Edit Fields (Set)): sets 2 fields: id, metadata
- Pinecone Upsert (HTTP Request): calls an HTTP API (POST)
Services it uses
HTTP calls to: unstructured:8000, api.openai.com
Before you upgrade to n8n 3.0
1 thing in this workflow is removed in n8n 3.0. Fix it before you upgrade:
- AI Agent v1 (old agent modes) in Question & Answer (v1.8): replace with Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent.
| Removed in 3.0 | Replace with |
|---|---|
| AI Agent v1 (old agent modes) Question & Answer (v1.8) | Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent. |
Nodes used (11)
- HTTP Request
n8n-nodes-base.httpRequest - Code
n8n-nodes-base.code - Chat Trigger
@n8n/n8n-nodes-langchain.chatTrigger - AI Agent
@n8n/n8n-nodes-langchain.agent - OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - Pinecone Vector Store
@n8n/n8n-nodes-langchain.vectorStorePinecone - Embeddings OpenAI
@n8n/n8n-nodes-langchain.embeddingsOpenAi - Simple Memory
@n8n/n8n-nodes-langchain.memoryBufferWindow - Edit Fields (Set)
n8n-nodes-base.set - Google Drive
n8n-nodes-base.googleDrive - Google Drive Trigger
n8n-nodes-base.googleDriveTrigger
From the author
This template monitors a Google Drive folder, converts PDF documents into clean text chunks with Unstructured, generates OpenAI embeddings, and upserts vectors into Pinecone. It’s a practical, production-ready starting point for Retrieval-Augmented Generation…