Quick Overview
This workflow monitors a Gmail inbox for client emails, looks up the client’s statement of work in Google Docs, uses OpenAI to classify requests as in-scope or scope creep, logs each request to Google Sheets, and notifies your team in Slack while saving a change-order reply as a Gmail draft.
How it works
- Triggers every minute on new emails in a Gmail inbox matching the configured search query.
- Extracts the sender domain, ignores emails from unmapped domains, and associates matched domains with the correct SOW Google Docs URL.
- Fetches the client’s current SOW content from Google Docs and sends it with the email content to OpenAI to return a structured verdict, clause citation, effort estimate, and draft reply.
- Drops messages classified as not_a_request and prepares a log record with estimated hours and value based on your hourly rate.
- Appends the request details and verdict to a Google Sheets tab named “Scope Log” including a direct Gmail thread link.
- If the verdict is out_of_scope or unclear, posts an alert to a Slack channel and creates a Gmail draft reply in the same thread; otherwise it only logs the in-scope request.
Setup
- Connect credentials for Gmail, Google Docs, Google Sheets, Slack, and OpenAI (ChatGPT/OpenAI API) in n8n.
- Update the client_sow_map JSON to map each client email domain to its SOW Google Docs URL.
- Create or select a Google Sheet and set its ID in sheet_id, and ensure a tab named “Scope Log” exists with the expected columns (checked_at, client_domain, from_email, subject, request_summary, verdict, matching_clause, estimated_hours, estimated_value, thread_link).
- Set your hourly_rate, currency, Slack channel name, and sign_off_name in the configuration values.
- Adjust the Gmail search query in the trigger if you want to monitor a different label, shared inbox, or filtering rule.