← All N8N workflows
AI & researchCodeGmailHTTP RequestLimitMarkdown

Reply draft with OpenAI Assistant

Configured with Gmail, HTTP Request, Limit, Markdown, and additional nodes. Review the connections and setup before adapting this template.

Workflow preview
MessagingRemove AI label fromemailGmailWeb / APIAdd email draft tothreadHTTP RequestCodeConvert raw to base64CodeTransformBuild email rawEdit FieldsTransformConvert response toHTMLMarkdownTransformMap fields for furtherprocessingEdit FieldsAI & modelsAsk OpenAI AssistantOpen AiMessagingGet single messagecontentGmailTransformReturn last message inthreadLimitMessagingGet thread messagesGmailRoutingLoop over threadsLoop Over ItemsMessagingGet threads withspecific labelsGmailTriggerSchedule trigger (1min)Schedule Trigger

Node categories in this workflow

  • Messaging
  • Web / API
  • Code
  • Transform
  • AI & models
  • Routing
  • Trigger

Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.

Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.

How it works

The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.

Workflow node names, types, and operations
NodeCategoryTypeOperation
Remove AI label from emailMessagingGmailthread / removeLabels
Add email draft to threadWeb / APIHTTP RequestPOST
Convert raw to base64CodeCodeSee node parameters
Build email rawTransformEdit FieldsSee node parameters
Convert response to HTMLTransformMarkdownSee node parameters
Map fields for further processingTransformEdit FieldsSee node parameters
Ask OpenAI AssistantAI & modelsOpen Aiassistant
Get single message contentMessagingGmailget
Return last message in threadTransformLimitSee node parameters
Get thread messagesMessagingGmailthread / get
Loop over threadsRoutingLoop Over ItemsSee node parameters
Get threads with specific labelsMessagingGmailthread
Schedule trigger (1 min)TriggerSchedule TriggerSee node parameters

Setup

  1. Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
  2. Connect your own credentials through n8n’s credential store. Replace REPLACE_WITH_* values with your resource identifiers.
  3. Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
  4. Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.

Requirements

An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.

Credential types declared in the source

  • gmailOAuth2
  • openAiApi

Workflow notes

Reply draft with OpenAI Assistant

Reply draft with OpenAI Assistant

This workflow automatically transfers content of incoming email messages with specific labels into OpenAI Assitant and returns reply draft. After draft is composed, trigger label is deleted from the thread.

Please remember to configure your OpenAI Assistant first.

Schedule trigger and get emails

Schedule trigger and get emails

Run the workflow in equal intervals and check for threads with specific labels (trigger labels).

⚠️ Note

⚠️ Note

  1. Complete video guide for this workflow is available on my YouTube.
  2. Remember to add your credentials and configure nodes (covered in the video guide).
  3. If you like this workflow, please subscribe to my YouTube channel and/or my newsletter.

Thank you for your support!

Generate reply

Generate reply

Transfer email content to OpenAI Assitant and return AI-generated reply.

Create HTML message

Create HTML message

Convert incoming Markdown from OpenAI Assistant into HTML content.

Build and encode message

Build and encode message

Create raw message in RFC standard and encode it into base64 string (please see Gmail API reference for more details).

Insert reply draft

Insert reply draft

Add reply draft from OpenAI Assistant to specific Gmail thread.

Remove label

Remove label

Delete trigger label from the Gmail thread.

Return message content

Return message content

Retrieve content of the last message in the thread.

Get last message from thread

Get last message from thread

Return all messages for a single thread and pass for further processing only the last one.

Reply draft with OpenAI Assistant

Reply draft with OpenAI Assistant

Purpose and structure

This folder contains the Reply draft with OpenAI Assistant workflow. Its executable nodes use code, gmail, httpRequest, limit, markdown, openAi, scheduleTrigger, set, splitInBatches. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.

Setup

Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.

Entry points

Schedule trigger (1 min)

Verification

Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.

Attribution

https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Limit/0473_Limit_Code_Create_Scheduled.json MIT; preserve source notices.

More in AI & research