Describe the problem/error/question
I used the n8n AI to make an email agent that checks your emails, and can respond to them for you. But I tested it and asked it to send me all emails in a specific timeframe, e.g. can you let me know if I received ANY emails in October. It responded notifying me of the most recent email I received to the mailbox, but it wasn't in october it was in November. I told it that email is in the wrong month. It acknowledged this, but carried on making the same mistake. I then changed the limit of emails retrieved number inside the Get Emails tool from 1 to 20 thinking this will solve the issue. I sent myself two emails to that mailbox and asked it to show me ANY emails I have received today. It still would only give me one email, the most recent one. I asked it inside the chat, to retrieve ALL emails received inside the timeframe that I request, not just one. It responded saying it will do that going forward. I then tried again, and it still only retrieved one email, as if it cannot see the others. I then added this specification inside the prompt of the AI agent, and still the same problem.
What is the error message (if any)?
Please share your workflow/screenshots/recording
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)
⚠️ WARNING ⚠️ If you have sensitive data in your workflow (like API keys), please remove it before sharing.
{
"nodes": [
{
"parameters": {
"options": {}
},
"id": "cd69aaf7-8c4d-4dd0-8db6-c43af5fb547b",
"name": "Chat Trigger",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"typeVersion": 1.3,
"position": [
0,
144
],
"webhookId": "be88a3eb-e7b6-44b8-9b35-f769ffd29383"
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {}
},
"id": "a3d5f11d-47a2-4dc3-b808-fd54e9bdbd22",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [
224,
368
],
"credentials": {
"openAiApi": {
"id": "ph5p6u6tUQHfjrGj",
"name": "Ag OpenAI Account"
}
}
},
{
"parameters": {
"contextWindowLength": 20
},
"id": "1a1448f8-9fc6-4a21-8368-a32c9a49142c",
"name": "Simple Memory",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"typeVersion": 1.3,
"position": [
352,
368
]
},
{
"parameters": {
"operation": "getAll",
"limit": "={{ $fromAI('limit', 'Number of emails to retrieve', 'number', 20) }}",
"filters": {}
},
"id": "cddb6a3e-407c-4dc7-bfd8-adcaecfc7558",
"name": "Gmail Tool - Get Emails",
"type": "n8n-nodes-base.gmailTool",
"typeVersion": 2.1,
"position": [
480,
368
],
"webhookId": "e73a2620-9f0d-483e-856e-d6dcd67fb279",
"credentials": {
"gmailOAuth2": {
"id": "CRvtHDQPSOG9AhQI",
"name": "Gmail account"
}
}
},
{
"parameters": {
"operation": "reply",
"messageId": "={{ $fromAI('messageId', 'The ID of the message to reply to', 'string') }}",
"message": "={{ $fromAI('replyMessage', 'The reply message content', 'string') }}",
"options": {}
},
"id": "5abad812-02da-4ca5-a93f-9853e9f026f7",
"name": "Gmail Tool - Send Reply",
"type": "n8n-nodes-base.gmailTool",
"typeVersion": 2.1,
"position": [
608,
368
],
"webhookId": "8274b6ec-35b7-467d-a60f-8d431d4a66e3",
"credentials": {
"gmailOAuth2": {
"id": "CRvtHDQPSOG9AhQI",
"name": "Gmail account"
}
}
},
{
"parameters": {
"options": {
"systemMessage": "You are an intelligent email management assistant with access to Gmail.\n\nYour capabilities:\n1. Check and retrieve emails from the user's Gmail inbox\n2. Summarize emails clearly and concisely\n3. Reply to emails on behalf of the user\n\nInstructions:\n\nWhen the user asks you to:\n- "Check emails" or "Get emails": Use the Gmail Tool - Get Emails to retrieve recent emails, and also always check the dates each emails was received. Retrieve ALL emails received inside the timeframe specified by the user.\n- "Summarize emails": First retrieve the emails, then provide a clear summary of each email including sender, subject, and key points\n- "Reply to an email": Use the Gmail Tool - Send Reply to compose and send a response, ending every email with a polite sign off, and the name 'Agatha', on the next line beneath. Always respond with politeness and enthusiasm.\n\nAlways be helpful, professional, and ask for clarification if needed before taking actions like sending emails. Always pay close attention to time restrictions given in the user's instructions. For example 'show me emails I got this month'\n\nDo not end every chat message to the user with a sign off, and with the name 'Agatha'. Only do that for emails.\n\nFormat every email professionally, with line spacing in right places, rather than one big clunky paragraph. For example: \n\n"Hello Emma,\n\nThank you for getting in touch. I will go ahead and put in a meeting for us to chat at 12.\n\nLooking forward to hearing back.\n\nKind regards,\nAgatha"\n\n"
}
},
"id": "509e5e97-0074-4d03-bb51-8a8cb2a43eb0",
"name": "Property Expert and Personal Assistant",
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3,
"position": [
352,
144
]
}
],
"connections": {
"Chat Trigger": {
"main": [
[
{
"node": "Property Expert and Personal Assistant",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Property Expert and Personal Assistant",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Simple Memory": {
"ai_memory": [
[
{
"node": "Property Expert and Personal Assistant",
"type": "ai_memory",
"index": 0
}
]
]
},
"Gmail Tool - Get Emails": {
"ai_tool": [
[
{
"node": "Property Expert and Personal Assistant",
"type": "ai_tool",
"index": 0
}
]
]
},
"Gmail Tool - Send Reply": {
"ai_tool": [
[
{
"node": "Property Expert and Personal Assistant",
"type": "ai_tool",
"index": 0
}
]
]
}
},
"pinData": {},
"meta": {
"instanceId": "dd298b42578d86e75c40629778d279eb495de4287cfc4096b4a857c53a484a73"
}
}
Share the output returned by the last node
[Used tools: Tool: Gmail_Tool_-_Get_Emails, Input: {}, Result: {"id":"19a6586a111d57e1","threadId":"19a6586a111d57e1","snippet":"Hi, I was wondering if you have any properties that are 3bed, in south London, with a garden? Best, Chicky","payload":{"mimeType":"multipart/alternative"},"sizeEstimate":12866,"historyId":"418877","internalDate":"1762639910000","labels":[{"id":"INBOX","name":"INBOX"},{"id":"CATEGORY_PERSONAL","name":"CATEGORY_PERSONAL"},{"id":"UNREAD","name":"UNREAD"}],"From":"agatha marcus quick_chick@live.com","To":""agathamarc16@gmail.com" agathamarc16@gmail.com","Subject":"...
Debug info
core
- n8nVersion: 1.118.1
- platform: docker (cloud)
- nodeJsVersion: 22.21.0
- nodeEnv: production
- database: sqlite
- executionMode: regular
- concurrency: 5
- license: community
storage
- success: all
- error: all
- progress: false
- manual: true
- binaryMode: filesystem
pruning
- enabled: true
- maxAge: 168 hours
- maxCount: 2500 executions
client
- userAgent: mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, like gecko) chrome/141.0.0.0 safari/537.36 edg/141.0.0.0
- isTouchDevice: false
Generated at: 2025-11-08T22:13:04.818Z}
Describe the problem/error/question
I used the n8n AI to make an email agent that checks your emails, and can respond to them for you. But I tested it and asked it to send me all emails in a specific timeframe, e.g. can you let me know if I received ANY emails in October. It responded notifying me of the most recent email I received to the mailbox, but it wasn't in october it was in November. I told it that email is in the wrong month. It acknowledged this, but carried on making the same mistake. I then changed the limit of emails retrieved number inside the Get Emails tool from 1 to 20 thinking this will solve the issue. I sent myself two emails to that mailbox and asked it to show me ANY emails I have received today. It still would only give me one email, the most recent one. I asked it inside the chat, to retrieve ALL emails received inside the timeframe that I request, not just one. It responded saying it will do that going forward. I then tried again, and it still only retrieved one email, as if it cannot see the others. I then added this specification inside the prompt of the AI agent, and still the same problem.
What is the error message (if any)?
Please share your workflow/screenshots/recording
{
"nodes": [
{
"parameters": {
"options": {}
},
"id": "cd69aaf7-8c4d-4dd0-8db6-c43af5fb547b",
"name": "Chat Trigger",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"typeVersion": 1.3,
"position": [
0,
144
],
"webhookId": "be88a3eb-e7b6-44b8-9b35-f769ffd29383"
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {}
},
"id": "a3d5f11d-47a2-4dc3-b808-fd54e9bdbd22",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [
224,
368
],
"credentials": {
"openAiApi": {
"id": "ph5p6u6tUQHfjrGj",
"name": "Ag OpenAI Account"
}
}
},
{
"parameters": {
"contextWindowLength": 20
},
"id": "1a1448f8-9fc6-4a21-8368-a32c9a49142c",
"name": "Simple Memory",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"typeVersion": 1.3,
"position": [
352,
368
]
},
{
"parameters": {
"operation": "getAll",
"limit": "={{ $fromAI('limit', 'Number of emails to retrieve', 'number', 20) }}",
"filters": {}
},
"id": "cddb6a3e-407c-4dc7-bfd8-adcaecfc7558",
"name": "Gmail Tool - Get Emails",
"type": "n8n-nodes-base.gmailTool",
"typeVersion": 2.1,
"position": [
480,
368
],
"webhookId": "e73a2620-9f0d-483e-856e-d6dcd67fb279",
"credentials": {
"gmailOAuth2": {
"id": "CRvtHDQPSOG9AhQI",
"name": "Gmail account"
}
}
},
{
"parameters": {
"operation": "reply",
"messageId": "={{ $fromAI('messageId', 'The ID of the message to reply to', 'string') }}",
"message": "={{ $fromAI('replyMessage', 'The reply message content', 'string') }}",
"options": {}
},
"id": "5abad812-02da-4ca5-a93f-9853e9f026f7",
"name": "Gmail Tool - Send Reply",
"type": "n8n-nodes-base.gmailTool",
"typeVersion": 2.1,
"position": [
608,
368
],
"webhookId": "8274b6ec-35b7-467d-a60f-8d431d4a66e3",
"credentials": {
"gmailOAuth2": {
"id": "CRvtHDQPSOG9AhQI",
"name": "Gmail account"
}
}
},
{
"parameters": {
"options": {
"systemMessage": "You are an intelligent email management assistant with access to Gmail.\n\nYour capabilities:\n1. Check and retrieve emails from the user's Gmail inbox\n2. Summarize emails clearly and concisely\n3. Reply to emails on behalf of the user\n\nInstructions:\n\nWhen the user asks you to:\n- "Check emails" or "Get emails": Use the Gmail Tool - Get Emails to retrieve recent emails, and also always check the dates each emails was received. Retrieve ALL emails received inside the timeframe specified by the user.\n- "Summarize emails": First retrieve the emails, then provide a clear summary of each email including sender, subject, and key points\n- "Reply to an email": Use the Gmail Tool - Send Reply to compose and send a response, ending every email with a polite sign off, and the name 'Agatha', on the next line beneath. Always respond with politeness and enthusiasm.\n\nAlways be helpful, professional, and ask for clarification if needed before taking actions like sending emails. Always pay close attention to time restrictions given in the user's instructions. For example 'show me emails I got this month'\n\nDo not end every chat message to the user with a sign off, and with the name 'Agatha'. Only do that for emails.\n\nFormat every email professionally, with line spacing in right places, rather than one big clunky paragraph. For example: \n\n"Hello Emma,\n\nThank you for getting in touch. I will go ahead and put in a meeting for us to chat at 12.\n\nLooking forward to hearing back.\n\nKind regards,\nAgatha"\n\n"
}
},
"id": "509e5e97-0074-4d03-bb51-8a8cb2a43eb0",
"name": "Property Expert and Personal Assistant",
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3,
"position": [
352,
144
]
}
],
"connections": {
"Chat Trigger": {
"main": [
[
{
"node": "Property Expert and Personal Assistant",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Property Expert and Personal Assistant",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Simple Memory": {
"ai_memory": [
[
{
"node": "Property Expert and Personal Assistant",
"type": "ai_memory",
"index": 0
}
]
]
},
"Gmail Tool - Get Emails": {
"ai_tool": [
[
{
"node": "Property Expert and Personal Assistant",
"type": "ai_tool",
"index": 0
}
]
]
},
"Gmail Tool - Send Reply": {
"ai_tool": [
[
{
"node": "Property Expert and Personal Assistant",
"type": "ai_tool",
"index": 0
}
]
]
}
},
"pinData": {},
"meta": {
"instanceId": "dd298b42578d86e75c40629778d279eb495de4287cfc4096b4a857c53a484a73"
}
}
Share the output returned by the last node
[Used tools: Tool: Gmail_Tool_-_Get_Emails, Input: {}, Result: {"id":"19a6586a111d57e1","threadId":"19a6586a111d57e1","snippet":"Hi, I was wondering if you have any properties that are 3bed, in south London, with a garden? Best, Chicky","payload":{"mimeType":"multipart/alternative"},"sizeEstimate":12866,"historyId":"418877","internalDate":"1762639910000","labels":[{"id":"INBOX","name":"INBOX"},{"id":"CATEGORY_PERSONAL","name":"CATEGORY_PERSONAL"},{"id":"UNREAD","name":"UNREAD"}],"From":"agatha marcus quick_chick@live.com","To":""agathamarc16@gmail.com" agathamarc16@gmail.com","Subject":"...
Debug info
core
storage
pruning
client
Generated at: 2025-11-08T22:13:04.818Z}