ChatGPTWorkInbox & emailAI score · 83/100AI-assisted edit · no obvious prompt-injection riskn8n.io

n8n Automated Multilingual Gmail Draft Reply with GPT-4o

Gmail label trigger → GPT-4o assess & detect language → branch to generate Japanese/English draft → save as Gmail reply draft

Some experienceStepsWorkflowPromptTip
Who
Customer support or business users handling a high volume of multilingual Gmail inquiries who want to reduce manual drafting
You get
When a new email with a specified label arrives, automatically assess whether a reply is needed, detect the language, and generate a draft reply in that language saved into the original thread
You need
n8n · gmail

Constraints

Prerequisites: accessible n8n instance; Gmail OAuth2 credential; OpenAI API credential. Create and apply a Gmail label (e.g., Inquiry) to target emails beforehand. The workflow polls for new messages with that label, defaulting to every minute. The template currently includes Japanese and English branches; expanding to additional languages requires adding Switch rules and corresponding generation-node system prompts.

What they did

Author henry published this workflow template in the n8n official template library. The template demonstrates an end-to-end flow: a Gmail Trigger polls for new emails with a specific label, GPT-4o assesses whether a reply is needed and detects the language, a Switch node routes by Japanese or English, two separate LLM Chain nodes generate culturally appropriate draft replies, and a Gmail node converts the text to HTML and saves it as a reply draft in the original thread.

How it went

The template shows as published on n8n (status: published) with 2,523 total views at time of collection (author_report). No specific reply accuracy, user satisfaction, or ROI figures are provided by the source.

Worth knowing

This site has not tested the workflow (reproduction=not_tested). Production deployment requires valid Gmail OAuth2 and OpenAI API credentials; GPT-4o calls incur costs. The template currently includes only Japanese and English branches; additional languages require extending Switch rules and authoring corresponding system prompts. Prompts contain hardcoded salutation placeholders that must be replaced for actual use. Marketing emails are explicitly excluded from auto-reply (needsReply=false). Polling frequency affects response latency and API cost; adjust to your volume.

n8n workflow template

Structure checked · Not run-tested

Use “Import from File” in n8n, or copy the JSON and paste it into the editor. Connect your own accounts, then try test data. The template is inactive by default.

Setup and test checklist

Credentials to connect

  • Connect the same test Gmail account to Gmail trigger and Gmail - Create Draft using OAuth2.
  • Connect your OpenAI API credentials to all three GPT-4o model nodes. Email content is sent to this service.

Configuration to replace

  • The source Gmail trigger has an empty filters.q, which is too broad for an initial test. Create a dedicated label in a test mailbox and set the Search query to label:your-label before enabling it.
  • Polling defaults to every minute. Only Japanese and English routes exist; other languages fall back to English. Add routes and prompts to support more languages.
  • Replace the company, personal and client placeholders in the Japanese prompt. Parser Result defines an array while later expressions read top-level needsReply/message_language; inspect the actual shape step by step and fix your copy if parsing fails.

Test input and expected output

  • Send one tagged English or Japanese test inquiry. Fetch one test email and inspect needsReply, message_language, the selected branch and generated draft.
  • Verify the draft recipient, subject and original threadId. The template creates a draft; it has no automatic send node. Review manually before sending.
  • Use a marketing test message to verify the false branch. Avoid bulk tests with real customer mail.

Template changes

  • Author credential bindings, instance metadata and execution data are removed; the workflow is inactive. Nodes, connections and original prompts are preserved. Not run-tested in n8n.
  • No labels were added automatically, and routing, parser and prompts were not rewritten. Check the documented source configuration differences before running.

Template retrieved: 2026-10-24

Steps

  1. Configure the Gmail trigger

    Add a Gmail Trigger node in n8n and connect your Gmail OAuth2 credential. In Gmail, apply a label (e.g., Inquiry) to target emails and configure the same label filter in the node. Note: the source trigger's Search query (filters.q) is empty, so it applies no label filter and the scope is too broad; before the first test, create a dedicated test label in a test mailbox and set filters.q to label:your-test-label, then run the test. Adjust the polling interval (pollTimes) as needed. The trigger outputs fields including subject, textAsHtml, headers.from, and threadId for downstream use.

  2. Assess the email and identify language

    Add a Basic LLM Chain node (Assess if a message needs a reply and identify the language), connect an OpenAI GPT-4o model node (model=gpt-4o, temperature=0, responseFormat=json_object), and a Structured Output Parser node. In the LLM Chain, set the prompt field to the email subject and body; in messages, place the system prompt asking the model to return needsReply (boolean) and message_language (English / Japanese / Other) as JSON. The Parser’s JSON Schema must require needsReply and message_language.

    Execution prompt · Source text。Basic LLM Chain node prompt field (email content input)

    =Subject: {{ $json.subject }}
    Message:
    {{ $json.textAsHtml }}

    Execution prompt · Source text。Basic LLM Chain node messages.messageValues[0].message (system prompt)

    Your task is to :
    - identify the language of the message and set the value to field "message_language" : "English", "Japanese" or "Other"
    - assess if the message requires a response and set the value to field "needsReply" : true if it does, false otherwise.
    Return in JSON format.
    Marketing emails don't require a response.

    Execution prompt · Source text。Structured Output Parser node jsonSchema field

    ={
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "needsReply": {
            "type": "boolean"
          },
          "message_language": {
            "type": "string"
          }
        },
        "required": ["needsReply", "message_language"]
      }
    }
  3. Branch by detected language

    Add an If node to check whether needsReply is true; if true, route to a Switch node. The Switch branches on message_language: equals Japanese goes to the Japanese branch, equals English goes to the English branch. fallbackOutput is set to 1 (English). To add more languages, create additional rules in the Switch and connect corresponding generation nodes.

  4. Generate a draft reply in the detected language

    On the Japanese branch, place a Basic LLM Chain node (Generate email for a Japanese client); on the English branch, place another (Generate email reply for an English client). Each connects to its own OpenAI GPT-4o model sub-node. In both nodes, the text field references the Gmail trigger’s subject and textAsHtml; the messages field contains the Japanese or English system prompt defining tone, salutation, closing, placeholder rules, and yes-no dual-response format.

    Execution prompt · Source text。Generate email for a Japanese client and Generate email reply for an English client nodes text field (email content input)

    =Subject: {{ $('Gmail trigger').item.json.subject }}
    Message: {{ $('Gmail trigger').item.json.textAsHtml }}

    Execution prompt · Source text。Generate email for a Japanese client node messages.messageValues[0].message (Japanese generation system prompt)

    You're a helpful personal assistant and your task is to draft replies on my behalf to my incoming emails. Whenever I provide some text from an email, return an appropriate draft reply for it and nothing else.
    Ensure that the reply is suitable for a professional email setting and addresses the topic in a clear, structured, and detailed manner.
    Do not make things up.
    
    Detailed instructions:
    - Be concise and maintain a business tone (desu-masu).
    - Follow the following content 
    [INSERT CLIENT NAME] 様
    お世話になっております。
    株式会社 [INSERT YOUR COMPANY NAME] の[INSERT YOUR NAME]です。
    
    BODY (main content)
    
    引き続き、何卒どうぞ宜しくお願いいたします。
    
    - When replying to yes-no questions, draft 2 responses: one affirmative and one negative separated by " - - - - - - - OR - - - - - - - "
    - If you don't know an answer, you can leave placeholders like "[YOUR_ANSWER_HERE]".
    - Don't use any special formatting, only plain text.
    - Make sure each request is separated with a new line break
    - Reply in the same language as the inbound email.

    Execution prompt · Source text。Generate email reply for an English client node messages.messageValues[0].message (English generation system prompt)

    You're a helpful personal assistant and your task is to draft replies on my behalf to my incoming emails. Whenever I provide some text from an email, return an appropriate draft reply for it and nothing else.
    Ensure that the reply is suitable for a professional email setting and addresses the topic in a clear, structured, and detailed manner.
    Do not make things up.
    
    Detailed instructions:
    - Be concise and maintain a business casual tone.
    - Start with "Dear,", and end with "Best regards,"
    - When replying to yes-no questions, draft 2 responses: one affirmative and one negative separated by " - - - - - - - OR - - - - - - - "
    - If you don't know an answer, you can leave placeholders like "[YOUR_ANSWER_HERE]".
    - Don't use any special formatting, only plain text.
    - Reply in the same language as the inbound email.
  5. Save as a Gmail reply draft

    Add a Gmail node (Gmail - Create Draft), set resource to draft and emailType to html. The message field replaces newlines with <br />\n; the subject prefixes Re: and references the original subject; options.sendTo references the original sender and options.threadId references the original thread ID so the draft appears as a reply. Connect your Gmail OAuth2 credential.

    Execution prompt · Source text。Gmail - Create Draft node message field (HTML conversion)

    ={{ $json.text.replace(/\n/g, "<br />\n") }}

    Execution prompt · Source text。Gmail - Create Draft node subject field

    =Re: {{ $('Gmail trigger').item.json.headers.subject }}

    Execution prompt · Source text。Gmail - Create Draft node options.sendTo field

    ={{ $('Gmail trigger').item.json.headers.from }}

    Execution prompt · Source text。Gmail - Create Draft node options.threadId field

    ={{ $('Gmail trigger').item.json.threadId }}

Prompt you can copy

Setup guidance · Editorial suggestion。Hand to setup assistant; confirm inputs and permissions first

This block is the prompt. Ads are never placed here.

Import template 4870 into n8n, connect Gmail OAuth2 and OpenAI API credentials, confirm the label name and polling interval, then activate the workflow. For the first run, test with a single email to verify language detection and draft generation.

Create and apply the target label in Gmail before activation. Replace [INSERT CLIENT NAME], [INSERT YOUR COMPANY NAME], and [INSERT YOUR NAME] in the Japanese/English prompts with actual values or variable references.

Source

Automated multilingual Gmail draft reply with OpenAI GPT-4o · henry · n8n.io · 2025-06-11

Comments & feedback

Tried this method? Share results, problems or improvements. Comments appear after moderation. Please avoid sensitive information.

Loading…

    Related