Workflow

Label New Emails in Gmail

Automate email labeling in Gmail to keep your inbox organized by applying the right labels instantly as new messages arrive.

Needle Team

Last updated

October 1, 2025

Connectors used

Google Mail

Tags

Gmail AutomationEmail FiltersInbox OrganizationEmail Management

Key Takeaways

  • Automatic labeling on arrival - New emails are labeled as soon as they hit your inbox, with no manual sorting needed.
  • Uses your existing Gmail labels - The workflow reads your current label structure and assigns emails to those labels.
  • Triggered by new emails - A polling trigger watches your Gmail inbox and kicks off the workflow when new messages arrive.
  • Filters out unwanted senders - A code node lets you exclude specific senders from processing before labels are applied.

What This Workflow Does

This workflow automatically labels incoming Gmail emails by combining a new-email trigger with AI-powered label assignment. When a new email arrives, the workflow fetches recent emails and your existing Gmail labels, then applies the appropriate labels to each message based on its content. It runs continuously in the background so your inbox stays organized without you doing anything.

Use cases:

  • Keeping a busy inbox organized by auto-sorting emails into categories like work, finance, or newsletters
  • Ensuring important emails from specific senders always get flagged with the right label
  • Maintaining a consistent labeling system across a shared Google Workspace inbox

How It Works

StepWhat Happens
1. New Email TriggerA polling trigger detects new emails arriving in your Gmail inbox.
2. Find EmailsFetches the last 100 emails from Gmail.
3. Filter EmailsA code node removes unwanted senders from the list.
4. Flatten ResultsA transform node flattens the email data for processing.
5. List LabelsRetrieves all existing labels from your Gmail account.
6. Extract Label InfoA code node formats label IDs and names into a clean list.
7. MergeCombines the filtered emails with the available labels.
8. Attach LabelsA code node maps the full set of possible labels onto each email.
9. Add LabelsApplies the appropriate labels to each email in Gmail.

Workflow Nodes

NodeRole
Gmail New Email ReceivedPolling trigger that fires when new emails land in the inbox
Gmail Find EmailQueries Gmail for the last 100 emails
Code (Filter)Filters out specific senders you want to exclude
TransformFlattens nested email results into a single list
Gmail List LabelsFetches all available Gmail labels
Code (Extract Labels)Extracts label IDs and names into a structured format
MergeCombines email data with label data
Code (Attach Labels)Adds the full list of possible labels to each email object
Gmail Add Label to EmailApplies the chosen labels to each email

Setup Instructions

  1. Add the "Label New Emails in Gmail" template to your Needle workspace.
  2. Connect your Gmail account by creating a Gmail connector in Needle.
  3. Select your Gmail connector in the Find Email, List Labels, and Add Label to Email nodes.
  4. Optionally, update the filter code node to exclude or include specific senders.
  5. Publish the workflow so the trigger runs automatically.

Customization

What You Can ChangeHow
Sender filteringEdit the code node to change which senders are excluded from labeling
Number of emails fetchedChange the maxResults value in the Find Email node (default is 100)
Label assignment logicUpdate the instructions in the Add Label to Email node to adjust how labels are chosen
Inbox scopeModify the trigger's label filter to monitor specific Gmail labels instead of the full inbox

FAQ

Q: Does this workflow create new labels in Gmail? A: No. It uses your existing Gmail labels. You need to create the labels you want in Gmail first, and the workflow will assign emails to them.

Q: How quickly are emails labeled after they arrive? A: The trigger uses polling, so there may be a short delay depending on the polling interval. It is not instant but typically runs within minutes.

Q: Can I use this with Google Workspace? A: Yes. The Gmail connector works with both personal Gmail accounts and Google Workspace accounts.

Q: What happens if an email matches multiple labels? A: The Add Label to Email node can apply multiple labels to a single email based on the analysis of its content.

Want to showcase your own workflows?

Become a Needle workflow partner and turn your expertise into recurring revenue.

Try Needle today

Streamline AI productivity at your company today

Join thousands of people who have transformed their workflows.

Agentic workflowsAutomations, meet AI agents
AI SearchAll your data, searchable
Chat widgetsDrop-in widget for your website
Developer APIMake your app talk to Needle
    Needle LogoNeedle
    Like many websites, we use cookies to enhance your experience, analyze site traffic and deliver personalized content while you are here. By clicking "Accept", you are giving us your consent to use cookies in this way. Read our more on our cookie policy .