Quick overview
This workflow monitors a Gmail inbox for new unread emails, uses Google Gemini to classify whether each message is critical during out-of-office coverage, and for critical items alerts a backup on Slack, replies to the sender via Gmail, logs the escalation to Google Sheets, and labels the email.
How it works
- Triggers every minute when a new unread email arrives in Gmail (excluding Promotions and Social categories).
- Extracts key fields from the email (sender, subject, snippet, message ID, and thread ID) and loads out-of-office routing settings.
- Sends the email details to the Google Gemini API and parses the JSON response to determine whether the message is critical, along with a category, urgency reason, and Slack-ready summary.
- If the email is critical, posts an escalation message to a specified Slack channel and mentions the designated backup person.
- Replies to the sender in Gmail with an out-of-office message that loops in the backup contact.
- Appends the escalation details to a Google Sheets log and adds a Gmail label to the original message.
- If the email is not critical, it takes no further action.
Setup
- Connect Gmail OAuth2 credentials for both the inbox trigger and the Gmail reply/label actions.
- Add Google Gemini (PaLM) API credentials for the HTTP request to the Gemini generateContent endpoint.
- Connect Slack OAuth credentials and set the target Slack channel ID and backup Slack user ID used for mentions.
- Connect Google Sheets credentials (service account) and update the spreadsheet document ID, sheet/tab, and column headers used for logging.
- Update the workflow’s configuration values (backup name/email, company/product name, return date, and the Gmail label ID to apply to escalated emails).