๐ŸŽซ Retrieve and answer Gmail email queries with Llama 3.2, mxbai-embed, and Qdrant

โšก 447 views ยท ๐ŸŽซ Ticket Management & Triage

Description

Self-Hosted

This workflow provides a complete end-to-end system for automatically managing your inbox by reading incoming questions, matching them to approved guidelines, and sending consistent, 24/7 replies. By combining local AI processing with an automated retrieval-augmented generation (RAG) pipeline, it ensures fast resolution times without compromising data privacy or incurring ongoing AI API costs.

Who is this for?

This is designed for University Admissions, Student Support Teams, Customer Service Staff, or professionals in any industry who are overwhelmed by their inboxes and spend countless hours answering repetitive questions. It is particularly useful for any organization looking to automate routine FAQs across various fields, maintaining personalized, human-like, and threaded email conversations while keeping data completely in-house.

๐Ÿ› ๏ธ Tech Stack

โœจ How it works

  1. Knowledge Base Ingestion: The workflow automatically detects updates to a specific FAQ JSON file in Google Drive, converts the Q&A pairs into vector embeddings using the local mxbai model, and stores them in Qdrant.
  2. Email Trigger: The resolution pipeline kicks off instantly when a new incoming email arrives via the Gmail trigger.
  3. Semantic Search: The incoming question is converted to an embedding using the mxbai-embed-large-v1 model and checked against the Qdrant database to retrieve the top 3 most relevant FAQ answers, enforcing a minimum 0.7 similarity threshold for quality control.
  4. LLM Response Generation: The OpenAI node (pointing to LM Studio) processes the retrieved context and the studentโ€™s email using the llama-3.2-3b-instruct model to craft a polite, personalized HTML email response.
  5. Threaded Reply: The Gmail node sends the generated response directly back into the original email thread, exactly like a human would.

๐Ÿ“‹ Requirements

๐Ÿš€ How to set up

  1. Prepare your Local AI:
    • Open LM Studio, download both the embedding and LLM models.
    • Start the Local Server on port 1234.
    • Note your machineโ€™s local IP address (e.g., 192.168.1.50).
  2. Spin up Services:
    • Clone the repository and configure the .env file with your QDRANT_COLLECTION name.
    • Run docker compose up -d to start the n8n and Qdrant containers.
  3. Import the Workflow:
    • Open n8n at http://localhost:5678 and import the provided JSON workflow file.
  4. Link Services:
    • Update the Google Drive nodes with the File ID of your FAQ JSON document.
    • Update the embedding and AI nodes with your local IP address in the Base URL.
  5. Test and Activate:
    • Execute the ingestion pipeline manually to populate Qdrant.
    • Toggle the workflow to Active.
    • Send a test email to your connected Gmail address to verify the automated reply.

๐Ÿ”‘ Credential Setup

To run this workflow, you must configure the following credentials in n8n:

โš™๏ธ How to customize

๐Ÿ”— Nodes Used

HTTP Request, Google Drive, Gmail, Google Drive Trigger, Gmail Trigger, Extract from File

๐Ÿ“ฅ Import

Download workflow.json and import into n8n: Workflow menu โ†’ Import from File

๐Ÿ“– Importing guide ยท ๐Ÿ”‘ Credential setup