Retrieve and answer Gmail email queries with Llama 3.2, mxbai-embed, and Qdrant
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 combi...
Template notes
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
- n8n: For workflow orchestration of both the ingestion pipeline and response automation. - Docker & Docker Compose: For containerizing and orchestrating the n8n and Qdrant services locally. - Google Drive: To host and trigger updates from the approved FAQ knowledge base. - Gmail: For real-time incoming email triggers and threaded outbound replies. - Qdrant: For self-hosted vector database storage and similarity matching. - LM Studio: To host the local AI models via an OpenAI-compatible API for two primary tasks: - Embedding Generation: Uses the mxbai-embed-large-v1 model to convert FAQ data and incoming questions into high-dimensional vectors for semantic matching. - Response Generation: Uses the llama-3.2-3b-instruct model to process the retrieved context and craft a polite, personalized HTML email reply.
⨠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.