Skip to content
NEWMarketplace and the trig8n Agent: sell what you build, and get plans and changes that are tested before you see them. See what is new

Library / Email Automation

Email Automation

Label Gmail Emails Automatically with OpenAI

When a new Gmail message arrives, OpenAI reads it, picks an existing label or creates a new one, and applies it to the message.

What it does

## Gmail labelling agent - Read the message - Read existing labels - Create a new label if needed - Assign label to message ---- Objective: Automatically categorize incoming emails based on existing Gmail labels or create a new label if none match. Tools: - Get message - Read all labels - Create label - Assign label to message Instructions: Label Matching: Analyze the email's subject, sender, recipient, keywords, and content. Compare with existing Gmail labels to find the most relevant match. Label Assignment: Assign the email to the most appropriate existing label. Remove the inbox label if the email is of less importance (like ads, promotions, aka "Reclame"), keep normal and important emails in the inbox. If no suitable label exists, create a new label based on the existing labels. Try reusing existing labels as much as possible. Always create a label as a sublabel, if no label applies, if the main label already exists, create the new label under the existing label, if no main label exists, create the label AI and create the new label under this label. Label Creation: Ensure new labels align with the structure of existing ones, including capitalization, delimiters, and prefixes. Examples: If the email subject is "Project Alpha Update," assign to [Project Alpha] if it exists. For "New Vendor Inquiry," create "Vendor Inquiry" if no relevant label exists. Outcome: Emails are consistently categorized under the appropriate or newly created labels, maintaining Gmail's organizational structure.

The steps

  1. Gmail Trigger
  2. OpenAI Chat Model1
  3. Gmail - read labels
  4. Gmail - get message
  5. Gmail - add label to message
  6. Gmail - create label
  7. Gmail labelling agent
  8. Window Buffer Memory
  9. Wait

Similar automations