AutomationFlowsAI & RAG › AI Gmail Message Analyzer with OpenAI

AI Gmail Message Analyzer with OpenAI

Original n8n title: Ainodes

aiNodes. Uses openAi, gmailTool, chainLlm, lmChatOpenAi. Event-driven trigger; 19 nodes.

Event trigger★★★★☆ complexityAI-powered19 nodesOpenAIGmail ToolChain LlmOpenAI ChatInformation ExtractorGmailChain Retrieval QaRetriever Vector Store
AI & RAG Trigger: Event Nodes: 19 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow follows the Chainllm → Chainsummarization 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": "aiNodes",
  "nodes": [
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4.1-mini",
          "mode": "list",
          "cachedResultName": "GPT-4.1-MINI"
        },
        "messages": {
          "values": [
            {
              "content": "You're an intelligent assistance to generate 1 line motivational quotes.\n\ncall the mail and pass this quote as body\nsubject: today motivational quotes\nTo: paari24@gmail.com",
              "role": "system"
            }
          ]
        },
        "jsonOutput": true,
        "options": {
          "temperature": 0.6
        }
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        224,
        256
      ],
      "id": "1f7672ba-7578-4832-8e87-42b1c2f43197",
      "name": "Message a model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sendTo": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('To', ``, 'string') }}",
        "subject": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Subject', ``, 'string') }}",
        "message": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmailTool",
      "typeVersion": 2.1,
      "position": [
        304,
        480
      ],
      "id": "7a286df5-72a1-483c-8588-ce6f782443be",
      "name": "Send a message in Gmail",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Describe this quotes with clear explanation \"{{ $json.message.content.quote }}\"",
        "messages": {
          "messageValues": [
            {
              "message": "you're a expert in describing the quotes in simple english"
            }
          ]
        },
        "batching": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.7,
      "position": [
        576,
        256
      ],
      "id": "ff92ec21-54f0-456b-bf5d-ebd018788795",
      "name": "Basic LLM Chain"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        656,
        480
      ],
      "id": "59125491-98b5-4a64-9003-e4bf0bb08493",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "text": "={{ $json.Subject }}",
        "attributes": {
          "attributes": [
            {
              "name": "subject",
              "description": "give me the list of subjects"
            }
          ]
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "typeVersion": 1.2,
      "position": [
        1152,
        256
      ],
      "id": "9ab7378a-60d4-47db-8c3f-f70429d82084",
      "name": "Information Extractor"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        1232,
        480
      ],
      "id": "f15e8b14-0e1c-4970-8164-86f16e41ebf9",
      "name": "OpenAI Chat Model1",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "getAll",
        "limit": 5,
        "filters": {}
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        928,
        256
      ],
      "id": "5ff75893-d747-4d63-b088-64dfe7006029",
      "name": "Get many messages",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=tell me the answer for the user question:  {{ $json.output.subject }}",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainRetrievalQa",
      "typeVersion": 1.6,
      "position": [
        1536,
        256
      ],
      "id": "c759ca57-4598-4bbb-9ccf-4e260db3a53b",
      "name": "Question and Answer Chain"
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.retrieverVectorStore",
      "typeVersion": 1,
      "position": [
        1632,
        480
      ],
      "id": "ca9dcb35-2803-494c-b1e4-806ee9a624da",
      "name": "Vector Store Retriever"
    },
    {
      "parameters": {
        "memoryKey": {
          "__rl": true,
          "value": "vector_store_key",
          "mode": "list",
          "cachedResultName": "vector_store_key"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
      "typeVersion": 1.3,
      "position": [
        1632,
        688
      ],
      "id": "32013338-eae3-4268-a1d6-e8886fac80a3",
      "name": "Simple Vector Store"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1.2,
      "position": [
        1712,
        896
      ],
      "id": "de8f24a8-4b4f-460a-90b6-ef59305287a1",
      "name": "Embeddings OpenAI",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        1504,
        480
      ],
      "id": "df2759e5-345a-4e2d-ae9c-c25d01c04f99",
      "name": "OpenAI Chat Model2",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "formTitle": "review system",
        "formDescription": "getting the feedback from customer",
        "formFields": {
          "values": [
            {
              "fieldLabel": "rate our service",
              "requiredField": true
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.3,
      "position": [
        224,
        -400
      ],
      "id": "25d3df34-a7a1-4e86-8595-2eb4001ec0f3",
      "name": "On form submission"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        528,
        -144
      ],
      "id": "fd1cc21a-7ef4-48bc-99cb-8f1181fa1802",
      "name": "OpenAI Chat Model3",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "inputText": "={{ $json['rate our service'] }}",
        "options": {
          "systemPromptTemplate": "You are highly intelligent and accurate sentiment analyzer. Analyze the sentiment of the provided text. Categorize it into one of the following: {categories}. Use the provided formatting instructions. Only output the JSON."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.sentimentAnalysis",
      "typeVersion": 1.1,
      "position": [
        448,
        -400
      ],
      "id": "0fe63f8c-84a8-4101-86b6-4951a1ec3d7f",
      "name": "Sentiment Analysis"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainSummarization",
      "typeVersion": 2.1,
      "position": [
        800,
        -400
      ],
      "id": "39d6fd39-f93a-4f3f-95e9-689c4a299bdf",
      "name": "Summarization Chain"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        880,
        -176
      ],
      "id": "06e8825c-9c80-44d1-a6b7-30e756254685",
      "name": "OpenAI Chat Model4",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "inputText": "={{ $json.output.text }}",
        "categories": {
          "categories": [
            {
              "category": "negative",
              "description": "the reviews are negative"
            },
            {
              "category": "positive",
              "description": "positive reviews"
            }
          ]
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "typeVersion": 1.1,
      "position": [
        1152,
        -400
      ],
      "id": "37445eb5-e890-478f-9954-93dccb98e07c",
      "name": "Text Classifier"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        1232,
        -176
      ],
      "id": "ecde66ac-aedf-42c8-b6f7-b0a9bf1eff39",
      "name": "OpenAI Chat Model5",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Send a message in Gmail": {
      "ai_tool": [
        [
          {
            "node": "Message a model",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Message a model": {
      "main": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain": {
      "main": [
        [
          {
            "node": "Get many messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Information Extractor",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Get many messages": {
      "main": [
        [
          {
            "node": "Information Extractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Information Extractor": {
      "main": [
        [
          {
            "node": "Question and Answer Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Vector Store Retriever": {
      "ai_retriever": [
        [
          {
            "node": "Question and Answer Chain",
            "type": "ai_retriever",
            "index": 0
          }
        ]
      ]
    },
    "Simple Vector Store": {
      "ai_vectorStore": [
        [
          {
            "node": "Vector Store Retriever",
            "type": "ai_vectorStore",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Simple Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Question and Answer Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Question and Answer Chain": {
      "main": [
        []
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Sentiment Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model3": {
      "ai_languageModel": [
        [
          {
            "node": "Sentiment Analysis",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Sentiment Analysis": {
      "main": [
        [],
        [],
        [
          {
            "node": "Summarization Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model4": {
      "ai_languageModel": [
        [
          {
            "node": "Summarization Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Summarization Chain": {
      "main": [
        [
          {
            "node": "Text Classifier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model5": {
      "ai_languageModel": [
        [
          {
            "node": "Text Classifier",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "ac61f1f5-bc7c-42a7-a115-f30d170d47df",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "zZvSOiNubQX6OL20",
  "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

aiNodes. Uses openAi, gmailTool, chainLlm, lmChatOpenAi. Event-driven trigger; 19 nodes.

Source: https://github.com/paari24/genAI/blob/30bfbd32b1e76049e3795e5e94449ce5c7a2d915/n8n/aiNodes.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

Alfred (funcional). Uses gmailTool, googleCalendarTool, gmail, embeddingsOpenAi. Event-driven trigger; 83 nodes.

Gmail Tool, Google Calendar Tool, Gmail +24
AI & RAG

This n8n template automatically classifies incoming emails (Sales, Support, Internal, Finance, Promotions) and routes them to a dedicated OpenAI LLM Agent for processing. Depending on the category, th

OpenAI, Gmail, Text Classifier +16
AI & RAG

Who is this for? This workflow is ideal for HR teams, startups, and enterprises that want to handle employee interactions through WhatsApp and automate responses using LLM (OpenAI) and intelligent rou

WhatsApp Trigger, OpenAI, OpenAI Chat +13
AI & RAG

BambooHR AI-Powered Company Policies and Benefits Chatbot. Uses manualTrigger, documentDefaultDataLoader, embeddingsOpenAi, textSplitterRecursiveCharacterTextSplitter. Event-driven trigger; 50 nodes.

Document Default Data Loader, OpenAI Embeddings, Text Splitter Recursive Character Text Splitter +14
AI & RAG

BambooHR AI-Powered Company Policies and Benefits Chatbot. Uses manualTrigger, documentDefaultDataLoader, embeddingsOpenAi, textSplitterRecursiveCharacterTextSplitter. Event-driven trigger; 50 nodes.

Document Default Data Loader, OpenAI Embeddings, Text Splitter Recursive Character Text Splitter +14