Chat with Google Drive Documents via Pinecone Vector Store

Overview

This workflow enables you to have an interactive Q&A chat with the contents of any document stored in Google Drive. It first downloads a file (e.g., a PDF, Word doc, or text file) from Google Drive, splits it into manageable chunks, generates vector embeddings using OpenAI, and stores them in a Pinecone vector database. Once the data is indexed, you can ask natural language questions via a chat interface, and the workflow will retrieve the most relevant document chunks and use OpenAI's GPT model to formulate a concise answer.

This is particularly useful for research, legal document review, knowledge base queries, or any scenario where you need to quickly extract insights from large documents without reading them manually.

Workflow Steps

Data Ingestion Pipeline (Triggered Manually)

  1. When clicking 'Test Workflow' button (Manual Trigger) — No auth. This node starts the data ingestion process when you click the "Test Workflow" button in the n8n editor. It has no parameters and simply acts as a manual start point.

  2. Set Google Drive file URL (Set node) — No auth. This node creates a variable called file_url with the value https://drive.google.com/file/d/11Koq9q53nkk0F5Y8eZgaWJUVR03I4-MM/view. You must replace this URL with the actual Google Drive file you want to index.

  3. Google Drive (Google Drive node) — OAuth2. This node downloads the file from Google Drive using the file ID extracted from the URL. It uses OAuth2 authentication to access your Google Drive account. The file is downloaded as binary data for further processing.

  4. Embeddings OpenAI (Embeddings OpenAI node) — API Key auth. This node generates vector embeddings for the document chunks using OpenAI's embedding models. It requires an OpenAI API key configured in n8n credentials.

  5. Recursive Character Text Splitter (Text Splitter node) — No auth. This node splits the downloaded document into smaller chunks of 3000 characters with a 200-character overlap between chunks. This ensures that context is preserved across chunk boundaries and that each chunk fits within the embedding model's token limits.

  6. Default Data Loader (Document Data Loader node) — No auth. This node converts the binary file data into a document format that can be processed by the text splitter and vector store. It handles various file types automatically.

  7. Pinecone Vector Store (Pinecone Vector Store node) — API Key auth. This node inserts the document chunks and their embeddings into a Pinecone index named test-index. It uses the "insert" mode and clears the namespace before inserting new data. You must create this index in your Pinecone account with 1536 dimensions (matching OpenAI's embedding size).

Chat Interface (Triggered by User Message)

  1. When chat message received (Chat Trigger node) — No auth. This node creates a webhook that listens for incoming chat messages. When a user sends a message through the n8n chat interface, this node triggers the Q&A workflow.

  2. Question & Answer (Agent node) — No auth. This is the core reasoning node that coordinates the Q&A process. It receives the user's question and passes it to the language model along with relevant context from the vector store.

  3. OpenAI Chat Model (OpenAI Chat Model node) — API Key auth. This node uses OpenAI's gpt-4o-mini model to generate answers based on the retrieved document chunks and the user's question. It requires the same OpenAI API key as the embeddings node.

  4. Embeddings OpenAI1 (Embeddings OpenAI node) — API Key auth. This is a second instance of the OpenAI embeddings node used to embed the user's question so it can be compared against the stored document embeddings.

  5. Pinecone Vector Store1 (Pinecone Vector Store node) — API Key auth. This node operates in "retrieve-as-tool" mode and is configured as a tool named bitcoin_paper with the description "Call this tool to retrieve facts from the bitcoin whitepaper". It retrieves the most relevant document chunks from the same Pinecone index based on the embedded question.

Setup Instructions

  1. Pinecone Account: Create a free account at pinecone.io. Create an index with 1536 dimensions (to match OpenAI's text-embedding-ada-002 model). Note your API key and environment.

  2. OpenAI Account: Sign up at platform.openai.com and generate an API key. Ensure you have billing set up as both embeddings and chat completions incur costs.

  3. Google Drive: Ensure the document you want to index is accessible via a shareable link. The workflow currently uses a hardcoded URL to a Bitcoin whitepaper — replace this with your own document URL.

  4. n8n Credentials: In n8n, configure the following credentials:

    • Google Drive OAuth2: Connect your Google account with Drive access
    • OpenAI API: Paste your OpenAI API key
    • Pinecone API: Enter your Pinecone API key and environment
  5. Testing:

    • First, click "Test Workflow" at the bottom of the canvas to run the data ingestion pipeline. This will download the file, split it, embed it, and store it in Pinecone.
    • Then, click "Chat" at the bottom of the canvas to open the chat interface. Ask questions about the document content.

Use Cases and Variations

  • Document Analysis: Use this workflow to analyze legal contracts, research papers, or technical manuals by asking specific questions.
  • Knowledge Base: Index multiple documents by modifying the workflow to loop through a folder in Google Drive or a list of file URLs.
  • Custom Embeddings: Replace OpenAI embeddings with other providers like Cohere or Hugging Face if you prefer.
  • Different Vector Stores: Swap Pinecone for other vector databases like Weaviate, Qdrant, or Supabase if you have existing infrastructure.
  • Multi-file Support: Add a loop or webhook trigger to process new files automatically as they are added to a Google Drive folder.
  • Slack Integration: Replace the chat trigger with a Slack webhook to allow team members to query documents directly from Slack.
15 nodesmanual triggerAI
Sticky NoteVector Store PineconeAgentSetGoogle DriveDocument Default Data LoaderText Splitter Recursive Character Text SplitterEmbeddings Open AI

Workflow JSON

{
  "meta": {
    "instanceId": "408f9fb9940c3cb18ffdef0e0150fe342d6e655c3a9fac21f0f644e8bedabcd9",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "1f2bb917-6d65-4cfa-9474-fc3b19a8c3bd",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -440,
        -120
      ],
      "parameters": {
        "color": 7,
        "width": 918,
        "height": 627,
        "content": "### Load data into database\nFetch file from Google Drive, split it into chunks and insert into Pinecone index"
      },
      "typeVersion": 1
    },
    {
      "id": "eabbc944-5b62-4959-8ea4-879f28e19ab8",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        740,
        -120
      ],
      "parameters": {
        "color": 7,
        "width": 534,
        "height": 627,
        "content": "### Chat with database\nEmbed the incoming chat message and use it retrieve relevant chunks from the vector store. These are passed to the model to formulate an answer "
      },
      "typeVersion": 1
    },
    {
      "id": "ab577f4d-8906-4e0c-bc62-e8a4b2610551",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        240
      ],
      "parameters": {
        "height": 264.61498034081166,
        "content": "## Try me out\n1. In Pinecone, create an index with 1536 dimensions and select it in *both* Pinecone nodes\n2. Click 'test workflow' at the bottom of the canvas to load data into the vector store\n3. Click 'chat' at the bottom of the canvas to ask questions about the data"
      },
// ... truncated (copy to see full JSON)

How to Import This Workflow

  1. 1Copy the workflow JSON above using the Copy Workflow JSON button.
  2. 2Open your n8n instance and go to Workflows.
  3. 3Click Import from JSON and paste the copied workflow.

Don't have an n8n instance? Start your free trial at n8nautomation.cloud

Related Templates

Automated Blog Post Creation from News with AI and Blogger

This workflow automates the entire process of creating a fully SEO-optimized blog post from a news article. It fetches a trending technology news headline from Mediastack, generates relevant images from Pexels, uses two AI agents (via OpenRouter) to produce a title, slug, meta description, and a complete WordPress-compatible HTML blog post, then posts it directly to Blogger and sends you a Telegram notification. It's perfect for content marketers, bloggers, or anyone who wants to consistently publish fresh, data-driven content without manual effort. Node Breakdown Schedule Trigger (No auth) — Runs the workflow at a set interval (configured every minute by default, but you should change it to daily or hourly). Mediastack News (API Key auth via query parameter) — Fetches the latest technology news article in English from the Mediastack API. Parameters: set to . Genarate image (API Key auth via header, ) — Searches Pexels for up to 2 images related to the news title. Parameters: = , = 2. Send a text message1 (Telegram bot token auth) — Sends a Telegram message with the generated image URLs to the chat ID stored in . AI Agent (Uses OpenRouter Chat Model — API Key auth) — This agent takes the news title and returns a JSON object with three fields: , , and (meta description). The prompt includes strict guidelines for SEO-friendly output. OpenRouter Chat Model (API Key auth) — The language model for the first AI agent, using . Parsing (No auth) — A Code node that cleans the raw AI output (removes markdown code fences) and parses the JSON into usable fields. Copywriter AI Agent (Uses OpenRouter Chat Model2 — API Key auth) — This agent writes a complete 1,000-word SEO blog post in HTML format. It uses the title, meta, and the two images from Pexels. The prompt is very detailed, specifying structure, keyword placement, and styling. OpenRouter Chat Model2 (API Key auth) — Same model as the first, but used for the second agent. Cleanup HTML (No auth) — A Set node that removes any leftover htmlurlhttps://www.googleapis.com/blogger/v3/blogs/$vars.bloggerid/postsPOSThttpQueryAuthAuthorization$vars.telegramchatid$vars.bloggeridbusinesssports`) to match your niche. Multi-language Support — Modify the Mediastack query to fetch news in other languages, and adjust the AI prompts to write in that language. Custom Image Sources — Replace the Pexels node with another image API (e.g., Unsplash) or use a local image generation model. Different CMS — Swap the Blogger HTTP Request node with WordPress or any other CMS API (just change the URL and body format). Human-in-the-Loop — Add a Slack or email approval step before publishing to review the AI-generated content. Newsletter Integration — Instead of posting to a blog, send the formatted content as an email newsletter via Gmail or SendGrid.

16 nodes

AI Chat Agent with OpenAI, Memory, and Web Search

Overview This workflow creates an intelligent AI chat agent that combines OpenAI's language model with conversational memory and real-time web search capabilities via SerpAPI. It is designed to power interactive chat applications where the AI can remember context across messages and fetch up-to-date information from the internet when needed. This is particularly useful for building customer support bots, research assistants, or any conversational interface that requires both knowledge retention and live data access. The workflow is triggered by incoming chat messages and processes them through an AI agent that coordinates between the language model, memory buffer, and search tool. The agent can decide when to use web search to answer questions that require current information, while maintaining conversation history for coherent multi-turn dialogues. Workflow Steps Manual Trigger (No auth) — This node allows you to manually start the workflow for testing purposes. It has no parameters configured and simply provides a button to execute the workflow on demand. When chat message received (No auth) — This is a webhook-based trigger that listens for incoming chat messages. It generates a unique webhook URL that you can integrate with your chat frontend or messaging platform. The parameter is empty, meaning default webhook behavior is used. AI Agent (No auth) — This is the core orchestrator node that manages the conversation flow. It coordinates between the OpenAI model, memory buffer, and SerpAPI tool. The agent decides which tool to use based on the user's query and maintains the conversation state. OpenAI Chat Model (API Key auth) — This node connects to OpenAI's GPT-4o-mini model to generate responses. It requires an OpenAI API key configured in n8n credentials. The parameter is set to , which is a cost-effective and fast model suitable for chat applications. The parameter is empty, using default model settings. Window Buffer Memory (No auth) — This node implements a sliding window memory that stores recent conversation history. It allows the AI to remember context from previous messages within a configurable window size. The parameters are empty, using default memory settings. SerpAPI (API Key auth) — This tool node enables web search functionality via SerpAPI (Google Search API). It requires a SerpAPI API key configured in n8n credentials. The parameter is empty, using default search settings. The agent calls this node when it determines that real-time web data is needed to answer a query. Setup Instructions To use this workflow, you need the following accounts and credentials: OpenAI Account: Sign up at platform.openai.com and create an API key. In n8n, create an "OpenAI" credential and paste your API key. SerpAPI Account: Register at serpapi.com and obtain an API key. In n8n, create a "SerpAPI" credential with your key. Webhook URL: After activating the workflow, copy the webhook URL from the "When chat message received" node. Integrate this URL into your chat application (e.g., a custom web chat widget, Slack app, or Telegram bot). Optional: Configure the memory window size in the "Window Buffer Memory" node if you want to limit or extend conversation context. Use Cases and Variations This workflow can be adapted for multiple scenarios: Customer Support Bot: Replace SerpAPI with a knowledge base tool (e.g., vector store or database lookup) to answer product-specific questions. Research Assistant: Keep SerpAPI for web search and add additional tools like Wikipedia or news APIs. Multi-Platform Chat: Connect the webhook to different messaging platforms (Slack, Discord, Telegram) by adding appropriate trigger nodes. Personal Assistant: Add calendar or email tools to let the AI manage schedules and send messages. Language Translation: Replace the OpenAI model with a translation-specific model or add a translation tool node. To extend the workflow, you can add more tool nodes (e.g., database queries, file operations) and connect them to the AI Agent. The agent will automatically learn to use new tools based on their descriptions.

6 nodes

AI Social Media Content Generator using Local Ollama

This workflow uses a local Ollama instance to automatically generate platform-specific social media content (Twitter, LinkedIn, Reddit, Instagram) for a given topic, brand voice, and target audience. It then reviews and polishes the content for consistency and quality. Perfect for content creators, marketers, or developers who want to quickly produce multi-platform posts with full control over AI model and data privacy. Workflow Steps Manual Trigger (No auth) — Manually start the workflow to generate content on demand. Content Parameters — A Set node that defines three input variables: , , and . These can be edited directly in the node to customize each generation. Generate All Platform Content (Ollama) — An HTTP Request node (No auth) that sends a prompt to the local Ollama API (). It requests the model () to output structured JSON containing posts for Twitter, LinkedIn, Reddit, and Instagram. Parse Content JSON — A Code node that extracts and parses the JSON response from Ollama, merging it with the original topic and a timestamp. Review & Polish (Ollama) — A second HTTP Request node (No auth) that sends the generated content to Ollama for quality review (grammar, tone, formatting) and returns corrected versions if needed. Final Content Output — A Code node that merges the reviewed output with the original and flags whether the content was reviewed. Setup Instructions Ollama: Download and install Ollama on your local machine. Pull the model by running . Ensure Ollama is running (default on ). n8n: The workflow uses only local connections—no external API keys or accounts required. Simply import the JSON into your n8n instance and execute it manually. Customization: Modify the node to change the topic, brand voice, or target audience. Adjust the prompt in the first HTTP Request node to add or remove platforms. Use Cases & Variations Scheduled content generation: Replace the Manual Trigger with a Cron trigger to generate posts daily or weekly. Multi-model support: Change the parameter in Ollama calls to use other models like , , or . Platform expansion: Edit the prompt to include additional platforms (e.g., Facebook, TikTok) or output formats. Integration with publishing tools: After the final output, add nodes to post directly to Twitter via API, save to a Google Sheet, or send to a CMS. Language/tonality: Adjust the and prompt instructions to generate content in different languages or styles.

6 nodes

Ready to automate with n8n?

Get affordable managed n8n hosting with 24/7 support.