Quick Overview
This workflow pulls unread Gmail messages, generates draft replies with OpenAI, and publishes an approval dashboard via CustomJS. When you approve or edit a draft in the dashboard, it posts back to a webhook that sends the reply in Gmail and marks the original message as read.
How it works
- Runs manually to fetch unread messages from Gmail.
- Filters out messages from common no-reply senders to avoid automated emails.
- Uses OpenAI (GPT-5) to generate a draft reply from the email subject, snippet, sender, and recipient.
- Compiles the original emails and AI drafts into a single HTML approval dashboard and publishes it as a CustomJS page.
- Receives an approval submission from the dashboard via an n8n webhook containing the edited reply text plus the Gmail message and thread IDs.
- Replies to the original Gmail message with the approved text and then marks the message as read.
Setup
- Connect Gmail OAuth2 credentials for the Gmail nodes that read messages, reply, and mark messages as read.
- Add an OpenAI API credential and select the model you want to use for draft generation.
- Add your CustomJS credentials and confirm the target page name used to publish the dashboard.
- Set your n8n base URL and choose the correct webhook path prefix (test vs production) in the dashboard HTML so submissions reach your webhook endpoint.
- Activate the workflow so the webhook can receive approval submissions from the hosted dashboard.