Describe the problem/error/question
I have tried to setup this flow, but somehow I keep getting errors, even though I think im doing it right…
What is the error message (if any)?
The error I get is that the profile document loader doesn’t load anything and therefor the rest also doesn’t work..
Please share your workflow
{
“nodes”: [
{
“parameters”: {
“pollTimes”: {
“item”: [
{
“mode”: “everyMinute”
}
]
},
“simple”: false,
“filters”: {
“q”: “-from:me”
},
“options”: {}
},
“id”: “gmail-trigger-001”,
“name”: “Gmail Trigger”,
“type”: “n8n-nodes-base.gmailTrigger”,
“position”: [
736,
448
],
“typeVersion”: 1,
“credentials”: {
“gmailOAuth2”: {
“id”: “C6e5F6HzsYySKl8L”,
“name”: “[email protected]”
}
}
},
{
“parameters”: {
“operation”: “download”,
“fileId”: {
“_rl": true,
“value”: “1FiMeSSf1FvRbFOglhgh04J3dzsJrMXkP39BMjClYk_E”,
“mode”: “”
},
“options”: {}
},
“id”: “drive-download-001”,
“name”: “Google Drive - Download Profile”,
“type”: “n8n-nodes-base.googleDrive”,
“position”: [
928,
304
],
“typeVersion”: 1,
“credentials”: {
“googleApi”: {
“id”: “wFVzxrulMEfmLAiL”,
“name”: “Google Service Account account”
}
}
},
{
“parameters”: {
“operation”: “getAll”,
“limit”: 10,
“filters”: {}
},
“id”: “gmail-thread-001”,
“name”: “Gmail - Fetch Thread”,
“type”: “n8n-nodes-base.gmail”,
“position”: [
928,
592
],
“typeVersion”: 2,
“webhookId”: “1fed71f3-6344-4ca7-bc16-9488fb84c999”,
“credentials”: {
“gmailOAuth2”: {
“id”: “C6e5F6HzsYySKl8L”,
“name”: “[email protected]”
}
}
},
{
“parameters”: {
“jsonMode”: “expressionData”,
“jsonData”: “={{ $json.content }}”,
“options”: {
“metadata”: {
“metadataValues”: [
{
“name”: “type”,
“value”: “user_profile”
}
]
}
}
},
“id”: “profile-loader-001”,
“name”: “Profile Document Loader”,
“type”: “@n8n/n8n-nodes-langchain.documentDefaultDataLoader”,
“position”: [
1152,
304
],
“typeVersion”: 1
},
{
“parameters”: {
“jsonMode”: “expressionData”,
“jsonData”: “={{ JSON.stringify($json.messages) }}”,
“options”: {
“metadata”: {
“metadataValues”: [
{
“name”: “type”,
“value”: “email_thread”
}
]
}
}
},
“id”: “thread-loader-001”,
“name”: “Thread Document Loader”,
“type”: “@n8n/n8n-nodes-langchain.documentDefaultDataLoader”,
“position”: [
1152,
592
],
“typeVersion”: 1
},
{
“parameters”: {
“chunkOverlap”: 100,
“options”: {}
},
“id”: “profile-splitter-001”,
“name”: “Profile Text Splitter”,
“type”: “@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter”,
“position”: [
1376,
304
],
“typeVersion”: 1
},
{
“parameters”: {
“chunkSize”: 2000,
“chunkOverlap”: 200,
“options”: {}
},
“id”: “thread-splitter-001”,
“name”: “Thread Text Splitter”,
“type”: “@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter”,
“position”: [
1376,
592
],
“typeVersion”: 1
},
{
“parameters”: {
“options”: {}
},
“id”: “openai-embeddings-001”,
“name”: “OpenAI Embeddings”,
“type”: “@n8n/n8n-nodes-langchain.embeddingsOpenAi”,
“position”: [
1600,
448
],
“typeVersion”: 1.2,
“credentials”: {
“openAiApi”: {
“id”: “d7SIuNYJ4r3k9AM3”,
“name”: “OpenAi account”
}
}
},
{
“parameters”: {
“mode”: “insert”,
“memoryKey”: "email_context{{ $(‘Gmail Trigger’).item.json.threadId }}”
},
“id”: “vector-store-001”,
“name”: “Simple Vector Store”,
“type”: “@n8n/n8n-nodes-langchain.vectorStoreInMemory”,
“position”: [
1808,
448
],
“typeVersion”: 1
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “context-text”,
“name”: “text”,
“type”: “string”,
“value”: “=Please analyze this incoming email and generate an appropriate reply based on the user profile and email thread context.\n\nIncoming Email Subject: {{ $(‘Gmail Trigger’).item.json.subject }}\nIncoming Email From: {{ $(‘Gmail Trigger’).item.json.headers.from }}\nIncoming Email Body: {{ $(‘Gmail Trigger’).item.json.textAsHtml }}\n\nInstructions:\n1. If this appears to be a newsletter, automated notification, or spam, respond with exactly ‘NO_REPLY_NEEDED’\n2. If this requires a response, generate a professional and contextual reply\n3. Use the knowledge from the vector store to inform your response\n4. Keep responses concise but helpful”
}
]
},
“options”: {}
},
“id”: “prepare-context-001”,
“name”: “Prepare Agent Context”,
“type”: “n8n-nodes-base.set”,
“position”: [
2032,
448
],
“typeVersion”: 3.4
},
{
“parameters”: {
“model”: {
“rl": true,
“mode”: “list”,
“value”: “gpt-4o-mini”
},
“options”: {
“temperature”: 0.3
}
},
“id”: “openai-chat-001”,
“name”: “OpenAI Chat Model”,
“type”: “@n8n/n8n-nodes-langchain.lmChatOpenAi”,
“position”: [
2256,
624
],
“typeVersion”: 1.2,
“credentials”: {
“openAiApi”: {
“id”: “d7SIuNYJ4r3k9AM3”,
“name”: “OpenAi account”
}
}
},
{
“parameters”: {
“sessionIdType”: “customKey”,
“sessionKey”: "=email{{ $(‘Gmail Trigger’).item.json.threadId }}"
},
“id”: “simple-memory-001”,
“name”: “Simple Memory”,
“type”: “@n8n/n8n-nodes-langchain.memoryBufferWindow”,
“position”: [
2352,
624
],
“typeVersion”: 1.3
},
{
“parameters”: {
“mode”: “retrieve-as-tool”,
“toolName”: “email_context”,
“toolDescription”: “Retrieve context about the user profile and email thread history”,
“memoryKey”: "email_context{{ $(‘Gmail Trigger’).item.json.threadId }}”
},
“id”: “vector-retriever-001”,
“name”: “Vector Store Retriever”,
“type”: “@n8n/n8n-nodes-langchain.vectorStoreInMemory”,
“position”: [
2448,
624
],
“typeVersion”: 1
},
{
“parameters”: {
“promptType”: “define”,
“text”: “={{ $json.text }}”,
“options”: {
“systemMessage”: “You are an intelligent email assistant. Your job is to analyze incoming emails and generate appropriate responses based on:\n\n1. User profile information (from vector store)\n2. Email thread context (from vector store)\n3. The specific incoming email content\n\nGuidelines:\n- For newsletters, promotions, automated messages: respond with exactly ‘NO_REPLY_NEEDED’\n- For legitimate emails requiring responses: generate professional, contextual replies\n- Keep responses concise but helpful\n- Use the user’s communication style from their profile\n- Reference relevant context from previous emails when appropriate\n- Always be polite and professional”
}
},
“id”: “email-agent-001”,
“name”: “Email Reply Agent”,
“type”: “@n8n/n8n-nodes-langchain.agent”,
“position”: [
2256,
448
],
“typeVersion”: 1.9
},
{
“parameters”: {
“conditions”: {
“combinator”: “and”,
“conditions”: [
{
“operator”: {
“type”: “notContainsText”
},
“leftValue”: “={{ $json.output }}”,
“rightValue”: “NO_REPLY_NEEDED”
}
]
},
“options”: {}
},
“id”: “check-response-001”,
“name”: “Check If Reply Needed”,
“type”: “n8n-nodes-base.if”,
“position”: [
2576,
448
],
“typeVersion”: 2
},
{
“parameters”: {
“resource”: “draft”,
“subject”: “=Re: {{ $(‘Gmail Trigger’).item.json.subject }}”,
“emailType”: “html”,
“message”: “={{ $json.output.replace(/\n/g, "
\n") }}”,
“options”: {
“threadId”: “={{ $(‘Gmail Trigger’).item.json.threadId }}”,
“sendTo”: “={{ $(‘Gmail Trigger’).item.json.headers.from }}”
}
},
“id”: “create-draft-001”,
“name”: “Gmail - Create Draft”,
“type”: “n8n-nodes-base.gmail”,
“position”: [
2848,
448
],
“typeVersion”: 2,
“webhookId”: “2e844cb8-568c-45d9-9fba-f93456ef2f23”,
“credentials”: {
“gmailOAuth2”: {
“id”: “C6e5F6HzsYySKl8L”,
“name”: “[email protected]”
}
}
},
{
“parameters”: {
“jsCode”: “// Log error details for debugging\nconst errorData = {\n timestamp: new Date().toISOString(),\n error: $input.all(),\n workflow: ‘Gmail Auto Reply’,\n threadId: $(‘Gmail Trigger’).item?.json?.threadId || ‘unknown’\n};\n\nconsole.log(‘Workflow Error:’, JSON.stringify(errorData, null, 2));\n\nreturn [{ json: errorData }];”
},
“id”: “error-handler-001”,
“name”: “Error Handler”,
“type”: “n8n-nodes-base.code”,
“position”: [
2576,
640
],
“typeVersion”: 2
},
{
“parameters”: {
“content”: “# Gmail Auto-Reply with AI\n\n## Setup Required:\n1. Gmail OAuth2 credentials\n2. Google Drive OAuth2 credentials \n3. OpenAI API credentials\n4. Profile Document: Update YOUR_PROFILE_DOC_FILE_ID\n\n## How it works:\n1. Monitors Gmail for new emails\n2. Downloads user profile from Google Drive\n3. Fetches email thread context\n4. Creates vector embeddings for context\n5. Uses AI agent to generate appropriate replies\n6. Creates draft if reply is needed\n\n## Features:\n- Smart filtering (ignores newsletters/spam)\n- Context-aware responses\n- Memory of conversation history\n- Professional tone matching”,
“height”: 752,
“width”: 300,
“color”: 5
},
“id”: “sticky-note-001”,
“name”: “Workflow Instructions”,
“type”: “n8n-nodes-base.stickyNote”,
“position”: [
384,
192
],
“typeVersion”: 1
}
],
“connections”: {
“Gmail Trigger”: {
“main”: [
[
{
“node”: “Google Drive - Download Profile”,
“type”: “main”,
“index”: 0
},
{
“node”: “Gmail - Fetch Thread”,
“type”: “main”,
“index”: 0
}
]
]
},
“Google Drive - Download Profile”: {
“main”: [
[
{
“node”: “Profile Document Loader”,
“type”: “main”,
“index”: 0
}
]
],
“error”: [
[
{
“node”: “Error Handler”,
“type”: “main”,
“index”: 0
}
]
]
},
“Gmail - Fetch Thread”: {
“main”: [
[
{
“node”: “Thread Document Loader”,
“type”: “main”,
“index”: 0
}
]
],
“error”: [
[
{
“node”: “Error Handler”,
“type”: “main”,
“index”: 0
}
]
]
},
“Profile Document Loader”: {
“ai_document”: [
[
{
“node”: “Simple Vector Store”,
“type”: “ai_document”,
“index”: 0
}
]
]
},
“Thread Document Loader”: {
“ai_document”: [
[
{
“node”: “Simple Vector Store”,
“type”: “ai_document”,
“index”: 0
}
]
]
},
“Profile Text Splitter”: {
“ai_textSplitter”: [
[
{
“node”: “Profile Document Loader”,
“type”: “ai_textSplitter”,
“index”: 0
}
]
]
},
“Thread Text Splitter”: {
“ai_textSplitter”: [
[
{
“node”: “Thread Document Loader”,
“type”: “ai_textSplitter”,
“index”: 0
}
]
]
},
“OpenAI Embeddings”: {
“ai_embedding”: [
[
{
“node”: “Simple Vector Store”,
“type”: “ai_embedding”,
“index”: 0
}
]
]
},
“Simple Vector Store”: {
“main”: [
[
{
“node”: “Prepare Agent Context”,
“type”: “main”,
“index”: 0
}
]
]
},
“Prepare Agent Context”: {
“main”: [
[
{
“node”: “Email Reply Agent”,
“type”: “main”,
“index”: 0
}
]
]
},
“OpenAI Chat Model”: {
“ai_languageModel”: [
[
{
“node”: “Email Reply Agent”,
“type”: “ai_languageModel”,
“index”: 0
}
]
]
},
“Simple Memory”: {
“ai_memory”: [
[
{
“node”: “Email Reply Agent”,
“type”: “ai_memory”,
“index”: 0
}
]
]
},
“Vector Store Retriever”: {
“ai_tool”: [
[
{
“node”: “Email Reply Agent”,
“type”: “ai_tool”,
“index”: 0
}
]
]
},
“Email Reply Agent”: {
“main”: [
[
{
“node”: “Check If Reply Needed”,
“type”: “main”,
“index”: 0
}
]
],
“error”: [
[
{
“node”: “Error Handler”,
“type”: “main”,
“index”: 0
}
]
]
},
“Check If Reply Needed”: {
“main”: [
[
{
“node”: “Gmail - Create Draft”,
“type”: “main”,
“index”: 0
}
]
]
},
“Gmail - Create Draft”: {
“error”: [
[
{
“node”: “Error Handler”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“templateId”: “5370”,
“instanceId”: “7fddb1f9d8cec074ab17477a5134dc7d6b88a61c4cdad3683d4dc570abed2682”
}
}
## Share the output returned by the last node
Invalid URL
## Information on your n8n setup
cloud, latest version