---
title: "Categorize Mails"
description: "Local-first visual environment for building and running AI workflows. Build agents visually, deploy anywhere, privacy by design."
canonical: https://docs.nodetool.ai/workflows/categorize-mails
markdown: https://docs.nodetool.ai/workflows/categorize-mails.md
product: NodeTool
source: https://github.com/nodetool-ai/nodetool/blob/main/docs/workflows/categorize-mails.md
---

# Categorize Mails

## Overview

Classifies emails into predefined categories (Newsletter, Work, Family, Friends) using an LLM and applies matching Gmail labels.

## Demo

<video controls preload="metadata" poster="{{ '/assets/workflows/categorize-mails.jpg' | relative_url }}">
  <source src="{{ '/assets/workflows/categorize-mails.mp4' | relative_url }}" type="video/mp4">
</video>

## Workflow Steps

1. **Gmail Search** - Fetches up to 10 recent emails using the specified filters (date, subject, sender).
2. **Template** - Formats each email into a structured prompt with subject, sender, and body snippet.
3. **Classifier** - Uses an LLM to classify the email into one or more categories.
4. **Add Label** - Applies the determined label(s) to each email in Gmail.

## Tags

email, start

## Workflow Diagram

{% mermaid %}
graph TD
  template_29a39f["Template"]
  classifier_a6df08["Classifier"]
  addlabel_663354["AddLabel"]
  gmailsearch_b776a8["GmailSearch"]
  template_29a39f --> classifier_a6df08
  classifier_a6df08 --> addlabel_663354
  gmailsearch_b776a8 --> addlabel_663354
  gmailsearch_b776a8 --> template_29a39f
{% endmermaid %}
