Skip to main content

Real-time email RAG assistant with Gmail, OpenAI GPT, and PGVector

Workflow preview

Workflow preview
100%
Real-time email RAG assistant with Gmail, OpenAI GPT, and PGVector preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Email real time RAG Assistant with Gmail, OpenAI & PGVector Who’s it for This workflow is ideal for: Professionals Project managers Sales and support teams Anyone managing high volumes of Gma...

Best for

  • Personal Productivity automation workflows
  • AI RAG automation workflows
  • intermediate n8n builders looking for reusable templates

Tools used

n8n-nodes-base.gmailtrigger, n8n-nodes-base.gmail, @n8n/n8n-nodes-langchain.textsplitterrecursivecharactertextsplitter, @n8n/n8n-nodes-langchain.embeddingsopenai, @n8n/n8n-nodes-langchain.documentdefaultdataloader, @n8n/n8n-nodes-langchain.vectorstorepgvector, n8n-nodes-base.stickynote, @n8n/n8n-nodes-langchain.lmchatopenai

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Zain Ali.

Original n8n.io source

1.1 Workflow description

Title
Real-time email RAG assistant with Gmail, OpenAI GPT, and PGVector
Workflow name
Real-time email RAG assistant with Gmail, OpenAI GPT, and PGVector

🧠 Email real time RAG Assistant with Gmail, OpenAI & PGVector

📌 Who’s it for

This workflow is ideal for:

  • Professionals
  • Project managers
  • Sales and support teams
  • Anyone managing high volumes of Gmail messages

It enables fast and intelligent search through your email inbox using natural language queries.


⚙️ How it works / What it does

  • Continuously monitors your Gmail inbox for new emails.
  • Extracts email content and metadata (subject, body, sender, date).
  • Converts email content into vector embeddings using OpenAI.
  • Stores embeddings in a PostgreSQL database with PGVector.
  • A conversational AI agent performs semantic search on your stored email history.
  • Supports time-sensitive and context-aware responses via OpenAI Chat model.

🚀 How to set up

  1. Connect your Gmail account to the Gmail Trigger node (with API access enabled).
  2. Configure OpenAI credentials for the Embedding and Chat nodes.
  3. Set up a PostgreSQL database with the PGVector extension enabled.
  4. Import the workflow into your n8n instance (Cloud or Self-hosted).
  5. Customize parameters like polling frequency, embedding settings, or vector query depth.

📋 Requirements

  • ✅ n8n instance (Self-hosted or Cloud)
  • ✅ Gmail account with API access
  • ✅ OpenAI API Key
  • ✅ PostgreSQL database with PGVector extension installed

🛠️ How to customize the workflow

  • Email Filtering: Change filters in the Gmail Trigger to watch specific labels or senders.
  • Text Splitting Granularity: Adjust chunkSize and chunkOverlap in the text splitter node.
  • Query Depth: Modify topK in the vector search node to retrieve more or fewer similar results.
  • Prompt Tuning: Customize the system message or agent instructions in the RAG node.
  • Workflow Extensions: Add notifications, error logging, Slack/Telegram alerts, or data exports.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Gmail Trigger

Type / Role
n8n-nodes-base.gmailTrigger - gmailTrigger
Config choices
Version 1.2

Block 2 - Get Mail Data

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 3 - Recursive Character Text Splitter2

Type / Role
@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter - textSplitterRecursiveCharacterTextSplitter
Config choices
Version 1

Block 4 - Embeddings OpenAI3

Type / Role
@n8n/n8n-nodes-langchain.embeddingsOpenAi - embeddingsOpenAi
Config choices
Version 1.1

Block 5 - Enhanced Default Data Loader

Type / Role
@n8n/n8n-nodes-langchain.documentDefaultDataLoader - documentDefaultDataLoader
Config choices
Version 1

Block 6 - Postgres PGVector Store3

Type / Role
@n8n/n8n-nodes-langchain.vectorStorePGVector - vectorStorePGVector
Config choices
Version 1.1

Block 7 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 8 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1

Block 9 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 10 - New RAG Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 1.7

Block 11 - Postgres PGVector Store

Type / Role
@n8n/n8n-nodes-langchain.vectorStorePGVector - vectorStorePGVector
Config choices
Version 1.1

Block 12 - Embeddings OpenAI

Type / Role
@n8n/n8n-nodes-langchain.embeddingsOpenAi - embeddingsOpenAi
Config choices
Version 1.1

Block 13 - When chat message received

Type / Role
@n8n/n8n-nodes-langchain.chatTrigger - chatTrigger
Config choices
Version 1.1

3. Summary Table

Workflow Real-time email RAG assistant with Gmail, OpenAI GPT, and PGVector
Complexity intermediate
Nodes 13
Categories Personal Productivity, AI RAG
Author Zain Ali
Published 12 Jul 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/5908/5908.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Real-time email RAG assistant with Gmail, OpenAI GPT, and PGVector do?

Email real time RAG Assistant with Gmail, OpenAI & PGVector Who’s it for This workflow is ideal for: Professionals Project managers Sales and support teams Anyone managing high volumes of Gma...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Personal Productivity, AI RAG use case.