Overview
Classifies emails into categories (Newsletter, Work, Family, Friends) with an LLM and applies the matching Gmail label.
This tutorial does not ship as an importable template. Build it manually by following the steps below. It needs the Google Workspace integration, which is available only on installs with a login (Supabase auth mode) or with
NODETOOL_GOOGLE_WORKSPACE=1, and a connected Google account. See Google Workspace and Email.
Demo
Workflow Steps
- Gmail Search (
nodetool.code.Code) - Importsgmail_searchfrom@nodetool-ai/sandbox-nodetool/google. It takes a Gmailquery(for exampleis:unread newer_than:7d) andmax_results(1 to 50, default 10), and returnsmessageswith subject, sender, date, and body. - Prompt (
nodetool.text.Prompt) - Formats each email into a prompt with subject, sender, and body. - Classifier (
nodetool.agents.Classifier) - Picks one of thecategoriesyou list. It takestextand a model. - Add Label (
nodetool.code.Code) - Importsgmail_modify_labelsand calls it with the message’smessage_idandadd_label_ids. Label ids come fromgmail_list_labels.
Tags
email, start
Workflow Diagram
graph TD
search["Code (gmail_search)"]
prompt["Prompt"]
classifier["Classifier"]
label["Code (gmail_modify_labels)"]
search --> prompt
prompt --> classifier
classifier --> label
search -->|message_id| label