Draft and approve Gmail replies with OpenAI and CustomJS

Go to Workflow
0 views
Built by CustomJS CustomJS
Created on June 07, 2026

Description

Quick Overview
This workflow drafts replies for unread Gmail messages using OpenAI, publishes a Tailwind/Alpine approval dashboard to CustomJS, and sends approved replies back through Gmail via a webhook submission.

How it works
Starts manually and pulls unread emails from Gmail (up to the configured limit).
Filters out messages whose sender contains common no-reply patterns.
Sends each remaining email’s subject, snippet, sender, and recipient to OpenAI (gpt-5) to generate a draft reply.
Combines the email metadata with the generated drafts and builds a single HTML inbox-style approval page that posts approvals back to an n8n webhook.
Uploads (upserts) the generated HTML dashboard to CustomJS as a hosted page.
Receives approved/edited reply text via the webhook, replies to the original message in Gmail using the message ID, and then marks the message as read.

Setup
Add a Gmail OAuth2 credential and select it for the Gmail read, reply, and mark-as-read steps.
Add an OpenAI API credential and ensure the selected model (gpt-5) is available in your OpenAI account.
Add a CustomJS credential and set the target page name you want to upsert (for example, “Dashboard”).
In the HTML builder code, set N8N_BASE_URL to your reachable n8n URL and switch the webhook prefix from webhook-test to webhook for production.
Activate the workflow so the “email-reply-submit” webhook endpoint can receive approvals from the hosted dashboard.

Nodes Used (3)

Code
n8n-nodes-base.code
Gmail
n8n-nodes-base.gmail
OpenAI
@n8n/n8n-nodes-langchain.openAi