How to Build a Zero-Cost AI Executive Assistant Using n8n, Gemini Pro, and MongoDB
Executive Summary
The Problem: Administrative tasks like email triaging, task entry, and calendar scheduling consume an average of 5+ hours weekly with zero value creation. The Solution: Deploying an autonomous AI Agent using n8n that reads emails, checks availability, schedules meetings, and creates database tasks. The ROI: Inbox zero, eliminated manual data entry, and 20+ hours saved monthly at zero operational cost.
The Limitations of Standard Automation
Traditional automation relies on rigid, rule-based logic (If X, then Y). Unstructured data, such as client emails, breaks these workflows because natural language requires interpretation. Building an "Agentic Workflow" solves this. Instead of following strict paths, an AI Agent uses a Large Language Model (LLM) to reason, extract intent, and independently select the correct external tools to execute the task.
The Architecture and Tech Stack
This workflow acts as a digital Chief of Staff, operating continuously in the background. The system relies on four primary components: The Engine (n8n): A self-hosted node-based workflow automation platform that connects the APIs and orchestrates the logic. The Logic Model (Google Gemini Pro): The reasoning layer responsible for parsing unstructured email text, identifying meeting requests versus tasks, and formatting output data. The Memory (MongoDB): Provides persistent state memory, allowing the agent to recall previous context from ongoing email threads. The Tools (Google Workspace & Notion APIs): The external applications the agent manipulates to execute the work.
Step-by-Step Implementation Guide
Step 1: Configure the Trigger and Ingestion
Set the workflow to run on a scheduled trigger (e.g., every night at 10:00 PM) or attach it directly to a Webhook listening for new emails. Utilize the Gmail API node, specifically filtering for messages with the UNREAD status. Limit the batch size to prevent hitting API rate limits during testing.
Step 2: Initialize the AI Agent and Memory
Add the n8n "AI Agent" node. This differs from a standard LLM node as it supports function calling. Connect the Google Gemini Pro model to the agent. Next, attach a MongoDB Chat Memory node. This ensures that if a client replies to a previous thread changing a meeting time, the agent has the historical context to update the event rather than creating a duplicate.
Step 3: Define the Toolset
The agent requires explicit instructions on how to interact with external platforms. Create three separate tool nodes: Calendar Scheduler: Connected to the Google Calendar API. Instruct the agent to use this only when an email contains specific time and duration data. Task Creator: Connected to the Notion API. Instruct the agent to map extracted deliverables, client names, and deadlines into the respective database columns. Inbox Cleanup: Connected to the Gmail API with the operation set to "Mark as Read." This is a critical safeguard to prevent the workflow from processing the same email in an infinite loop.
Step 4: Establish the System Prompt
The system prompt dictates the agent's behavior and operational strictness. Inject the current date and timezone dynamically ({{ $now }}) into the prompt so the LLM can accurately calculate relative dates (e.g., "tomorrow at 3 PM"). Command the agent to analyze the email, utilize the appropriate tool, and generate a plain-text summary of actions taken.
Step 5: Configure the Output Report
Route the output of the AI Agent node to a final Gmail node. Set the recipient to your own email address and pass the agent's generated summary into the message body. This provides a daily audit log of all automated actions.
Conclusion
Replacing manual administrative work with an agentic n8n workflow shifts focus from operational maintenance to high-value execution. Start by isolating a single repetitive pipeline—such as email to task creation—validate the data parsing, and scale the toolset incrementally.
n8n workflow
{
"nodes": [
{
"parameters": {
"promptType": "define",
"text": "Get an email from \"get email.\"",
"options": {
"systemMessage": "=You are an intelligent executive assistant. Your goal is to clear my inbox and organize my life.\n\n## CONTEXT\nCurrent Date: {{ $now.format('cccc, MMMM d, yyyy h:mm a') }}\nTimezone: {{ $now.format('z') }}\n\n## YOUR WORKFLOW (Follow strictly)\n1. **CHECK EMAILS:** Use \"Get All emaill\" to find unread messages.\n2. **PROCESS EACH EMAIL:**\n - **Meeting Request?** Use \"schedule_meeting\".\n - **Task/ToDo?** Use \"create_notion_task\".\n - **Spam?** Ignore it.\n3. **REPLY TO CLIENT:**\n - If you successfully scheduled a meeting or added a task, use the \"send_reply\" tool.\n - Send a polite email to the client confirming the specific date/time or task.\n4. **CLEAN UP (CRITICAL):**\n - After processing an email, you MUST use the \"mark_email_read\" tool on that specific message ID. This is required to stop duplicates.\n5. **REPORT TO ME:**\n - Once all emails are done, generate a final text summary for me.\n\n## FINAL RESPONSE FORMAT\nYour final output will be sent to ME (the user).\n- Example: \"Processed 2 emails. 1) Scheduled meeting with Client X. 2) Added Budget task. Replied to both clients and marked emails as read.\"\n- If nothing found: \"No new requests found.\"\n\nDO NOT return JSON. Return clear text only."
}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"position": [
-32,
-48
],
"id": "483bed50-5b59-4573-8cf5-6e51dae8120e",
"name": "AI Agent"
},
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"typeVersion": 1,
"position": [
-176,
208
],
"id": "eed74327-3bf7-469f-afca-2cd4c1afec10",
"name": "Google Gemini Chat Model",
"credentials": {
"googlePalmApi": {
"id": "Z9r7hmc9L9SV58ey",
"name": "Google Gemini(PaLM) Api account"
}
}
},
{
"parameters": {
"sessionIdType": "customKey",
"sessionKey": "=2347962674",
"collectionName": "n8n_chat_histories_m"
},
"type": "@n8n/n8n-nodes-langchain.memoryMongoDbChat",
"typeVersion": 1,
"position": [
-48,
176
],
"id": "c22d814e-f23c-48a5-aed6-dc299056c49f",
"name": "MongoDB Chat Memory",
"credentials": {
"mongoDb": {
"id": "nEG8R2BBrwzYCh5R",
"name": "MongoDB account"
}
}
},
{
"parameters": {
"descriptionType": "manual",
"toolDescription": "Call this tool to create a new task in the database. Use this when the user mentions a task, to-do, or client request. Inputs required: title, client_name, and due_date.",
"pageId": {
"__rl": true,
"value": "https://www.notion.so/All-n8n-page-2d78f7a2f206802ea51add23c49b1709?source=copy_link",
"mode": "url"
},
"title": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Title', ``, 'string') }}",
"options": {}
},
"type": "n8n-nodes-base.notionTool",
"typeVersion": 2.2,
"position": [
240,
192
],
"id": "c80b8a88-8df8-4853-bcec-670bc4542da5",
"name": "create_notion_task",
"credentials": {
"notionApi": {
"id": "47S280tPbNRoBq75",
"name": "Notion account"
}
}
},
{
"parameters": {
"descriptionType": "manual",
"toolDescription": "Call this tool to schedule a meeting on Google Calendar. Use this ONLY when a specific start time and duration are confirmed. Inputs required: summary, start_time, end_time, and description.",
"calendar": {
"__rl": true,
"value": "db180e53f87527e07a18d230a74be25bc114dc3391635d5998fd4d58379e05ec@group.calendar.google.com",
"mode": "list",
"cachedResultName": "n8n"
},
"start": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Start', ``, 'string') }}",
"end": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('End', ``, 'string') }}",
"additionalFields": {
"description": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Description', ``, 'string') }}",
"summary": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Summary', ``, 'string') }}"
}
},
"type": "n8n-nodes-base.googleCalendarTool",
"typeVersion": 1.3,
"position": [
128,
224
],
"id": "b59cdf18-6e2d-49d5-bdd8-7f51358303c0",
"name": "schedule_meeting",
"credentials": {
"googleCalendarOAuth2Api": {
"id": "LW4plkUAQXxg4kpD",
"name": "Google Calendar account"
}
}
},
{
"parameters": {
"rule": {
"interval": [
{
"triggerAtHour": 22
}
]
}
},
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.3,
"position": [
-272,
-64
],
"id": "a0264d7b-5f10-4001-aebe-f1f663c35464",
"name": "Schedule Trigger"
},
{
"parameters": {
"descriptionType": "manual",
"toolDescription": "You can get all the clients' emails for this ",
"operation": "getAll",
"filters": {
"readStatus": "unread"
}
},
"type": "n8n-nodes-base.gmailTool",
"typeVersion": 2.2,
"position": [
336,
176
],
"id": "f4b74706-c75b-4024-afbd-906bc7b437b1",
"name": "Get All emaill",
"webhookId": "f2bf9207-af6c-4bbc-b26a-06b7b425144b",
"credentials": {
"gmailOAuth2": {
"id": "osZsIZpGUe3XHuR5",
"name": "Gmail account"
}
}
},
{
"parameters": {
"sendTo": "istiyaqkhanr@gmail.com",
"subject": "Update: Actions taken by your AI Assistant",
"message": "={{ $json.output }}",
"options": {
"appendAttribution": false
}
},
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.2,
"position": [
336,
-64
],
"id": "0d69901a-a69c-482c-995b-1d5326f15b5f",
"name": "Send a message",
"webhookId": "0dbd8e68-542c-4407-b283-2537cecd00f3",
"credentials": {
"gmailOAuth2": {
"id": "osZsIZpGUe3XHuR5",
"name": "Gmail account"
}
}
},
{
"parameters": {
"descriptionType": "manual",
"toolDescription": "Call this tool to mark an email as READ after you have processed it. Input required: messageId",
"operation": "markAsRead",
"messageId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message_ID', `The unique ID of the email message to mark as read.`, 'string') }}"
},
"type": "n8n-nodes-base.gmailTool",
"typeVersion": 2.2,
"position": [
432,
208
],
"id": "0e637c61-07be-40d8-9cb3-4740a825cf3a",
"name": "mark_email_read",
"webhookId": "14bf058b-f28b-4cb2-91d5-70c3554f7f12",
"credentials": {
"gmailOAuth2": {
"id": "osZsIZpGUe3XHuR5",
"name": "Gmail account"
}
}
}
],
"connections": {
"AI Agent": {
"main": [
[
{
"node": "Send a message",
"type": "main",
"index": 0
}
]
]
},
"Google Gemini Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"MongoDB Chat Memory": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"create_notion_task": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"schedule_meeting": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"Get All emaill": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"mark_email_read": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
}
},
"pinData": {},
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "5dd9b46813b85ffb73bba701f0d5a1a93ada4dd10494880ad91b81033c95151f"
}
}