Skip to main content

Draft and approve Gmail replies with OpenAI and CustomJS

Workflow preview

Workflow preview
100%
Draft and approve Gmail replies with OpenAI and CustomJS preview
Open on n8n.io

1. Workflow Overview

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 w...

Best for

  • Ticket Management automation workflows
  • AI Chatbot automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.manualtrigger, @custom-js/n8n-nodes-pdf-toolkit-v2.pdftoolkit, n8n-nodes-base.stickynote, n8n-nodes-base.gmail, n8n-nodes-base.webhook, n8n-nodes-base.code, @n8n/n8n-nodes-langchain.openai

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by CustomJS.

Original n8n.io source

1.1 Workflow description

Title
Draft and approve Gmail replies with OpenAI and CustomJS
Workflow name
Draft and approve Gmail replies with OpenAI and CustomJS

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

  1. Starts manually and pulls unread emails from Gmail (up to the configured limit).
  2. Filters out messages whose sender contains common no-reply patterns.
  3. Sends each remaining email’s subject, snippet, sender, and recipient to OpenAI (gpt-5) to generate a draft reply.
  4. 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.
  5. Uploads (upserts) the generated HTML dashboard to CustomJS as a hosted page.
  6. 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

  1. Add a Gmail OAuth2 credential and select it for the Gmail read, reply, and mark-as-read steps.
  2. Add an OpenAI API credential and ensure the selected model (gpt-5) is available in your OpenAI account.
  3. Add a CustomJS credential and set the target page name you want to upsert (for example, “Dashboard”).
  4. 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.
  5. Activate the workflow so the “email-reply-submit” webhook endpoint can receive approvals from the hosted dashboard.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - When clicking 'Execute workflow'

Type / Role
n8n-nodes-base.manualTrigger - manualTrigger
Config choices
Version 1

Block 2 - Upsert Approval Page

Type / Role
@custom-js/n8n-nodes-pdf-toolkit-v2.pdfToolkit - pdfToolkit
Config choices
Version 1

Block 3 - Sticky Note Overview

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 4 - Sticky Note Email

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 5 - Sticky Note AI

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 6 - Sticky Note Host

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 7 - Get many messages

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.2

Block 8 - Webhook - Receive Approval

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 1

Block 9 - Extract Reply Data

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 10 - Lane 2 Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 11 - Filter No Reply Emails

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 12 - Generate AI Draft Reply

Type / Role
@n8n/n8n-nodes-langchain.openAi - openAi
Config choices
Version 2.1

Block 13 - Format Email Drafts

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 14 - Build Approval Page

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 15 - Reply to a message

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.2

Block 16 - Mark a message as read

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.2

3. Summary Table

Workflow Draft and approve Gmail replies with OpenAI and CustomJS
Complexity advanced
Nodes 16
Categories Ticket Management, AI Chatbot
Author CustomJS
Published 30 May 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/16027/16027.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Draft and approve Gmail replies with OpenAI and CustomJS do?

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 w...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Ticket Management, AI Chatbot use case.