Reads unread inbox mail every hour and applies your own labels to each message using AI.
Uses
Claude
Gmail
Auto-label new Gmail messages with AI
Every hour, the workflow reads the unread mail sitting in your Gmail inbox and sorts it using labels you describe in plain English, such as one for invoices, one for candidate outreach and one for newsletters. The AI reads each message's sender, subject and preview against your rules and picks exactly one label, which is then applied to the message.
You end up with an inbox where new mail already carries the right label, and labels are created in Gmail the first time they are used. A message that matches none of your rules is left untouched rather than pushed into the nearest category, so the labels you do see stay trustworthy. A message that cannot be processed is noted in the run log and skipped, and the rest of the batch still goes through. Nothing is archived, moved or replied to: labels are added and that is all.
labelRules to blank.Set labelRules to blank.maxEmails to 25.Set maxEmails to 25.inbox.List emails. Save it as inbox.messages to inbox.emails.Set messages to inbox.emails.email in messages:For each email in messages:labelErrorIf a step below fails, save the error as labelErrorsubject to email.subject.Set subject to email.subject.sender to email.from.Set sender to email.from.snippet to email.snippet.Set snippet to email.snippet.prompt to You are labelling one email. Reply with EXACTLY one label name from the rules below, and nothing else. If none of them fit, reply with the single word none.Set prompt to You are labelling one email. Reply with EXACTLY one label name from the rules below, and nothing else. If none of them fit, reply with the single word none.
Rules:
labelRules
From: sender
Subject: subject
Preview: snippet.prompt. Save it as verdict.Ask Claude: prompt. Save it as verdict.
Maximum response length: 16verdict.response_text and save it as label.Trim verdict.response_text and save it as label.label isn't empty and label is not noneIf label isn't empty and label is not nonelabel to email email.Add label label to email email.email.id as text: labelError as text.Show in the output: Could not label message email.id as text: labelError as text.