Quick overview
This workflow polls a Gmail inbox, filters out auto-replies and bounce emails, classifies real enquiries with an OpenAI-compatible chat model, validates and sanitizes the AI output, and appends each enquiry as a structured row in Google Sheets.
How it works
- Triggers every 15 minutes and fetches emails from Gmail regardless of read status.
- Filters out common machine-generated messages (such as out-of-office replies and delivery failures) and normalizes sender, reply-to, subject, body, and a short excerpt.
- Sends the email content to the OpenAI Chat Completions API to generate a JSON classification (category, priority, sentiment, language, summary, and recommended action).
- Validates the AI JSON against allowed values, escalates to high priority and records substituted fields when output is missing or out of range, and sanitizes text to prevent Google Sheets formula injection.
- Appends one row per enquiry to a Google Sheets spreadsheet with the received time, sender details, AI classification, and excerpt.
Setup
- Connect your Gmail account credential and confirm the polling interval and search query settings in the Gmail trigger.
- Add an OpenAI API credential (or compatible provider) and ensure the model name in the Settings step matches a model available to your account.
- Connect your Google Sheets credential, select the target spreadsheet and sheet, and create the header row with the required columns in the expected order before mapping fields.