n8n

How to Automate Gmail AI Reply Drafts for Support?

Email replies get drafted for you based on labeled Gmail threads. Great for support and sales inboxes that need fast, consistent answers without writing from scratch.

On a set schedule, n8n looks for Gmail threads with a chosen label. It pulls the newest message in each thread, gets the full content, and sends it to an OpenAI Assistant to write a reply. The assistant returns Markdown, which is turned into HTML. The flow then builds a proper email in RFC format, encodes it, and creates a draft reply in the same thread. The label is removed to avoid running on the same thread again.

Setup is simple once Gmail OAuth and OpenAI credentials are ready. Expect time saved on common questions, intake messages, and follow ups. Teams can handle more email with the same staff while keeping tone and structure steady.

What are the key features?

  • Checks Gmail on a schedule for threads with a trigger label
  • Selects the newest message in each thread to avoid old content
  • Fetches full message body and metadata from Gmail
  • Sends message content to an OpenAI Assistant to draft the reply
  • Converts assistant Markdown into clean HTML for email
  • Builds a reply in RFC format and encodes it to base64
  • Creates a Gmail draft in the same thread using the Gmail API
  • Removes the trigger label after drafting to prevent repeats
  • Loops over multiple threads safely with batching control
  • Simple field mapping to set subject, recipients, and tone

What are the benefits?

  • Reduce manual reply drafting from 10 minutes to 1 minute per email
  • Automate up to 80 percent of repetitive email responses
  • Keep tone and formatting consistent across agents
  • Handle higher email volume without adding new seats
  • Connect Gmail and OpenAI with no custom code

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with Gmail and OpenAI. See the Tools Required section above for links to create accounts with these services.
  3. In the n8n credentials manager, create a Gmail OAuth2 credential. Double click any Gmail node, choose Credential to connect with, click Create new credential, and follow the on screen steps to sign in and allow read, compose, and modify permissions.
  4. Create an OpenAI API Key credential. In your OpenAI account, generate an API key on the API keys page, then in n8n choose Credential to connect with, click Create new credential, and paste the key.
  5. In Gmail, create a label that will act as the trigger. Apply this label to a few test threads you want to draft replies for.
  6. Open the Get threads with specific labels node and select your Gmail credential. Choose the trigger label and set a sensible max results value.
  7. Open the Schedule trigger node and set the interval to 1 minute or a value that fits your volume. Activate the workflow when ready.
  8. Check the Get thread messages and Return last message in thread nodes to confirm they pass the newest message ID into the flow.
  9. Open the Ask OpenAI Assistant node. Select your OpenAI credential and set the Assistant or instructions that define tone, length, and policy for replies.
  10. Review the Map fields and Convert response to HTML nodes. Ensure the subject and body fields are mapped and any placeholders you want are set.
  11. In Build email raw and Convert raw to base64, confirm From, To, Subject, and threadId use data from the Gmail message so the draft lands in the right thread.
  12. Open Add email draft to thread and verify the endpoint and payload include the base64 raw and threadId. Run a test execution.
  13. Apply the trigger label to a test Gmail thread and wait for the next schedule. Check the thread for a new Draft reply and review the content.
  14. Confirm Remove AI label from email clears the trigger label. This prevents the same thread from being processed again.
  15. If no draft appears, check credential scopes, label names, Assistant output, and the execution log. Verify base64 encoding and threadId mapping are present.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

Gmail

Sign up

No cost: Personal Gmail (Gmail API has no usage-based pricing; quotas apply)

OpenAI

Sign up

Pay-as-you-go: GPT-5 at $1.25 per 1M input tokens and $10 per 1M output tokens

Credits:
Author: workfloows. YouTube video. YouTube channel

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.