AutomationFlowsAI & RAG › Email Automation

Email Automation

Email Automation. Uses gmailTrigger, textClassifier, lmChatOpenAi, openAi. Event-driven trigger; 13 nodes.

Event trigger★★★★☆ complexityAI-powered13 nodesGmail TriggerText ClassifierOpenAI ChatOpenAIGmailTelegramInformation ExtractorGoogle Docs Tool
AI & RAG Trigger: Event Nodes: 13 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow follows the Gmail → Gmail Trigger 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": "Email Automation",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "filters": {
          "labelIds": [
            "INBOX"
          ]
        }
      },
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1.2,
      "position": [
        -440,
        -80
      ],
      "id": "8311acb0-4e19-4cae-a21d-c452cdd29514",
      "name": "Gmail Trigger",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "inputText": "={{ $json.snippet }}",
        "categories": {
          "categories": [
            {
              "category": "Assistance technique",
              "description": "Emails qui demandent de l'assistance technique, service apr\u00e8s-ventes, description du produit, mat\u00e9riel, mat\u00e9riau du produit, software, hardware, "
            },
            {
              "category": "Assistant commercial ",
              "description": "Demande par rapport au prix, promotion, stock, les nouveaut\u00e9s produit, mod\u00e8le"
            },
            {
              "category": "Divers",
              "description": "email personnel, aucun rapport avec l'assistance ou la vente. "
            }
          ]
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "typeVersion": 1,
      "position": [
        -180,
        -80
      ],
      "id": "526fff62-92b3-4ee7-b52b-cc6036294b36",
      "name": "Text Classifier"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -260,
        140
      ],
      "id": "4e013ada-4be8-4327-b293-ca7a2879f339",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o",
          "mode": "list",
          "cachedResultName": "GPT-4O"
        },
        "messages": {
          "values": [
            {
              "content": "=Tu es un assistant technique, tu donnes l'information n\u00e9cessaire par rapport \u00e0 la technicit\u00e9 du produit cit\u00e9. Si tu ne connais pas la r\u00e9ponse, invite le client \u00e0 contacter support@gmail.com.  \n\nDonne une solution directe sans demander plus d'information. \n\nTu \u00e9cris la r\u00e9ponse sous forme d'un email.\n\nVoil\u00e0 la demande du client  :  {{ $json.snippet }}"
            }
          ]
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        200,
        -320
      ],
      "id": "f03b910b-3a91-4725-bcdf-ef7c0f44060c",
      "name": "OpenAI",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "reply",
        "messageId": "={{ $('Text Classifier').item.json.id }}",
        "emailType": "text",
        "message": "={{ $json.message.content }}",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        580,
        -80
      ],
      "id": "f5b0bfe2-b251-48ad-922f-ccc8ae84d3dc",
      "name": "Gmail",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4O-MINI"
        },
        "messages": {
          "values": [
            {
              "content": "=Tu es un assistant commercial, tu pousses la vente des ordinateurs, on se basant sur le document dont tu as acc\u00e8s. \n\n\nNom du client : {{ $json.From }}\n\nMail auquel tu dois r\u00e9pondre : \n\nTexte sous forme d'email.  ",
              "role": "assistant"
            }
          ]
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        200,
        -80
      ],
      "id": "34e0c0a9-c487-44c0-a900-90438988df38",
      "name": "OpenAI1",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "chatId": "892959162",
        "text": "=Tu as envoy\u00e9 un message : \n\nSujet : {{ $json.output['L\\'objet de l\\'email'] }}\n\n\u00e0 : {{ $json.output.Destinataire }}\n\nMessage : {{ $json.output['Message envoy\u00e9'] }}",
        "additionalFields": {
          "appendAttribution": true
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1260,
        -80
      ],
      "id": "f0b65003-0c33-489b-a0e8-abeb5220252c",
      "name": "Telegram",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "text": "={{ $json.text }}",
        "attributes": {
          "attributes": [
            {
              "name": "L'objet de l'email",
              "description": "L'objet de l'email"
            },
            {
              "name": "Message envoy\u00e9",
              "description": "Message envoy\u00e9"
            },
            {
              "name": "Destinataire ",
              "description": "=celui qui nous envoy\u00e9 le mail : {{ $('Gmail Trigger').item.json.From }}"
            }
          ]
        },
        "options": {
          "systemPromptTemplate": "You are an expert extraction algorithm.\nOnly extract relevant information from the text.\nIf you do not know the value of an attribute asked to extract, you may omit the attribute's value."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "typeVersion": 1,
      "position": [
        920,
        -80
      ],
      "id": "df43f46d-e646-4383-9bcc-6543b7fbe73d",
      "name": "Information Extractor"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        940,
        160
      ],
      "id": "60a6bc5f-21c1-4fa9-b45a-591453780715",
      "name": "OpenAI Chat Model1",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o",
          "mode": "list",
          "cachedResultName": "GPT-4O"
        },
        "messages": {
          "values": [
            {
              "content": "=Donne un r\u00e9sum\u00e9 du message envoy\u00e9 avec l'adresse email.  \n\nEmail du Destinateur : {{ $('Gmail Trigger').item.json.From }}\n\nMessage envoy\u00e9 :  {{ $json.snippet }}"
            }
          ]
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        200,
        280
      ],
      "id": "17009dd3-7e5f-4d24-b0c0-b40bcb8036db",
      "name": "OpenAI2",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "chatId": "892959162",
        "text": "={{ $json.message.content }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        580,
        280
      ],
      "id": "20590ccc-3b4e-4280-9c7b-c52a3dcdd4f1",
      "name": "Telegram1",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "get",
        "messageId": "={{ $json.id }}",
        "simple": false,
        "options": {}
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        760,
        -80
      ],
      "id": "4359006e-dcc9-43d9-ad8f-24bb07025196",
      "name": "Gmail1",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "get",
        "documentURL": "https://docs.google.com/document/d/1fuMsd9gIAXSzPoZ_TVs9v7FNCI53-5FXInZUCH5CsHc/edit?usp=sharing"
      },
      "type": "n8n-nodes-base.googleDocsTool",
      "typeVersion": 2,
      "position": [
        400,
        140
      ],
      "id": "8e2d1e12-e8b8-435a-80f3-f290873e143c",
      "name": "Google Docs1",
      "credentials": {
        "googleDocsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Text Classifier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Text Classifier",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Text Classifier": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "OpenAI1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "OpenAI2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI": {
      "main": [
        [
          {
            "node": "Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI1": {
      "main": [
        [
          {
            "node": "Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail": {
      "main": [
        [
          {
            "node": "Gmail1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Information Extractor",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Information Extractor": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI2": {
      "main": [
        [
          {
            "node": "Telegram1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail1": {
      "main": [
        [
          {
            "node": "Information Extractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Docs1": {
      "ai_tool": [
        [
          {
            "node": "OpenAI1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "11aafe7e-43ef-4332-bb35-001f7caf1d83",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "kA6PVJ1HDFFKKpoV",
  "tags": []
}

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

Email Automation. Uses gmailTrigger, textClassifier, lmChatOpenAi, openAi. Event-driven trigger; 13 nodes.

Source: https://github.com/houseofichigo/json/blob/d73f6e7ccf65d535b168f46a7a2cdcb0a0f929ef/Email_Automation.json — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

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

AI & RAG

Detects new unread Gmail messages Extracts sender name for personalized replies Classifies the email into one of four categories Applies the correct Gmail label and either sends an auto-reply, creates

Gmail Trigger, OpenAI Chat, Gmail +4
AI & RAG

This n8n template demonstrates how to automate email classification, labeling, draft generation, and logging using Gmail, OpenAI, and Google Sheets. Use cases include customer support management, sale

Gmail Trigger, Gmail, Text Classifier +4
AI & RAG

This template can be used to automatically label your incoming Gmail messages with AI and to build a knowledge graph from the emails tagged with a specific label to brainstorm new ideas based on them.

Gmail Trigger, OpenAI Chat, Gmail +4
AI & RAG

This n8n template uses AI to automatically classify incoming Gmail messages into five categories and route them to the right people or departments. It can also reply automatically and send WhatsApp al

Gmail Trigger, OpenAI Chat, Gmail +3
AI & RAG

Email Automation AI-Powered Operations Internal Productivity Tools

Gmail Trigger, Text Classifier, OpenAI Chat +3