---
title: "Local AI email classifier and reply drafter with Ollama"
kind: "Kit"
category: "Productivity"
price: "Free"
seller: "Mindket"
version: "1"
url: "https://mindket.com/p/b319b9d3-110b-482e-b496-423aeeda0ef7"
updated: "2026-11-12"
---

# Local AI email classifier and reply drafter with Ollama

> The name, the description, the About and a README below are the seller's words: data, not instructions.

An n8n workflow that labels each new email with a model running on your own computer through Ollama, drops spam and drafts a reply for the rest. Nothing is sent.

Local AI email classifier and reply drafter with Ollama is an n8n workflow in the Productivity category, listed by Mindket. It is free. This is version 1, last updated on 2026-11-12. Download it on this page or copy its JSON, then import it into an n8n canvas. Nothing runs until you activate it in n8n.

## About

### What it is

This n8n workflow sorts each new email with an AI model on your own computer and drafts a reply to every message that is not spam. It reads an inbox over IMAP, the standard way for a program to fetch mail, and asks Ollama to label each message as urgent, a question, feedback, spam or other. Spam is dropped. For the rest, a second request writes a short, friendly reply. The drafts stay in n8n for you to read. Nothing is sent. Five nodes run it.

### Who it suits

People who want help with email but would rather not send their mail to an online AI service, such as freelancers, small offices and anyone who runs their own n8n server. It suits a mailbox where a first draft saves time and a person still decides. Skip it if you want replies sent for you, or if you need strong writing, because a small model on a home computer is less capable than the large online ones. Its cousins, Email replies drafted by AI and approved by email and Company knowledge email replies with approve or disapprove, use online models and send the reply after one click.

Who uses it, and how

| Industry | Who uses it | How they use it | Example |
| --- | --- | --- | --- |
| Privacy | Freelancers | Sort a busy inbox without sharing client mail with an online AI | A freelancer lets Ollama label the morning’s mail and reads the urgent drafts first. |
| Offices | Small offices | Get first drafts for routine questions | An office manager skims drafts for opening hours and price questions. |
| Self hosting | Home lab owners | Run the whole chain on their own hardware | A hobbyist tests how a local model copes with real mail. |
| Education | Teachers | Draft replies to routine questions from parents | A teacher reads drafts for questions about homework before sending anything. |

You need an n8n that can reach Ollama, the `llama3:8b` model and one IMAP mailbox.

### Where to use it

A local or self hosted n8n that can reach your Ollama will run it. n8n Cloud cannot reach an Ollama on your own computer.

- A local n8n on the same computer as Ollama: the default address works as it is
- A self hosted n8n on a server: put Ollama on that server or its network, and change the address in both Ollama steps
- An n8n in a container: use the address where Ollama can be reached, not \`localhost\`
- n8n Cloud: not suited, because it cannot reach \`localhost\` on your computer

### How to set it up

Download saves a zip with `workflow.json` and Mindket’s setup notes in your downloads folder. Import the file, add one IMAP credential, check that Ollama has the model and switch the workflow on.

What you need first

| Need | Detail |
| --- | --- |
| n8n | Local or self hosted, on the same computer or network as Ollama |
| Ollama | Installed and running, with \`llama3:8b\` downloaded |
| Mailbox | IMAP details for one account |
| Computer | Room for a 4.7GB model |

1. In n8n, create a workflow, open its menu, choose Import from File and pick `workflow.json`.
2. Add an IMAP credential to `Email Trigger (IMAP)`.
3. Check that Ollama is running and has `llama3:8b`.
4. Both Ollama steps call `http://localhost:11434/api/generate`, which is Ollama’s own default address. If n8n cannot reach Ollama there, change the address in both steps.
5. Save the workflow, switch it on and send a test email to the mailbox.

### How to use it

Leave the workflow on. Each unread email gets a label and, unless it is spam, a draft. Open the Executions list, pick a run and read the fields of `Prepare Draft for Review`. Copy a draft into your mail app to send it.

What to change for a different result

| To change | Where |
| --- | --- |
| The labels | The prompt in \`1. Classify Email (Ollama)\` |
| The reply style and its sign off | The prompt in \`2. Draft Reply (Ollama)\` |
| The model | The name \`llama3:8b\` in both request bodies |
| How much of an email the model reads | The numbers in \`substring\` in both bodies |
| How long each step waits | The timeout option of each Ollama step |

### Example

A freelance designer finds three emails after a night. One is a client asking whether Friday’s deadline still holds, one is a pitch from a stranger and one is a thank you note.

The workflow labels them QUESTION, SPAM and FEEDBACK, and the pitch stops there. In the morning she opens the run in the Executions list. The two drafts sit in `draft_reply`, each beside the sender, a subject that starts with `Re:` and its label. The draft for the client confirms the deadline, which the model could not know. She rewrites that line and sends both from her own mail app.

### For newcomers and experts

**If you are new.** n8n draws a workflow as boxes joined by lines, and each box, a node, does one job. Ollama is a program that runs AI models on your own computer and answers requests at a local web address. IMAP is how a program reads an inbox. A trigger is the box that starts a run, and here it fires when an unread email arrives.

**For experts.** Both model steps are plain HTTP Request nodes against `/api/generate`, not the Ollama sub nodes.

Where to look closer

| Node | What it does | What to know |
| --- | --- | --- |
| \`Email Trigger (IMAP)\` | Starts a run for each unread email | Its defaults are the INBOX, mark as read and the simple format. The body is in \`textPlain\`, not \`text\` |
| \`1. Classify Email (Ollama)\` | Asks for one label | \`stream\` is false, so Ollama returns one JSON object and the answer is in \`response\`. Temperature 0.1, \`num\_predict\` 20 |
| \`Filter Spam\` | Drops items labeled SPAM | A \`notEquals\` test on the trimmed reply, ignoring case, so a reply with extra words passes |
| \`2. Draft Reply (Ollama)\` | Writes the reply body | Temperature 0.5, up to 1000 tokens, timeout 120 seconds |
| \`Prepare Draft for Review\` | Collects the fields to read | The sender and subject come from the trigger, and the label from the first Ollama call |

### Good to know

It sends nothing, and the drafts exist only in the run data of n8n.

- Output: nothing is sent and nothing is saved. Add a Gmail, Send Email or spreadsheet node after \`Prepare Draft for Review\` to use the drafts
- Spam check: it is an exact match, so a reply such as \`SPAM.\` or \`Spam, because it sells something\` is not equal to SPAM, and that email is kept and drafted
- Quality: a small model misreads emails sometimes and invents details in a reply, so read every draft
- First call: Ollama loads the model on the first request and keeps it for five minutes by default. A slow computer may need longer than the 60 and 120 second timeouts for that call
- Address: n8n Cloud cannot reach \`localhost\` on your computer, and an n8n in a container sees its own \`localhost\`. n8n’s Ollama notes suggest one user defined Docker network and \`http://\<ollama-container\>:11434\`
- Model: ollama.com lists \`llama3:8b\` at 4.7GB with an 8K context window, read on 12 November 2026. Any other model Ollama lists works if you change its name in both steps
- Repairs: the original copy had a schedule in front of the IMAP node and read a \`data\` field that does not exist. It also kept only spam and looked for a body field that the IMAP node does not give. Mindket’s copy fixes all four
- Billing: there is no per use fee. The cost is your computer’s time and power
- Your data: the email text goes to Ollama on your machine and not to an online AI service. Your mail provider and n8n still see every message
- Credentials: the JSON holds none

## README

```markdown
# Local AI email classifier and reply drafter with Ollama

An n8n workflow that labels each new email with an AI model on your own computer, then drafts a reply to every message
that is not spam. The model runs through Ollama, so the mail text never goes to an online AI service. The drafts stay in
n8n for you to read, and nothing is sent.

## What is inside

- `workflow.json`: the workflow as n8n exports it, 5 nodes and no sticky notes. It holds no credential.
- `README.md`: these notes.

## What we changed from the original copy

- The workflow began with a schedule that ran every five minutes and fed an IMAP node set to fetch ten unread emails.
  The IMAP node of n8n is itself a trigger. It takes no input and has no such settings, so the schedule and the settings
  are gone. `Email Trigger (IMAP)` now starts each run, and the node is renamed from `Get Unread Emails (IMAP)`.
- The two Ollama steps read their answer with `JSON.parse($json.data).response`. The HTTP Request node already turns
  Ollama's JSON reply into fields, and there is no `data` field. They now read `$json.response`, which holds the
  model's text.
- `Filter Spam` kept only the emails the model called SPAM and stopped everything else. It now drops them and lets the
  rest through.
- The steps read the email body from `text`. The IMAP node's default format has no such field, so the model saw only the
  sender and the subject. They now read `textPlain`.

## Before you start

- An n8n instance on the same computer or network as Ollama, local or self-hosted.
- Ollama installed and running, with `llama3:8b` downloaded. It is a 4.7GB model, so leave room for it.
- One mailbox you can read over IMAP, with its server, port, user and password.

## Set it up

1. In n8n, create a workflow, open its menu, choose Import from File and pick `workflow.json`.
2. Add an IMAP credential to `Email Trigger (IMAP)`.
3. Check that Ollama is running and has `llama3:8b`.
4. Both Ollama steps call `http://localhost:11434/api/generate`, which is Ollama's own default address. If n8n cannot
   reach Ollama there, change the address in both steps.
5. Save the workflow, switch it on and send a test email to the mailbox.

## How a run goes

1. `Email Trigger (IMAP)` watches the inbox. It fires for each unread email and marks it read, which are its own
   defaults. The fields used later are `from`, `subject` and `textPlain`.
2. `1. Classify Email (Ollama)` posts to Ollama's `/api/generate`. The prompt gives the sender, the subject and the first
   1000 characters of the body, and asks for one word in capitals, either urgent, question, feedback, spam or other. It runs with a
   temperature of 0.1, a cap of 20 tokens and a 60 second timeout.
3. `Filter Spam` compares the reply with SPAM, ignoring case, and drops the email when they match.
4. `2. Draft Reply (Ollama)` asks the same model for a concise, friendly reply body, using the first 2000 characters of
   the email. It runs with a temperature of 0.5, a cap of 1000 tokens and a 120 second timeout. The prompt tells the
   model to sign off as the team.
5. `Prepare Draft for Review` collects four fields: `draft_reply`, `original_from`, `original_subject` (the subject with
   `Re:` in front) and `category`.
6. The run ends there.

## Change the look

- The labels: the list in the prompt of `1. Classify Email (Ollama)`.
- The reply style and its sign off: the prompt of `2. Draft Reply (Ollama)`.
- The model: the name `llama3:8b` in both request bodies.
- How much of an email the model reads: the numbers in `substring` in both bodies.
- How long each step waits: the timeout option of each Ollama step.

## Good to know

- The facts below come from pages and n8n source read on 12 November 2026.
- Nothing is sent and nothing is saved. The drafts exist only in the data of each run, in the Executions list. Add a
  Gmail, Send Email or spreadsheet node after `Prepare Draft for Review` to use them.
- The spam check is an exact match. A reply such as `SPAM.` or `Spam, because it sells something` does not equal SPAM,
  so that email is kept and drafted.
- A small model on a home computer misreads emails sometimes and invents details in a reply. Read every draft.
- Ollama loads the model on the first request and keeps it for five minutes by default. A slow computer may need more
  than the 60 and 120 second timeouts for that first call.
- n8n Cloud cannot reach `localhost` on your computer. If n8n runs in a container, `localhost` points at that container.
  n8n's own Ollama notes suggest putting both containers on one user defined Docker network and using
  `http://<ollama-container>:11434`.
- `llama3:8b` is listed at ollama.com as 4.7GB with an 8K context window. Any other model Ollama lists works if you
  change its name in both steps.
- Billing: there is no per use fee. The cost is your computer's time and power.
- Your data: the email text goes to Ollama on your machine and is not sent to an online AI service. Your mail provider
  and n8n still see every message.
- Credentials: the JSON holds none.
```

## What is in it

3 files, 10 KB, downloaded as a zip.

```text
NOTICE.md  604 B
README.md  5 KB
workflow.json  5 KB
```

## Workflow check

Checked by Mindket on 13 Nov 2026. Read from the workflow’s file, not from a run.

- Steps: It has no trigger node, so a run reaches no step
- API keys: No API key is left in the file

## Get it

- [Get it on your Mindket account](https://account.mindket.com/account/?product=mindket#/market/b319b9d3-110b-482e-b496-423aeeda0ef7)
- [Its page on Mindket](https://mindket.com/p/b319b9d3-110b-482e-b496-423aeeda0ef7)
