Build the responder in n8n as a chain of nodes: an inbox trigger over IMAP, a Markdown converter, a DeepSeek summariser, a GPT-4o-mini classifier, an OpenAI writer, a DeepSeek reviewer and a Send Email node. Emails classed as company information requests pull context from a Qdrant vector database first. A separate branch loads your Google Drive documents into Qdrant. Test with a real email before switching the workflow to Active.
Manually replying to routine enquiries takes time away from higher-value work. By connecting an IMAP inbox to an AI pipeline in n8n, you can automatically read incoming emails, classify them, generate a professional reply and send it, all without human intervention.
This guide walks you through building a complete automated mail responder workflow in n8n. The finished workflow monitors an inbox, summarises each message, classifies it, drafts a reply using OpenAI, reviews that reply with a second model, and sends the response via SMTP. A Qdrant vector database backs the response generation with relevant documents pulled from Google Drive.
npm install -g @n8n/cli or run it directly with npx @n8n/cli workflow list.Before building each node, it helps to understand the full data path. Each incoming email passes through a chain of processing steps, and knowing the purpose of each step makes it easier to debug problems later.
The workflow follows this sequence:
A separate document vectorisation branch handles loading your Google Drive files into Qdrant. You run this branch once to populate the database, then refresh it whenever your documents change.
The Email Trigger node is the entry point for the workflow. It connects to your inbox over IMAP and passes each new message downstream as a data object.
993 for SSL), your email address and password.INBOX and choose a polling frequency. One minute is a reasonable starting point for most business inboxes.With the trigger configured, the workflow now has a live data source. The next step cleans the email body before it reaches the AI models.
HTML email bodies contain tags, inline styles and encoded characters that confuse language models. Converting to plain text first produces more accurate summaries and classifications.
{{ $json.html }} (the HTML body field from the IMAP node). The output will be clean plain text.deepseek-reasoner model.The summarisation output feeds into the classifier, giving it a condensed version of the email rather than the full body.
Classification routes each email to the correct response path. An email asking about your company gets a context-aware reply drawn from your document store; everything else follows a generic path.
gpt-4o-mini as the model. Connect it to the Text Classifier as the language model.Company info request and Other. Add a description for each so the model understands the distinction. For example: Company info request – the sender is asking about the business, its services, pricing or contact details.With classification in place, the workflow can now apply different logic depending on what the sender needs.
The vector database stores embeddings of your company documents. When an email is classified as a company info request, the workflow queries Qdrant to retrieve the most relevant document chunks and passes them to the response-generation model as context.
text-embedding-3-small or text-embedding-ada-002. This node converts the incoming email text into a vector so Qdrant can find similar document chunks.The retrieved context gives the response model accurate, up-to-date information about your business rather than relying on the model’s training data alone.
Two AI nodes handle response generation. The first drafts the reply; the second reviews it for tone and formats it as HTML ready for sending.
gpt-4o or gpt-4o-mini and connect it as the language model.<br>, <b>, <i> and <p> where appropriate.deepseek-chat and connect it as the language model for the review step.Using two models in sequence means the first model focuses on content accuracy while the second focuses on presentation, producing a more consistent output than a single prompt would.
The final node in the main branch delivers the formatted reply to the original sender using SMTP.
587 for STARTTLS or 465 for SSL), username and password.{{ $('Email Trigger (IMAP)').item.json.from.value[0].address }} to reply to the original sender. Set Subject to Re: {{ $('Email Trigger (IMAP)').item.json.subject }}.{{ $json.text }}.The main workflow branch is now complete. Incoming emails are read, summarised, classified, answered and sent without manual intervention.
The retrieval step only works if your Qdrant collection contains document embeddings. This separate branch loads your company documents from Google Drive, splits them into chunks and stores them as vectors. Run it once to populate the collection, then re-run it whenever your documents change.
500 tokens and the chunk overlap to 50 tokens. Smaller chunks improve retrieval precision; overlap prevents context being cut mid-sentence.text-embedding-3-small or text-embedding-ada-002) so that query and document vectors are in the same space.Once this branch has run successfully, your Qdrant collection is ready to serve relevant context to the response generation model.
Testing before activation catches credential errors and misconfigured expressions before they affect real senders.
The workflow is now live. Every new email that arrives in the monitored inbox will be processed and replied to automatically.
If the trigger never activates, the most common cause is a credential or connection problem between n8n and your mail server.
993 is not blocked by a firewall on your VPS. See our guide on opening ports in UFW.Empty retrieval results usually mean the collection was not populated, or the embedding model used during insertion does not match the one used during retrieval.
SMTP failures are almost always caused by incorrect credentials or a blocked outgoing port.
curl or a desktop mail client before entering them in n8n.587 or 465 is open on your server. See our guide on opening ports in firewalld.API errors from OpenAI or DeepSeek are usually caused by invalid keys, rate limits or malformed prompts.
{{ $json.text }} to use the plain-text body instead.The workflow you built here covers one common automation pattern: inbound email triage and response. n8n supports hundreds of integrations, so the same principles apply to other communication channels and data sources.
If you want to extend this workflow, consider adding a Slack or Teams notification node on the Other branch so a human agent is alerted when an email falls outside the automated categories. You could also add a Google Sheets node to log every processed email, giving you a record of what was sent and when.
For the infrastructure side, running n8n on a VPS gives you full control over polling intervals, memory allocation and outbound IP addresses. A dedicated outbound IP is particularly useful if your SMTP provider enforces IP-based sending limits. Our guide on securing your VPS covers the baseline hardening steps you should apply before exposing any service to the internet.
Managing workflows from the command line is covered in the n8n CLI documentation. You can list, export and import workflows without opening the browser interface, which is useful for version-controlling your automations in Git. Our guide on adding an SSH key to GitHub walks through connecting your server to a repository.
For a broader look at what you can self-host on a VPS alongside n8n, the Node.js hosting page covers compatible environments. The n8n project also maintains a full list of built-in app nodes where you can browse available integrations and their configuration options.
You have built a complete automated mail responder in n8n. The workflow monitors an inbox via IMAP, converts and summarises each message, classifies it with GPT-4o-mini, retrieves relevant context from a Qdrant vector database, drafts a reply with OpenAI, reviews it with DeepSeek and sends the finished response via SMTP.
Review the execution logs over the first few days to confirm classifications are accurate and replies read naturally. Adjust the system prompts in the Write Email and Review Email nodes to match your brand voice. For related tasks, see our guides on installing Node.js on Linux, installing Docker Compose (useful for self-hosting Qdrant) and managing firewall ports on your VPS.
Running n8n on a VPS from Unlimited Web Hosting gives you the resources and network access this kind of always-on automation workflow needs.
Did this guide solve your problem?
Our UK support team answers tickets and live chat every day. Send us the guide you were following and where it stopped working.
Related guides
Every cPanel hosting plan includes mailboxes you manage yourself.
Get cPanel HostingRegister the domain your mailboxes will sit on, with hundreds of extensions available.
Search Domains