# Classify Gmail support emails with a local model and Postgres: n8n workflow

> Started by an arriving email, and works across Gmail and Postgres. It hands the judgement calls to a local model.

Source: https://millionrounds.com/workflow/classify-gmail-support-emails-with-a-local-model-and-postgre (Millionrounds; every figure on the page links to its filing or article)

[Automation library](https://millionrounds.com/workflows) · [Customer support](https://millionrounds.com/workflows?category=Customer+support#library)

# Classify Gmail support emails with a local model and Postgres

Started by an arriving email, and works across Gmail and Postgres. It hands the judgement calls to a local model. 16 steps: a working afternoon to understand properly.

Medium Calls a model: a local model

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fclassify-gmail-support-emails-with-a-local-model-and-postgre)

**16 steps** Medium: a working afternoon

**0** Branches: places the flow splits

**0** Loops or waits

**2** Services it connects to

## The flow

Starts it 1 Model 2 Logic 7 Service 6

The steps in the order they run, from what starts it.

- 1 **Ollama Model** Lm Ollama *Model*
- 2 **Gmail Trigger** Gmail trigger *Starts it*
- 3 **Text Classifier** Text Classifier *Model*
- 4 **Get many messages** Gmail *Service*
- 5 **Code in JavaScript1** Code *Logic*
- 6 **Code in JavaScript2** Code *Logic*
- 7 **Code in JavaScript3** Code *Logic*
- 8 **Code in JavaScript4** Code *Logic*
- 9 **Code in JavaScript5** Code *Logic*
- 10 **Code in JavaScript** Code *Logic*
- 11 **Select rows from a table** Postgres *Service*
- 12 **Insert rows in a table** Postgres *Service*
- 13 **Update rows in a table** Postgres *Service*
- 14 **Insert rows in a table1** Postgres *Service*
- 15 **Reply to a message** Gmail *Service*
- 16 **No Operation, do nothing** No Op *Logic*

## How it's built

- **Starts on:** An arriving email
- **Steps:** 16
- **Size:** Medium: a working afternoon
- **Connects to:** Gmail, Postgres
- **Model:** a local model

## Questions

What does it need to run?

An n8n account, plus your own Gmail and Postgres accounts, and a key for a local model. You connect your own accounts after importing it; none are included.

What starts it?

It starts on an arriving email.

Does it use AI?

Yes. It calls a local model. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Plan an afternoon. 16 steps is enough that you should read each one before running it.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

**Before you run it**

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 16 steps before you point it at anything that matters.

## Run it in n8n

- **Create your n8n account** Free to start. n8n is where the workflow runs. [Create an n8n account ↗](https://millionrounds.com/n8n)
- **Download the workflow** Free with a Millionrounds account. [Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fclassify-gmail-support-emails-with-a-local-model-and-postgre)
- **Paste it into n8n** Open a new workflow in n8n and paste. Then connect your own accounts.

Stored with the author's traces removed: canvas notes, instance identifiers, saved credential names and any live document they had left behind.

## Connects to

Each opens the other workflows that use it.

[Gmail](https://millionrounds.com/workflows?service=Gmail#library)[Postgres](https://millionrounds.com/workflows?service=Postgres#library)

## Workflows like it

Also customer support, with the same services where possible, closest in size first.

- [**Answer customer questions and book jobs with OpenAI RAG** 16 steps · calls a model · Gmail, Google Calendar](https://millionrounds.com/workflow/answer-customer-questions-and-book-jobs-with-openai-rag-2)
- [**Answer customer questions and book jobs with OpenAI RAG** 16 steps · calls a model · Gmail, Google Calendar](https://millionrounds.com/workflow/answer-customer-questions-and-book-jobs-with-openai-rag)
- [**Automate IT support: Convert emails to Jira tickets** 16 steps · calls a model · Gmail, Jira](https://millionrounds.com/workflow/automate-it-support-convert-emails-to-jira-tickets)
- [**Automated customer support with OpenAI** 16 steps · calls a model · Gmail, Google Drive](https://millionrounds.com/workflow/automated-customer-support-with-openai)
- [**Book beauty appointments and answer FAQs with OpenAI** 16 steps · calls a model · Gmail, Google Calendar](https://millionrounds.com/workflow/book-beauty-appointments-and-answer-faqs-with-openai)
- [**Build a support knowledge base from historical Gmail emails** 16 steps · calls a model · Gmail, Postgres](https://millionrounds.com/workflow/build-a-support-knowledge-base-from-historical-gmail-emails)
