See llms.txt for all machine-readable content.

Back to Templates

Reply to customer emails with Gmail, OpenAI and Orvanta approvals

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

  1. Polls Gmail every minute for unread messages in the inbox.
  2. Filters out automated senders (for example, noreply/no-reply/mailer-daemon) to avoid replying to system emails.
  3. Uses OpenAI to draft a short, friendly, factual reply to the customer email based on a defined system prompt.
  4. 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).
  5. If allowed, replies to the original Gmail thread immediately and logs the sent reply to Orvanta.
  6. 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.
  7. If denied or paused, stops without sending any email.

Setup

  1. Connect your Gmail account for the Gmail trigger and reply actions.
  2. Add an OpenAI credential and select the model you want to use (the template uses gpt-4o-mini).
  3. Create an Orvanta agent, then configure an HTTP Header Auth credential (Authorization: Bearer <your key>) for both Orvanta HTTP requests.
  4. Ensure your n8n instance is reachable over HTTPS so Orvanta can POST to the wait/resume webhook for approvals.
  5. 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”