AutomationFlowsEmail & Gmail › AI Email Draft Generator

AI Email Draft Generator

Original n8n title: Smart Email Draft Generator

ByOneclick AI Squad @oneclick-ai on n8n.io

In this guide, we’ll walk you through setting up an AI-driven workflow that automatically processes incoming emails using a custom AI model (e.g., Llama), prepares email content, and saves it as a Gmail draft. Ready to automate your email drafting process? Let’s dive in!…

Manual trigger★★☆☆☆ complexityAI-powered6 nodesEmail Read ImapChain LlmLm OllamaGmail
Email & Gmail Trigger: Manual Nodes: 6 Complexity: ★★☆☆☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #5196 — we link there as the canonical source.

This workflow follows the Chainllm → Gmail recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "TXzwSeIj2lNw8Pr7",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Smart Email Draft Generator",
  "tags": [],
  "nodes": [
    {
      "id": "2f4d2db0-f825-4064-b9c4-059570ca28e8",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        840,
        -20
      ],
      "parameters": {
        "content": "This workflow triggers from Mail (IMAP), processes text with Basic LLM or Ollama Model, sets up an email field, and saves it as a draft."
      },
      "typeVersion": 1
    },
    {
      "id": "8cc89e3d-ab69-4c3e-8753-ef79a105fd62",
      "name": "Check New Email (IMAP)",
      "type": "n8n-nodes-base.emailReadImap",
      "position": [
        500,
        220
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "imap": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "d4098fe8-b946-441a-8f7d-1aada1cb6625",
      "name": "Process Email with AI",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        700,
        220
      ],
      "parameters": {
        "text": "={{ $json.textPlain }}",
        "messages": {
          "messageValues": [
            {
              "message": "=this is email\n\n{{ $json.textPlain }}\n\ni need reply of this "
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.6
    },
    {
      "id": "1bb72900-6d50-449a-bf8a-49cbeb0cfc86",
      "name": "Custom AI Model",
      "type": "@n8n/n8n-nodes-langchain.lmOllama",
      "position": [
        700,
        420
      ],
      "parameters": {
        "model": "llama3.2-16000:latest",
        "options": {}
      },
      "credentials": {
        "ollamaApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2308c0c8-c232-4560-b120-598addd7e4c5",
      "name": "Prepare Email Content",
      "type": "n8n-nodes-base.set",
      "position": [
        1100,
        220
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "7d428c48-4809-45d8-ba1e-c96d68c02c07",
              "name": "from",
              "type": "string",
              "value": "={{ $('Check New Email (IMAP)').first().json.from }}"
            },
            {
              "id": "63b99545-3d2d-4563-b9d7-078cbc20dbcc",
              "name": "subject",
              "type": "string",
              "value": "=Re: {{ $('Check New Email (IMAP)').first().json.subject }}"
            },
            {
              "id": "11d94d3f-2170-4b54-b5f9-b85bb95ad472",
              "name": "text",
              "type": "string",
              "value": "={{ $json.text }} "
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "f2c81d97-0b15-4fbb-a050-4f2750b1af9c",
      "name": "Save as Gmail Draft",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1320,
        220
      ],
      "parameters": {
        "message": "={{ $json.text }}",
        "options": {},
        "subject": "={{ $json.subject }}",
        "resource": "draft"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "66359f5c-1ada-4470-bc27-4796360c2fe8",
  "connections": {
    "Custom AI Model": {
      "ai_languageModel": [
        [
          {
            "node": "Process Email with AI",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Save as Gmail Draft": {
      "main": [
        []
      ]
    },
    "Prepare Email Content": {
      "main": [
        [
          {
            "node": "Save as Gmail Draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Email with AI": {
      "main": [
        [
          {
            "node": "Prepare Email Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check New Email (IMAP)": {
      "main": [
        [
          {
            "node": "Process Email with AI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

In this guide, we’ll walk you through setting up an AI-driven workflow that automatically processes incoming emails using a custom AI model (e.g., Llama), prepares email content, and saves it as a Gmail draft. Ready to automate your email drafting process? Let’s dive in!…

Source: https://n8n.io/workflows/5196/ — original creator credit. Request a take-down →

More Email & Gmail workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Email & Gmail

Alrouf AI Integration (Production). Uses googleSheets, chainLlm, lmChatGoogleGemini, outputParserStructured. Manual trigger; 21 nodes.

Google Sheets, Chain Llm, Google Gemini Chat +5
Email & Gmail

Stickynote Emailreadimap. Uses hubspot, lmChatOpenAi, chainLlm, emailReadImap. Manual trigger; 13 nodes.

HubSpot, OpenAI Chat, Chain Llm +2
Email & Gmail

Anyone who is drowning in emails Busy parents who has alot of school emails Busy executives with too many emails

Email Read Imap, HTTP Request, Chain Llm +2
Email & Gmail

This workflow automatically responds to incoming emails identified as potential leads using AI-generated text. It connects to your email inbox via IMAP, classifies incoming messages with an AI model,

Email Read Imap, Gmail, OpenAI
Email & Gmail

What it does

Reddit, Execute Workflow Trigger, OpenRouter Chat +3