Quick Overview
This workflow monitors unread Gmail inbox messages, uses Google Gemini to classify and score each email, applies a corresponding Gmail label, logs the triage details to Google Sheets, and optionally drafts a reply in Gmail when a response is needed.
How it works
- Triggers every 5 minutes when a new unread email arrives in the Gmail inbox.
- Loads the existing triage log from Google Sheets and continues only when the incoming message has a message ID.
- Sends the sender, subject, and body text to Google Gemini to classify the email (URGENT, CAN_WAIT, NEWSLETTER, SPAM) and return structured fields like sentiment, priority score, and reply guidance.
- Maps the classification into a Gmail label ID and prepares a normalized record containing message metadata and the AI analysis.
- Adds the selected label to the email in Gmail and appends the triage record to a Google Sheets log.
- If the AI indicates a reply is needed, uses Google Gemini to draft a reply and creates a Gmail draft in the original thread.
Setup
- Connect a Gmail OAuth2 account with permission to read messages, apply labels, and create drafts.
- Connect Google Sheets using a Google service account (or update to your preferred auth method) and set the target spreadsheet and sheet for the triage log.
- Add Google Gemini (Google PaLM) API credentials and ensure the Gemini 3.1 Flash Lite model is available to your project.
- Ensure the Google Sheet has columns that match the appended fields (for example: timestamp, messageId, from, subject, category, needsReply, priorityScore, sentiment, summary, replyGuidance).