Quick overview
This workflow monitors unread Gmail messages, drafts a reply with OpenAI, checks the draft against Orvanta guardrails (with optional approval and a pause/deny control), and then replies in the original email thread while logging the final outcome back to Orvanta.
How it works
- Polls Gmail every minute for unread messages in the inbox.
- Filters out automated senders (for example, noreply/no-reply/mailer-daemon) to avoid replying to system emails.
- Uses OpenAI to draft a short, friendly, factual reply to the customer email based on a defined system prompt.
- Sends the customer email text and the drafted reply to Orvanta for a policy check and receives an allow/needs approval/deny decision (with a callback URL to resume the workflow when needed).
- If allowed, replies to the original Gmail thread immediately and logs the sent reply to Orvanta.
- If approval is required, waits up to 24 hours for an Orvanta webhook, then sends the approved (possibly edited) reply or does nothing if declined/timed out.
- If denied or paused, stops without sending any email.
Setup
- Connect your Gmail account for the Gmail trigger and reply actions.
- Add an OpenAI credential and select the model you want to use (the template uses gpt-4o-mini).
- Create an Orvanta agent, then configure an HTTP Header Auth credential (Authorization: Bearer <your key>) for both Orvanta HTTP requests.
- Ensure your n8n instance is reachable over HTTPS so Orvanta can POST to the wait/resume webhook for approvals.
- Review Orvanta rules for when replies are allowed versus requiring approval or being denied/paused, and adjust the drafting system prompt to match your support policy.
Requirements
- An Orvanta account (orvantahq.io) with an agent created for this workflow
- Gmail and OpenAI credentials
- An n8n instance reachable over HTTPS (n8n Cloud works)
Customization
- Swap Gmail for Outlook or a helpdesk, or OpenAI for Claude or Gemini
- Edit the system prompt in “Draft the reply” to match your tone and support policy
- In Orvanta, add rules such as “No customer email between 10 pm and 7 am” or “I approve what’s sensitive”