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 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, i...

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

  1. Runs manually to fetch unread messages from Gmail.
  2. Filters out messages from common no-reply senders to avoid automated emails.
  3. Uses OpenAI (GPT-5) to generate a draft reply from the email subject, snippet, sender, and recipient.
  4. Compiles the original emails and AI drafts into a single HTML approval dashboard and publishes it as a CustomJS page.
  5. Receives an approval submission from the dashboard via an n8n webhook containing the edited reply text plus the Gmail message and thread IDs.
  6. Replies to the original Gmail message with the approved text and then marks the message as read.

Setup

  1. Connect Gmail OAuth2 credentials for the Gmail nodes that read messages, reply, and mark messages as read.
  2. Add an OpenAI API credential and select the model you want to use for draft generation.
  3. Add your CustomJS credentials and confirm the target page name used to publish the dashboard.
  4. 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.
  5. Activate the workflow so the webhook can receive approval submissions 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/16026/16026.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 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, i...

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.