Quick overview
This workflow monitors unread Gmail messages, uses Groq’s Chat Completions API (LLama 3.3) to classify and draft replies, routes key emails to Slack or Gmail labels, logs triage details to Google Sheets, and sends a separate Gmail alert when an email is marked Critical.
How it works
- Triggers every minute when a new unread Gmail message arrives that does not already have the AI-Processed label.
- Extracts and normalizes key email fields (sender, subject, snippet, message ID, and thread ID) for consistent processing.
- Sends the email content to Groq’s Chat Completions API to return a JSON triage result (urgency, category, intent, summary, action, route, and an optional reply draft).
- Routes the message based on the AI-selected destination by posting a summary to Slack (#incidents or #sales) or applying predefined Gmail labels.
- If the AI provides a draft and the route indicates replying directly, sends a reply via Gmail.
- Appends the triage outcome (classification fields, summary, action, routing, and IDs) to a Google Sheets “Triage Log” worksheet.
- If the logged urgency is Critical, sends a separate critical alert email via Gmail to a configured address.
Setup
- Connect your Gmail OAuth2 account and confirm/create the Gmail label used by the trigger query (AI-Processed) and the label IDs used for Gmail label application.
- Add an HTTP Header Auth credential containing your Groq API key (Authorization header) and confirm the model endpoint settings.
- Connect your Slack OAuth credential and ensure the target channels (#incidents and #sales) exist or update the workflow to use your channel names.
- Connect your Google Sheets OAuth credential and update the spreadsheet ID and sheet tab used for the “Triage Log”, ensuring the expected columns exist.
- Update the recipient address for the critical alert email and verify the “reply to” target mapping matches how your Gmail trigger exposes the sender address.