Gmail assistant with full Gmail history RAG using OpenAI
đ§ RAG with Full Gmail history + Real time email updates in RAG using OpenAI & Qdrant > Summary: > This workflow listens for new Gmail messages, extracts and cleans email content, generates embeddings via OpenAI...
Template notes
đ§ RAG with Full Gmail history + Real time email updates in RAG using OpenAI & Qdrant
> Summary: > This workflow listens for new Gmail messages, extracts and cleans email content, generates embeddings via OpenAI, stores them in a Qdrant vector database, and then enables a RetrievalâAugmentedâGeneration (RAG) agent to answer user queries against those stored emails. Itâs designed for teams or bots that need conversational access to past emails.
---
đ§âđ¤âđ§ Whoâs it for - Support teams who want to surface past customer emails in chatbots or helpâdesk portals - Sales ops that need AIâpowered summaries and quick lookup of email histories - Developers building RAG agents over email archives
---
âď¸ How it works / What it does 1. Trigger - Gmail Trigger polls every minute for new messages. 2. Fetch & Clean - Get Mail Data pulls full message metadata and body. - Code node normalizes the body (removes line breaks, collapses spaces). 3. Embed & Store - Embeddings OpenAI node computes vector embeddings. - Qdrant Vector Store inserts embeddings + metadata into the emailshistory collection. 4. Batch Processing - SplitInBatches handles large inbox loads in chunks of 50. 5. RAG Interaction - When chat message received â RAG Agent â uses Qdrant Email Vector Store as a tool to retrieve relevant email snippets before responding. 6. Memory - Simple Memory buffer ensures the agent retains recent context.
---
đ ď¸ How to set up 1. n8n Instance - Deploy n8n (selfâhosted or via Coolify/Docker). 2. Credentials - Create an OAuth2 credential in n8n for Gmail (with Gmail API scopes). - Add your OpenAI API key in n8n credentials. 3. Qdrant - Stand up a Qdrant instance (selfâhosted or Qdrant Cloud). - Note your host, port, and API key (if any). 4. Import Workflow - In n8n, go to Workflows â Import â paste the JSON you provided. - Ensure each credential reference (Gmail & OpenAI) matches your n8n credential IDs. 5. Test - Click Execute Workflow or send a test email to your Gmail. - Monitor n8n logs: you should see new points in Qdrant and RAG responses.