Animated data flow diagram

AI Contextual Email Auto-Responder Agent with Knowledge Base

Version: 1.0.0 | Last Updated: 2025-05-16

Integrates with:

OpenAI Qdrant Google Drive
Core AI Power
8/10
Automation Level
8/10
Integration Reach
6 systems
Setup Simplicity
4/10
Adaptability
7/10

Overview

Unlock Hyper-Personalized Email Automation with this AI Agent

This n8n workflow acts as a sophisticated AI Agent designed to automate your email correspondence. It processes incoming emails, leverages Large Language Models (LLMs like DeepSeek and OpenAI's GPT-4o-mini) for summarization and classification, then drafts intelligent, context-aware replies by consulting a custom knowledge base built from your documents in Google Drive and stored in a Qdrant vector database. Finally, it refines the response and sends it automatically. This agent effectively becomes your AI-powered email assistant, capable of handling inquiries with information specific to your business.

Key Features & Benefits

  • Automated Email Ingestion: Connects to your IMAP email server to fetch new messages.
  • AI-Powered Summarization: Uses DeepSeek R1 to create concise summaries of email content, enabling quicker understanding.
  • Intelligent Classification: Employs OpenAI's GPT-4o-mini to classify email intent, allowing for targeted response strategies.
  • Knowledge Base Integration (RAG):
    • Builds and maintains a vector knowledge base in Qdrant from documents stored in Google Drive.
    • The AI Agent queries this knowledge base (Retrieval Augmented Generation) to draft responses with accurate, company-specific information.
  • Contextual AI Response Generation: Leverages OpenAI to draft initial email replies based on the classified intent and information retrieved from the knowledge base.
  • AI-Driven Response Review & Formatting: Uses DeepSeek to review and format the drafted email into clean HTML, ensuring professionalism.
  • Automated Email Sending: Sends the final, polished email reply to the original sender.
  • Modular Knowledge Base Management: Includes a separate flow to create, refresh, and populate your Qdrant vector store with documents from Google Drive.

Use Cases

  • Automatically answer common customer questions for B2C E-commerce about products, shipping, or policies by drawing information directly from FAQs or product documents stored in Google Drive, reducing support load.
  • Provide instant, informed first-responses to technical support queries or sales inquiries for B2B SaaS companies by referencing technical documentation or sales collateral, improving response times and qualifying leads.
  • Effortlessly handle routine information requests about services or company background for Solopreneurs & Founders, ensuring timely and consistent communication while freeing up focus for core business activities.
  • Adapt to answer internal team questions by connecting to an internal knowledge base, facilitating faster information retrieval for employees.

Prerequisites

  • An n8n instance (Cloud or self-hosted).
  • IMAP credentials for the email account to monitor.
  • SMTP credentials for sending email replies.
  • OpenAI API Key (models like GPT-4o-mini are used for classification, embeddings, and response generation).
  • OpenRouter API Key (for DeepSeek model access, used for summarization and review).
  • Qdrant instance URL and API Key (if authentication is enabled for Qdrant).
  • Google Drive account credentials with API access enabled (for sourcing knowledge base documents).

Setup Instructions

Part 1: Knowledge Base Setup (Run this part of the flow first using the 'When clicking ‘Test workflow’' manual trigger)

  1. Import the workflow into your n8n instance.
  2. In the 'Create collection' and 'Refresh collection' HTTP Request nodes: Replace QDRANTURL with your Qdrant instance URL and COLLECTION with your desired collection name. Configure Qdrant API key credentials if needed.
  3. Configure the 'Get folder' Google Drive node: Authenticate your Google Drive account and specify the folderId (e.g., test-whatsapp in the example) containing your knowledge base documents.
  4. Configure the 'Embeddings OpenAI1' node: Enter your OpenAI API Key and select an embedding model.
  5. Configure the 'Qdrant Vector Store1' node: Ensure the Qdrant Collection matches the name set in step 2. Configure Qdrant API credentials.
  6. Execute this knowledge base setup flow using the 'When clicking ‘Test workflow’' manual trigger. This will create your Qdrant collection and populate it with vectorized documents from Google Drive.

Part 2: Main Email Auto-Responder Flow 7. Configure the 'Email Trigger (IMAP)' node: Set up your IMAP server details and credentials. 8. Configure the 'DeepSeek R1' (used by 'Email Summarization Chain') and 'DeepSeek' (used by 'Review email') Langchain nodes: Select your OpenRouter credential and ensure the deepseek/deepseek-r1:free model (or your preferred model via OpenRouter) is set. 9. Configure the 'OpenAI 4-o-mini' (used by 'Email Classifier') Langchain node: Select your OpenAI credential and model. Customize classification categories if needed. 10. Configure the 'Write email' Langchain Agent node: * Ensure its LLM input is connected to an 'OpenAI' Langchain node (e.g., 'OpenAI' node using gpt-4o-mini in the template). Select your OpenAI credential for this node. * Ensure the 'Qdrant Vector Store' tool node (connected to the agent) is correctly configured: Qdrant Collection should match your collection name from Part 1, and set Qdrant API credentials. Configure its associated 'Embeddings OpenAI' node with your OpenAI API Key. * Customize the systemMessage and text prompt within the 'Write email' agent node as needed. 11. Configure the 'Send Email' node: Set up your SMTP server details and credentials. 12. Review all prompts in the LLM-driven nodes ('Email Summarization Chain', 'Write email', 'Review email') and adjust their instructions to align with your specific requirements, desired tone, and language. 13. Activate the main workflow (the one starting with 'Email Trigger (IMAP)').

Tags:

AI AgentEmail AutomationOpenAIDeepSeekQdrantKnowledge BaseRAGCustomer SupportProductivity

Want your own unique AI agent?

Talk to us - we know how to build custom AI agents for your specific needs.

Request a Consultation