AI Financial Report Analyzer (RAG) using n8n, Gemini & Pinecone
Integrates with:
Overview
Unlock Automated Financial Insights with this AI Agent
This n8n AI Agent automates the complex task of analyzing financial earnings reports. It ingests PDF reports (whose Google Drive links are listed in a Google Sheet), processes them using Google Gemini for embeddings, and stores these embeddings in a Pinecone vector store. The AI Agent, primarily powered by an OpenAI model, then uses a RAG tool (which itself leverages Gemini) to query this vector store and generate a comprehensive, markdown-formatted financial analysis based on your specific query. The analysis focuses on trends, differences, and outliers, and the final report is automatically saved to a Google Doc.
This agent is pre-configured to analyze Google's (Alphabet Inc.) earnings reports as an example but can be adapted for other companies.
Key Features & Benefits
- AI-Driven Document Analysis: Employs Retrieval Augmented Generation (RAG) with Google Gemini embeddings and Pinecone to deeply understand and summarize dense financial PDFs.
- Automated Reporting: Automatically generates structured financial reports in Google Docs, significantly reducing manual effort and time.
- Hybrid AI Power: Leverages Google Gemini for efficient document embedding and specialized RAG tool operations, combined with OpenAI's advanced models (configurable) for the main agent's reasoning, query understanding, and report generation.
- Customizable Data Ingestion: Easily point the agent to analyze reports for any company by updating a Google Sheet with links to PDFs stored in Google Drive.
- Targeted Financial Insights: The AI is prompted to identify key financial trends, compare performance across periods, and highlight significant outliers or anomalies.
- Streamlined Workflow: From PDF ingestion to final report in Google Docs, the entire process is automated within n8n.
- Scalable Processing: Designed to efficiently handle multiple documents, ideal for quarter-over-quarter or year-over-year financial analysis.
Use Cases
- Automate quarterly earnings report summarization for investment portfolio management.
- Enable solopreneurs and founders to quickly assess competitor financial health without needing deep financial expertise.
- Equip CTOs and finance heads with AI-powered tools to extract key financial metrics for strategic decision-making and board reporting.
- Streamline due diligence by rapidly analyzing financial statements of potential investment targets or acquisition candidates.
- Generate initial drafts of financial analysis for market research reports or internal briefings.
Prerequisites
- An n8n instance (Cloud or self-hosted).
- Google Cloud Project with Vertex AI API enabled.
- Google AI API key (for Google Gemini models used in embeddings and the RAG tool).
- OpenAI API Key (for the main AI Agent's language model, e.g., GPT-3.5-turbo or GPT-4).
- Pinecone account and API key. You'll need to create an index (e.g., 'company-earnings') with dimensions matching your embedding model (e.g., Google's text-embedding-004 outputs 768 dimensions).
- Google Workspace account with API access enabled for Google Drive, Google Sheets, and Google Docs. OAuth2 credentials for these services must be configured in n8n.
- PDF earnings reports stored in a Google Drive folder.
- A Google Sheet listing the direct URLs to these PDF files in Google Drive.
Setup Instructions
- Download the n8n workflow JSON file.
- Import the workflow into your n8n instance.
- Configure Credentials: In n8n, set up credentials for: Google Sheets (OAuth2), Google Drive (OAuth2), Google Docs (OAuth2), Google Gemini (API Key using your Google AI API key), Pinecone (API Key), and OpenAI (API Key).
- Pinecone Setup: Ensure your Pinecone index (e.g., 'company-earnings') is created and configured with the correct dimensions for the embeddings (e.g., 768 for
models/text-embedding-004
). - Google Sheet Preparation: Create a Google Sheet. One column should contain the direct links (URLs) to your PDF financial reports stored in Google Drive (e.g., name this column 'File URL'). You can add other columns for metadata if needed (e.g., '10Q' for report name).
- Configure 'List Of Files To Load (Google Sheets)' node: Select your Google Sheet, the specific tab, and ensure it reads the column with file URLs.
- Configure 'Download File From Google Drive' node: Ensure the 'File ID' parameter correctly references the URL column from the Google Sheet node (e.g.,
={{ $('List Of Files To Load (Google Sheets)').item.json['File URL'] }}
). - Data Ingestion Path: Verify 'Embeddings Google Gemini' and 'Pinecone Vector Store' (insertion mode) nodes are using your configured credentials and the correct Pinecone index name.
- Configure 'AI Agent' node:
- Review and customize the
text
parameter (the user query) as needed. - Review the
system_prompt
. It's pre-set for Google/Alphabet Inc. but can be generalized. - Ensure its connected Language Model (defaulted to 'OpenAI Chat Model') is configured with your OpenAI API Key and desired model.
- Verify the 'Vector Store Tool' is correctly connected.
- Review and customize the
- Configure 'Vector Store Tool' node:
- This tool is used by the AI Agent for RAG.
- Ensure it's connected to the 'Pinecone Vector Store (Retrieval)' node (set to your index), the 'Embeddings Google Gemini (retrieval)' node, and the 'Google Gemini Chat Model1' (this LLM powers the tool's internal operations).
- Configure 'Save Report to Google Docs' node:
- Set the 'Document URL' to your target Google Doc.
- Ensure the 'Text' field under 'Actions' is set to capture the AI Agent's output (e.g.,
={{ $('AI Agent').item.json.output }}
).
- Activate the workflow. You can run it manually via the 'When clicking ‘Test workflow’' node for initial data loading and report generation.
Want your own unique AI agent?
Talk to us - we know how to build custom AI agents for your specific needs.
Schedule a Consultation