Quick overview
This workflow triggers on new Gmail messages, sends key email details to OpenAI for classification, parses the JSON result, and applies a matching Gmail label to each email based on the predicted category.
How it works
- Triggers every minute when a new email arrives in Gmail.
- Sets the OpenAI model, a classification prompt, and a mapping of categories to Gmail label IDs.
- Calls the OpenAI Chat Completions API with the email subject, sender, and a truncated body to classify the message.
- Parses the JSON response to extract category, urgency, and a short summary, defaulting to “noise” if parsing fails.
- Adds the corresponding Gmail label to the original email message based on the returned category.
Setup
- Connect your Gmail account credentials for both the Gmail trigger and the Gmail label action.
- Add an OpenAI API key using HTTP Header Auth for the OpenAI Chat Completions request.
- Create the target labels in Gmail, copy their label IDs, and replace the placeholder values in the category-to-label mapping.
Additional info
This is the lite version. A fuller build adds a Google Sheets log of every email, AI-drafted replies to new enquiries, and instant alerts when something urgent lands, along with a step by step setup guide. Available at baynhams.gumroad.com/l/inbox-triage