AutomationFlowsEmail & Gmail › Personalize Emails with OpenAI & Gmail

Personalize Emails with OpenAI & Gmail

Original n8n title: AI Email Personalizer

AI Email Personalizer. Uses openAi, gmail. Webhook trigger; 6 nodes.

Webhook trigger★★★★☆ complexityAI-powered6 nodesOpenAIGmail
Email & Gmail Trigger: Webhook Nodes: 6 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow follows the Gmail → OpenAI 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
{
  "name": "AI Email Personalizer",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "personalize-email",
        "responseMode": "lastNode"
      },
      "id": "b1b2c3d4-2003-4000-8000-000000000001",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1.1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "set1",
              "name": "contactName",
              "value": "={{ $json.body.contactName }}",
              "type": "string"
            },
            {
              "id": "set2",
              "name": "contactCompany",
              "value": "={{ $json.body.company }}",
              "type": "string"
            },
            {
              "id": "set3",
              "name": "contactEmail",
              "value": "={{ $json.body.email }}",
              "type": "string"
            },
            {
              "id": "set4",
              "name": "emailTemplate",
              "value": "={{ $json.body.template }}",
              "type": "string"
            },
            {
              "id": "set5",
              "name": "context",
              "value": "={{ $json.body.context || '' }}",
              "type": "string"
            }
          ]
        }
      },
      "id": "b1b2c3d4-2003-4000-8000-000000000002",
      "name": "Set Contact Data",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.2,
      "position": [
        500,
        300
      ]
    },
    {
      "parameters": {
        "resource": "chat",
        "model": "gpt-4",
        "messages": {
          "values": [
            {
              "content": "Personalize the following email template for the recipient. Make it feel natural and not templated. Add relevant details based on the context provided.\n\nRecipient Name: {{ $json.contactName }}\nRecipient Company: {{ $json.contactCompany }}\nAdditional Context: {{ $json.context }}\n\nEmail Template:\n{{ $json.emailTemplate }}\n\nReturn JSON with keys: subject, body (personalized email body), personalTouches (array of personalizations made)"
            }
          ]
        },
        "options": {
          "temperature": 0.7,
          "maxTokens": 1500
        }
      },
      "id": "b1b2c3d4-2003-4000-8000-000000000003",
      "name": "OpenAI Personalize",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.3,
      "position": [
        750,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "const response = JSON.parse($input.first().json.message.content);\nconst contact = $('Set Contact Data').first().json;\nreturn [{\n  json: {\n    to: contact.contactEmail,\n    subject: response.subject,\n    body: response.body,\n    personalTouches: response.personalTouches,\n    contactName: contact.contactName,\n    contactCompany: contact.contactCompany\n  }\n}];"
      },
      "id": "b1b2c3d4-2003-4000-8000-000000000004",
      "name": "Format Email",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1000,
        300
      ]
    },
    {
      "parameters": {
        "resource": "message",
        "operation": "send",
        "sendTo": "={{ $json.to }}",
        "subject": "={{ $json.subject }}",
        "message": "={{ $json.body }}",
        "options": {}
      },
      "id": "b1b2c3d4-2003-4000-8000-000000000005",
      "name": "Send Gmail",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1250,
        300
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ success: true, sentTo: $json.to, subject: $json.subject }) }}"
      },
      "id": "b1b2c3d4-2003-4000-8000-000000000006",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1500,
        300
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Set Contact Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Contact Data": {
      "main": [
        [
          {
            "node": "OpenAI Personalize",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Personalize": {
      "main": [
        [
          {
            "node": "Format Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Email": {
      "main": [
        [
          {
            "node": "Send Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Gmail": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}
Pro

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

About this workflow

AI Email Personalizer. Uses openAi, gmail. Webhook trigger; 6 nodes.

Source: https://github.com/mlnjsh/n8n-workflows-mega/blob/main/workflows/ai-email/03-email-personalizer.json — 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

Googledocs. Uses extractFromFile, outputParserItemList, splitInBatches, stickyNote. Webhook trigger; 23 nodes.

Output Parser Item List, Google Docs, OpenAI Chat +4
Email & Gmail

Webhook Code. Uses openAi, noOp, googleDrive, respondToWebhook. Webhook trigger; 20 nodes.

OpenAI, Google Drive, Gmail +1
Email & Gmail

AI-Powered Deal Content Recommendation and Personalization. Uses zohoCrm, httpRequest, openAi, gmail. Webhook trigger; 16 nodes.

Zoho Crm, HTTP Request, OpenAI +1
Email & Gmail

Description

Google Sheets, OpenAI, Gmail +1
Email & Gmail

Order-Workflow. Uses gmail, postgres, openAi. Webhook trigger; 7 nodes.

Gmail, Postgres, OpenAI