Back to Catalog

Ask questions about a PDF using AI

David RobertsDavid Roberts
139506 views
2/3/2026
Official Page

The workflow first populates a Pinecone index with vectors from a Bitcoin whitepaper. Then, it waits for a manual chat message. When received, the chat message is turned into a vector and compared to the vectors in Pinecone. The most similar vectors are retrieved and passed to OpenAI for generating a chat response.

Note that to use this template, you need to be on n8n version 1.19.4 or later.

Ask Questions About a PDF Using AI

This n8n workflow enables you to interact with PDF documents stored in Google Drive using AI. It allows you to upload a PDF, embed its content into a Pinecone vector store, and then ask questions about the PDF, receiving AI-generated answers based on the document's content.

What it does

This workflow automates the following steps:

  1. Triggers on chat message: Initiates the workflow when a chat message is received, allowing for user interaction to either upload a PDF or ask a question.
  2. Loads PDF from Google Drive: Retrieves a specified PDF file from Google Drive.
  3. Processes PDF content: Converts the binary PDF data into a readable document format.
  4. Splits document into chunks: Divides the document into smaller, manageable text chunks for efficient processing by the AI.
  5. Generates embeddings: Creates numerical representations (embeddings) of the text chunks using OpenAI's embedding model.
  6. Inserts into Pinecone Vector Store: Stores the generated embeddings and their corresponding text chunks into a Pinecone vector database.
  7. Loads Pinecone Vector Store: Retrieves relevant document chunks from Pinecone based on the user's query.
  8. Retrieves relevant information: Uses a Vector Store Retriever to find the most relevant document sections for the given question.
  9. Answers questions using OpenAI: Leverages an OpenAI Chat Model to generate an answer to the user's question based on the retrieved document content.

Prerequisites/Requirements

To use this workflow, you will need:

  • n8n Instance: A running n8n instance.
  • Google Drive Account: To store your PDF documents.
  • OpenAI API Key: For generating text embeddings and AI-powered answers.
  • Pinecone Account: To create and manage your vector store for document embeddings.

Setup/Usage

  1. Import the workflow: Download the provided JSON and import it into your n8n instance.
  2. Configure Credentials:
    • Google Drive: Set up a Google Drive credential to allow n8n to access your files.
    • OpenAI: Configure an OpenAI credential with your API key.
    • Pinecone: Set up a Pinecone credential with your API key and environment details.
  3. Adjust Node Parameters:
    • Google Drive (Node 58): Specify the ID of the PDF file you want to process.
    • Pinecone: Insert (Node 1211): Configure your Pinecone index name and namespace if applicable.
    • Pinecone: Load (Node 1213): Configure your Pinecone index name and namespace, matching the insert node.
    • Manual Chat Trigger (Node 1207): This node acts as the entry point for your chat interactions. You will need to interact with it manually or integrate it with a chat platform (e.g., Slack, Telegram) using another trigger node.
  4. Activate the workflow: Once configured, activate the workflow.
  5. Interact with the workflow:
    • To upload and embed a new PDF, you would typically trigger the workflow with a specific command or input that leads to the Google Drive and Pinecone Insert path.
    • To ask a question, trigger the Manual Chat Trigger node with your question. The workflow will then retrieve relevant information from Pinecone and provide an AI-generated answer.