---
title: "Auto-Summarize Your Gmail Inbox Every Morning with n8n"
description: "Build an n8n workflow that reads your Gmail, ranks urgent emails with AI, and delivers a daily digest to Slack or Telegram. AI credits included — no BYOK."
canonical: https://agentroost.app/en/blog/gmail-daily-summary-n8n-ai
date: 2026-06-12T20:00:00Z
---

[Canonical URL](https://agentroost.app/en/blog/gmail-daily-summary-n8n-ai)

# Auto-Summarize Your Gmail Inbox Every Morning with n8n

Your inbox accumulates 40–80 emails overnight. By the time you've triaged them it's 9:30 AM and you haven't done a single thing that actually mattered. This workflow fixes that: at 7:00 AM every day, n8n pulls your unread Gmail, an AI node reads every subject and snippet, ranks what's genuinely urgent, and posts a 10-line briefing to wherever you're already looking — Slack, Telegram, whatever.

You'll build it once. It runs every day on its own. Here's exactly how.

---

## What the Workflow Does

1. A **Schedule Trigger** fires at 07:00 every morning.
2. A **Gmail** node (OAuth2) fetches unread messages from the last 18 hours.
3. A **Code** node formats the emails into a structured prompt (sender, subject, first 200 characters of body).
4. An **AI / LLM node** (Basic LLM Chain) classifies and summarizes: "Needs reply today", "FYI only", "Can ignore".
5. A **Set** node shapes the output into a clean digest string.
6. A **Slack** or **Telegram** node posts the briefing.

Total nodes: 6. Build time: ~25 minutes.

---

## Step-by-Step Build

### 1. Schedule Trigger

Drop in a **Schedule Trigger** node. Set:

- **Trigger Interval**: `Days`
- **Hour**: `7`
- **Minute**: `0`

This fires once per day. If you want weekdays only, add an **IF** node right after that checks `{{ $now.weekday >= 1 && $now.weekday <= 5 }}` and routes only the `true` branch forward. (In n8n, `$now.weekday` is a Luxon property — 1 is Monday, 7 is Sunday.)

### 2. Gmail Node — Fetch Unread Mail

Add a **Gmail** node set to **Get Many** messages. Config:

```
Operation:      Get Many
Filters:
  Read Status:  Unread
  Received After: {{ $now.minus({hours: 18}).toISO() }}
Limit:          50
Return All:     false
```

Connect your Gmail account via OAuth2 — n8n will prompt you to authorize once; after that it reuses the token silently.

> **Tip:** Set the date filter to 18 hours (not 24) so you don't double-count emails from the previous summary if you run it slightly late one morning.

### 3. Code Node — Build the Prompt

An **AI node** needs the emails formatted as a single string. Use a **Code** node (JavaScript) to collapse the array:

```js
const emails = $input.all();

const formatted = emails.map((item, i) => {
  const e = item.json;
  const snippet = (e.snippet || '').slice(0, 200);
  return `[${i + 1}] From: ${e.from} | Subject: ${e.subject}\n${snippet}`;
}).join('\n\n');

return [{ json: { emailBlock: formatted, count: emails.length } }];
```

This gives the AI a clean numbered list — much cheaper on tokens than sending raw MIME.

### 4. AI / LLM Node — Summarize and Rank

Add a **Basic LLM Chain** node. Connect it to the **Code** node's output.

In the **Prompt** field, use an expression like:

```
You are an executive assistant. Below are {{ $json.count }} unread emails from the last 18 hours.

Classify each as one of:
- URGENT: needs a reply or action today
- FYI: worth reading, no action
- NOISE: newsletters, notifications, can skip

Then write a 5–10 line morning briefing, starting with the URGENT items. Be concise.

Emails:
{{ $json.emailBlock }}
```

Leave **Model** at the default (the node will use whatever model is configured in your n8n credentials). On AgentRoost, those credentials already point to the included AI pool — no API key needed, no separate AI bill at the end of the month.

### 5. Set Node — Shape the Output

Add a **Set** node to extract just the AI's text for the next step:

```
Field:  digest
Value:  {{ $json.text }}
```

### 6. Deliver the Digest

**Option A — Slack:**
Add a **Slack** node, action **Send a Message**. Set:
- Channel: `#inbox-digest` (or any private channel)
- Message: `*Morning inbox briefing — {{ $now.toFormat('EEE d MMM') }}*\n\n{{ $json.digest }}`

**Option B — Telegram:**
Add a **Telegram** node, action **Send Message**. Use your bot credentials and paste the same message template. If you're on AgentRoost and also have a Hermes or OpenClaw agent, your Telegram bot is already provisioned — you can route to it directly.

---

## Pitfalls and Tips

**Gmail OAuth scopes.** When authorizing, make sure `gmail.readonly` is included. n8n's Gmail OAuth2 credential requests it by default, but if you set up a custom Google Cloud app, verify it's listed under scopes.

**Large inboxes.** If you regularly get 100+ emails overnight, the prompt will get long. Add a **Limit** node or pre-filter in the Gmail node with `label:important` so only starred/important mail goes to the AI.

**AI node "no output" errors.** These usually mean the model returned an empty response because the prompt was too long. Add a **Code** node before the AI that truncates `emailBlock` to 4000 characters if `emailBlock.length > 4000`.

**Credentials refresh.** Gmail OAuth tokens expire. n8n handles the refresh automatically as long as the workflow runs at least once every 7 days. The Schedule Trigger ensures this — just don't pause the workflow for a week or your token goes stale.

**Testing without waiting until 7 AM.** Click **Test Workflow** in the editor. The Schedule Trigger will fire immediately in test mode; you'll see the live Gmail data and the AI summary right in the canvas.

---

## How to Run This on AgentRoost

Here's what running this yourself on a VPS looks like: spin up a $6/mo server, install Node, install n8n, configure a process manager, set up SSL, sort out an OpenAI API key, watch the monthly AI bill, and remember to renew the server. The workflow itself takes 25 minutes — the plumbing takes a day.

On AgentRoost, you skip the plumbing entirely:

1. **Sign up** at [agentroost.app](/en/agents/n8n) — email, Google, Microsoft, or Discord.
2. **Pick the n8n framework** and name your instance (e.g., `morning-digest`).
3. Your private n8n editor opens at `https://morning-digest.agentroost.app` — it's yours. You own the login, the data, the workflows.
4. **Build the 6-node workflow above.** When you reach the AI node, the credentials are already wired to included AI credits. No API key dialog.
5. **Activate** the workflow. Done.

The instance runs 24/7 on dedicated hardware. The AI node works from day one because the LLM credits are included in the subscription — no separate OpenAI account, no bring-your-own-key. Plans start at **$19.99/mo all-in**, with a 14-day money-back guarantee and no annual lock-in.

[Get started — pick the n8n plan →](/en/agents/n8n)

---

## Extending the Workflow

Once the basic digest is running, a few natural next steps:

- **Reply drafts.** Add a second AI node that outputs a draft reply for each URGENT email, then use the Gmail node's **Reply** action to save them as drafts.
- **Calendar context.** Add a **Google Calendar** node before the AI step. Inject today's meetings into the prompt so the AI can flag emails that conflict with or relate to scheduled calls.
- **Filtering by sender.** Add an **IF** node after the Gmail fetch to split VIP senders (your boss, key clients) into a priority lane — the AI sees those first and flags them explicitly.
- **Weekly summary.** Duplicate the workflow, change the Schedule Trigger to every Monday at 8 AM, and adjust the prompt to ask for a week-in-review instead of a morning briefing.
