# Sync Gmail emails to PostgreSQL with S3: n8n workflow template

> Started by a clock, and works across Gmail, Postgres and S3. 19 steps, 1 loop or waits: a working afternoon to understand properly.

Source: https://millionrounds.com/workflow/sync-gmail-emails-to-postgresql-with-s3 (Millionrounds; every figure on the page links to its filing or article)

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

# Sync Gmail emails to PostgreSQL with S3

Started by a clock, and works across Gmail, Postgres and S3. 19 steps, 1 loop or waits: a working afternoon to understand properly.

Medium

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fsync-gmail-emails-to-postgresql-with-s3)

**19 steps** Medium: a working afternoon

**0** Branches: places the flow splits

**1** Loop or waits

**3** Services it connects to

## The flow

Starts it 2 Logic 12 Service 5

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

- 1 **Schedule Trigger** Schedule trigger *Starts it*
- 2 **Gmail Trigger** Gmail trigger *Starts it*
- 3 **Get Many Sent** Gmail *Service*
- 4 **Get Many Inbox** Gmail *Service*
- 5 **Get Individual Message** Gmail *Service*
- 6 **Flow Convergence** No Op *Logic*
- 7 **Binary Data Filter** Filter *Logic*
- 8 **Merge Attachments** Merge *Logic*
- 9 **Email to PostgreSQL Transform** Code *Logic*
- 10 **Extract Binary Metadata** Code *Logic*
- 11 **Upload to Storage** S3 *Service*
- 12 **Final Merge** Merge *Logic*
- 13 **Split Attachments** Split Out *Logic*
- 14 **Structure Fields** Set *Logic*
- 15 **Link Email Attachments** Code *Logic*
- 16 **Aggregate Attachments** Aggregate *Logic*
- 17 **Process Items Loop** Split In Batches *Logic*
- 18 **End Loop** No Op *Logic*
- 19 **Insert or Update Database** Postgres *Service*

## How it's built

- **Starts on:** A clock
- **Steps:** 19, 1 loop or waits
- **Size:** Medium: a working afternoon
- **Connects to:** Gmail, Postgres, S3
- **Model:** None. This is plumbing, not judgement

## Questions

What does it need to run?

An n8n account, plus your own Gmail, Postgres and S3 accounts. You connect your own accounts after importing it; none are included.

What starts it?

It starts on a clock.

Does it use AI?

No. Every step is fixed logic or a call to a service, so it does the same thing every time.

How long does it take to set up?

Plan an afternoon. 19 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 19 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%2Fsync-gmail-emails-to-postgresql-with-s3)
- **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)[S3](https://millionrounds.com/workflows?service=S3#library)

## Workflows like it

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

- [**Generate AI matte painting video variations with Seedance** 19 steps · ClickUp, Gmail](https://millionrounds.com/workflow/generate-ai-matte-painting-video-variations-with-seedance)
- [**Generate visual diagrams and content assets from ideas** 19 steps · Email, Postgres](https://millionrounds.com/workflow/generate-visual-diagrams-and-content-assets-from-ideas)
- [**Send post-delivery CSAT surveys and log responses with Gmail** 19 steps · Gmail, Google Sheets](https://millionrounds.com/workflow/send-post-delivery-csat-surveys-and-log-responses-with-gmail)
- [**YouTube outlier detector** 19 steps · Postgres, YouTube](https://millionrounds.com/workflow/youtube-outlier-detector)
- [**Analyze & sort suspicious email contents with OpenAI** 19 steps · calls a model · Gmail, Jira](https://millionrounds.com/workflow/analyze-and-sort-suspicious-email-contents-with-openai)
- [**Automate YouTube thumbnail creation & social publishing** 19 steps · calls a model · Gmail, Google Drive](https://millionrounds.com/workflow/automate-youtube-thumbnail-creation-and-social-publishing)
