Category: Automations › Gmail & Inbox Automation · Best for: Notion-first teams · Platform: n8n · Steps: 25
What it does
Important emails are copied into your Notion so you can find them later.
- Disable the Gmail Trigger and enable the manual trigger here
Works with: Gmail, OpenAI, Tool Calculator, Output Parser Structured, Agent, Airtable
What you get
- The n8n workflow file (
workflow.json), ready to import - This setup guide
- The list of fields to change for your own accounts (see Install below)
- Email support if you get stuck
Before you start
-
An n8n account. Easiest: n8n Cloud (free trial). Self-host for free with Docker:
docker run -it --rm -p 5678:5678 -v n8n_data:/home/node/.n8n docker.n8n.io/n8nio/n8n, then open http://localhost:5678. -
Accounts and API keys for these services:
- OpenAI API key: how to connect (used by OpenAI Chat Model, OpenAI Chat Model1)
- Google (Sheets, Gmail, Drive, Calendar, Docs): how to connect (used by Add Label "Processed", Add Label "Error", Send notification about deactivated route, Send notification about missing route, Gmail Trigger, Get all labels)
- Airtable personal access token: how to connect (used by Deactivate Route, Get Route by ID)
Install
- In n8n, click Create workflow (top right).
- Click the ⋯ menu → Import from file and choose
workflow.json. Or open the file, copy everything and paste it onto the empty canvas with Ctrl/Cmd + V. - Open each node with a red warning triangle and pick or create the matching credential from the list above.
- Point these fields at your own sheets, chats and accounts:
- Deactivate Route →
base: choose your own - Deactivate Route →
table: choose your own - Send notification about deactivated route →
sendTo: choose your own - Send notification about missing route →
sendTo: choose your own - Get Route by ID →
base: choose your own - Get Route by ID →
table: choose your own
- Deactivate Route →
- Click Save.
Test it
- Click Test workflow (or Execute workflow). Gmail Trigger starts it. Trigger it once with real sample data.
- Click each node to check its output. A green tick means the step worked.
- Fix any red node: it's almost always a credential or a field that still points at a sheet or chat that isn't yours.
Go live
Toggle Active (top right). From now on it runs on its own. Check Executions in the left sidebar to see every run.
How it works, step by step
- Gmail Trigger starts the workflow (Gmail).
- When clicking ‘Test workflow’ starts the workflow (Manual).
- OpenAI Chat Model1 uses AI (OpenAI).
- Calculator1 uses AI (Tool Calculator).
- Structured Output Parser1 uses AI (Output Parser Structured).
- OpenAI Chat Model uses AI (OpenAI).
- Calculator uses AI (Tool Calculator).
- Structured Output Parser uses AI (Output Parser Structured).
- Globals reshapes the data for the next step.
- Get all labels uses Gmail to label.
- Generate Actionable Task uses AI (Agent).
- Get Summary & Meta Data uses AI (Agent).
- Filter for unprocessed mails checks a condition and routes items accordingly.
- Required labels checks a condition and routes items accordingly.
- Format Notion Page Blocks reshapes the data for the next step.
- Extract Route ID reshapes the data for the next step.
- Create Notion Page calls an external API (https://api.notion.com/v1/pages).
- Get Route by ID uses Airtable to get.
- Add Label "Processed" uses Gmail to addLabels.
- Deactivate Route uses Airtable to update.
- Active Routes Only checks a condition and routes items accordingly.
- No Operation, do nothing uses No Op.
- Send notification about deactivated route uses Gmail.
- Send notification about missing route uses Gmail.
- Add Label "Error" uses Gmail to addLabels.
Extra setup notes
These notes are also on the canvas as yellow sticky notes:
Setup
- Disable the Gmail Trigger and enable the manual trigger here
- Execute the workflow once
- Copy the Gmail Label IDs from the output of the "Required labels" node to the "Globals" node
- Disable the manual trigger here and and enable the Gmail Trigger again
- Activate the workflow, so it runs automatically in the background
Set Globals
Use the setup instructions below to retrieve the values for both errorLabelID and processedLabelID
Select Base
Select the database and the table where the "Routes" are defined
The Gmail inbox is checked every minute for new entries
Extract the Airtable Row ID from the Email address
Filter by labels to prohibit double-processing
Dynamically build request body for Notion, since dynamic auth, and content with optional fields require a custom request
The custom built request including the user specific authentication is sent to Notion to create a new Page inside of a database
The Email is processed in multiple ways:
- An actionable task is being generated based on the content, consisting of a short title, a short description and optionally a few details as bullet points
- A detailed Email summary is being generated
- Meta data is being extracted - so the user has a reference to find the original Email again
- To get more stable results, the tasks are devided between two Agents
Skip disabled routes (determined by a checkbox attribute in Airtable)
Send custom Email notifications back to sender, containing an error message and suggestions to fix it
Add labels which prevent from double-processing
Disable a checkbox attribute in Airtable which determines if a route is active
Troubleshooting
- "Credentials not found": open the node and select your credential again.
- Google "access blocked": in Google Cloud, add your email as a test user on the OAuth consent screen.
- Webhook not firing: copy the node's Production URL (not Test URL) into the other app, and make sure the workflow is Active.
- AI node errors: check your API key has billing enabled and the model name exists on your plan.
- Nothing happens on schedule: the workflow must be Active, and self-hosted n8n must stay running.
Need help?
Reply to your Morning Method order email and we'll help you get it running.
© Morning Method