{
  "name": "AI Assistant - PUBLIC TEMPLATE",
  "nodes": [
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.body.message }}",
        "options": {
          "systemMessage": "=**Role:**\nYou are a smart, fast, and reliable **personal assistant AI** operating in an **n8n workflow**. Your primary responsibility is to understand the user's intent and route tasks to the correct tool. You help the user manage their time, communication, task management, decision-making, and professional networking with minimal friction.\n\nYou are not just reactive — you proactively interpret vague or underspecified requests, disambiguate unclear inputs, and determine the best course of action. You operate with professional tone and always optimize for usefulness, clarity, and follow-through.\n\n---\n\n## TOOLS AVAILABLE TO YOU\n\nYou have access to the following specialized tools. Choose the right tool based on the user's request:\n\n### 1. Calendar Tool\n* Check availability and suggest optimal meeting times.\n* View, create, update, or delete events.\n* Manage recurring events, reminders, and invite participants.\n* Handle time zones and overlapping events intelligently.\n\n### 2. Email Tool\n* Draft, send, forward, or reply to emails.\n* Search inbox or sent items for relevant conversations.\n* Extract contact details or summarize message threads.\n* Manage common workflows like scheduling from an email, sending follow-ups, or drafting replies in the user's tone.\n\n### 3. To Do Tool\n* Create, view, complete, and prioritize tasks across multiple lists.\n* Manage tasks in Personal, Grocery, Shopping, and Career lists.\n* Track task completion status and set priorities.\n* Help organize daily productivity and project management.\n* Break down complex projects into manageable tasks.\n\n### 4. Internet Research Tool\n* Search the web for current and accurate information.\n* Summarize results clearly and concisely.\n* Provide links to reputable sources when applicable.\n* Compare, evaluate, and synthesize conflicting information.\n* Use this tool only when real-time or external knowledge is required.\n\n### 5. Weather Tool\n* Get current weather conditions for any city or location.\n* Retrieve 5-day weather forecasts for planning purposes.\n* Provide temperature, humidity, wind conditions, and precipitation data.\n* Help with weather-related decision making for travel, events, or daily activities.\n* Offer practical advice based on weather conditions (clothing, activities, etc.).\n\n### 6. Google Sheets Tool\n* **Professional Networking Management**: Track contacts, meetings, follow-ups, and relationship building activities.\n* **Company Research Organization**: Manage target companies, motivations, contacts, job postings, and research notes.\n* **Job Application Tracking**: Monitor application status, contact outreach, resume submissions, and follow-up activities.\n\n**Three Sheet Types:**\n- **Networking Tracker**: Manage professional contacts with fields for name, email, company, referral source, meeting objectives, LinkedIn connections, status updates, meeting notes, thank you messages, and future correspondence.\n- **Company Ideas**: Organize target companies with motivation, primary contacts, job postings, and detailed research notes.\n- **Job Application Tracker**: Track applications with company, application dates, positions, contact assistance, resume submissions, and thank you follow-ups.\n\n**Common Use Cases:**\n- \"Add [person] to networking tracker\"\n- \"Update [contact]'s company to [company name]\"\n- \"Add [company] to company ideas with motivation [reason]\"\n- \"Track job application at [company] for [position]\"\n- \"Show me my networking contacts at [company]\"\n- \"Update meeting notes for [contact]\"\n\n### 7. Think Tool\n* Used for complex reasoning, analysis, or brainstorming.\n* Helps structure plans, prioritize tasks, or analyze tradeoffs.\n* Also used when the request is abstract, ambiguous, or doesn't involve direct tool actions.\n* Output should be thoughtful, structured, and actionable.\n\n---\n\n## BEHAVIOR AND DECISION LOGIC\n\n### 1. Interpret the Request\n* Understand what the user is asking — even if it's ambiguous.\n* Clarify or infer missing details if necessary.\n* Always optimize for intent, not literal words.\n\n### 2. Route to the Right Tool\n* If the user's request involves an action (scheduling, emailing, task management, researching, weather checking, networking/job tracking), pick the correct tool and frame the request accordingly.\n* If multiple tools are needed, orchestrate the flow step-by-step.\n* If no tool fits, use the Think Tool to formulate a helpful, reasoned response.\n\n### 3. Respond Like a Human Assistant\n* Be concise, helpful, and use natural language.\n* Maintain a tone that is friendly, professional, and aligned with high executive standards.\n* Anticipate needs — suggest next steps, ask clarifying questions, or notify the user of potential conflicts.\n\n### 4. Always Verify Before Acting\n* Don't send or commit to anything (like calendar invites or emails) unless the request is clear.\n* When details are unclear, ask targeted follow-up questions or suggest a safe default action.\n\n---\n\n## EXAMPLES OF TASK ROUTING\n\n| Request | Tool | Notes |\n|---------|------|-------|\n| \"Set up a meeting with Alex next week\" | Calendar Tool | Parse names, propose time, check availability |\n| \"Send a polite follow-up to that email from Monday\" | Email Tool | Find correct thread, draft in user's tone |\n| \"Add buy milk to my grocery list\" | To Do Tool | Create task in appropriate list |\n| \"Show me my personal tasks for today\" | To Do Tool | View tasks from specific list |\n| \"Mark oil change as completed\" | To Do Tool | Complete task, identify correct list |\n| \"What's the latest update on SAG-AFTRA negotiations?\" | Internet Research Tool | Use reputable sources, summarize with context |\n| \"What's the weather like in Miami this weekend?\" | Weather Tool | Get forecast, provide practical advice |\n| \"Should I reschedule my outdoor event tomorrow?\" | Weather Tool | Check forecast, advise based on conditions |\n| \"Add John Smith from Tesla to my networking contacts\" | Google Sheets Tool | Use Networking Tracker to add new contact |\n| \"Update Sarah's company to Microsoft\" | Google Sheets Tool | Update existing contact in Networking Tracker |\n| \"Add Google to my company research list\" | Google Sheets Tool | Add to Company Ideas sheet |\n| \"Track my application to Apple for Product Manager role\" | Google Sheets Tool | Use Job Application Tracker |\n| \"Show me all my contacts at consulting firms\" | Google Sheets Tool | Read and filter Networking Tracker |\n| \"Add meeting notes for my lunch with David\" | Google Sheets Tool | Update Networking Tracker with meeting details |\n| \"Help me prioritize my to-do list for tomorrow\" | Think Tool | Use reasoning and prioritization framework |\n\n---\n\n## GENERAL RULES\n\n* Do not hallucinate capabilities. If you cannot do something, clearly state the limitation.\n* Never make something up. If you don't know, say so.\n* Never take irreversible actions (e.g. deleting calendar events or sending final emails) unless explicitly instructed.\n* Flag potential conflicts (e.g. overlapping meetings) or inconsistencies.\n* Always confirm assumptions if they materially affect the output.\n* If the response contains times, make sure they are always referenced in the user's current timezone.\n* If the user asks for available times, return the times for the date or time slot requested that do NOT have an event booked already.\n* For weather-related requests, provide practical advice and suggestions based on the conditions.\n* For task management requests, identify the appropriate list (Personal, Grocery, Shopping, Career) and use the To Do Tool accordingly.\n* For professional networking, job search, or company research requests, use the Google Sheets Tool to maintain organized records and track relationship building activities.\n* When working with Google Sheets, always preserve existing data when updating records and suggest logical next steps for relationship management.\n\nToday's date and time is {{ $now }}"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2,
      "position": [
        272,
        48
      ],
      "id": "f8065f66-f8ef-4d48-b90a-e68471d587ba",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "description": "Call this tool for all email related tasks.",
        "workflowId": {
          "__rl": true,
          "value": "REPLACE_WITH_EMAIL_AGENT_WORKFLOW_ID",
          "mode": "id",
          "cachedResultName": "Email Agent"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2.2,
      "position": [
        528,
        272
      ],
      "id": "b9e4aa2b-6c10-4aa5-bddc-8d23f04d496e",
      "name": "Email Tool"
    },
    {
      "parameters": {
        "description": "Call this tool to execute calendar related tasks",
        "workflowId": {
          "__rl": true,
          "value": "REPLACE_WITH_CALENDAR_AGENT_WORKFLOW_ID",
          "mode": "id",
          "cachedResultName": "Calendar Agent"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2.2,
      "position": [
        640,
        272
      ],
      "id": "f03db95d-0a3f-4128-a762-03bfbac57b61",
      "name": "Calendar Tool"
    },
    {
      "parameters": {
        "toolDescription": "Call this tool to conduct internet research",
        "method": "POST",
        "url": "https://api.tavily.com/search",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "query",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', ``, 'string') }}"
            },
            {
              "name": "search_depth",
              "value": "advanced"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequestTool",
      "typeVersion": 4.2,
      "position": [
        784,
        272
      ],
      "id": "12ac952c-2b00-4bd3-83d7-718ce2c26533",
      "name": "Internet Research Tool"
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.toolThink",
      "typeVersion": 1,
      "position": [
        1344,
        272
      ],
      "id": "d720a1ce-c85c-4d67-ac53-fbfa000e9a8a",
      "name": "Think"
    },
    {
      "parameters": {
        "respondWith": "text",
        "responseBody": "={{ { response: $json.output ?? null, status: 'success' } }}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.3,
      "position": [
        624,
        48
      ],
      "id": "2cafed1f-8bd6-4065-8cbd-c778d907205e",
      "name": "Respond to Webhook"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "{{ $json.sessionID }}"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        368,
        272
      ],
      "id": "bb671c54-83e3-445c-b03e-e98139121518",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "jsCode": "// Get the incoming data\nconst incomingData = $input.all()[0].json;\n\n// Check if we have a unique identifier from GPT\nlet sessionID = incomingData.sessionID;\n\n// If sessionID is \"default\" or empty, generate a unique one\nif (!sessionID || sessionID === \"default\") {\n  // Try to use user_id if available\n  if (incomingData.user_id && incomingData.user_id !== \"anonymous\") {\n    sessionID = `user_${incomingData.user_id}_${Date.now()}`;\n  } else {\n    // Generate a unique session ID based on timestamp and random string\n    const timestamp = Date.now();\n    const randomString = Math.random().toString(36).substring(2, 15);\n    sessionID = `session_${timestamp}_${randomString}`;\n  }\n}\n\n// Store the session ID for the duration of this conversation\n// You might want to implement session persistence here\nglobal.currentSessionID = sessionID;\n\nreturn [{\n  json: {\n    ...incomingData,\n    sessionID: sessionID,\n    originalSessionID: incomingData.sessionID\n  }\n}];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        64,
        48
      ],
      "id": "8ba0c8d6-9af2-4bec-8bb5-fcc853535249",
      "name": "Create sessionID"
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "evey-assistant",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -128,
        48
      ],
      "id": "c9c22ced-40e3-48bb-a6f3-d5a38cd8123f",
      "name": "ChatGPT Webhook"
    },
    {
      "parameters": {
        "description": "Call this tool for weather related requests",
        "workflowId": {
          "__rl": true,
          "value": "REPLACE_WITH_WEATHER_AGENT_WORKFLOW_ID",
          "mode": "id",
          "cachedResultName": "Weather Agent"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2.2,
      "position": [
        928,
        272
      ],
      "id": "b70ad811-fee8-4b6f-abeb-a381a9d4c43d",
      "name": "Weather Tool"
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "REPLACE_WITH_TO_DO_AGENT_WORKFLOW_ID",
          "mode": "id",
          "cachedResultName": "To Do Agent"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2.2,
      "position": [
        1072,
        272
      ],
      "id": "d6f3e5bd-310c-403c-a6a1-2f6d9cd74ab6",
      "name": "To Do Tool"
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "REPLACE_WITH_GOOGLE_SHEETS_AGENT_WORKFLOW_ID",
          "mode": "id",
          "cachedResultName": "Google Sheets Agent"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2.2,
      "position": [
        1200,
        272
      ],
      "id": "76ce1f85-5480-4a7e-b17f-28942b51cf86",
      "name": "Google Sheets Tool"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.errorTrigger",
      "typeVersion": 1,
      "position": [
        624,
        -112
      ],
      "id": "ae74ce58-8ce3-4a8d-9ca8-4f3091717525",
      "name": "Error Trigger"
    },
    {
      "parameters": {
        "jsCode": "// Get the error data\nconst errorData = items[0].json;\n\n// Build a formatted error message with HTML for proper formatting\nconst errorMessage = errorData.execution?.error?.message || errorData.error?.message || 'Unknown error';\nconst errorType = errorData.execution?.error?.name || errorData.error?.name || 'N/A';\nconst lastNode = errorData.execution?.lastNodeExecuted || errorData.node?.name || 'Unknown';\nconst nodeType = errorData.node?.type || 'N/A';\nconst stackTrace = errorData.execution?.error?.stack || errorData.error?.stack;\n\n// Create HTML email body\nlet emailBody = `<html><body style=\"font-family: Arial, sans-serif; line-height: 1.6; color: #333;\">`;\n\nemailBody += `<h2 style=\"color: #d32f2f;\">🚨 AI Agent Error Report</h2>`;\nemailBody += `<hr style=\"border: 1px solid #ddd;\">`;\n\nemailBody += `<h3 style=\"color: #f57c00;\">⚠️ ERROR DETAILS</h3>`;\nemailBody += `<ul style=\"background-color: #fff3e0; padding: 15px; border-left: 4px solid #f57c00;\">`;\nemailBody += `<li><strong>Message:</strong> ${errorMessage}</li>`;\nemailBody += `<li><strong>Type:</strong> ${errorType}</li>`;\nemailBody += `</ul>`;\n\nemailBody += `<h3 style=\"color: #1976d2;\">🔧 FAILED NODE</h3>`;\nemailBody += `<ul style=\"background-color: #e3f2fd; padding: 15px; border-left: 4px solid #1976d2;\">`;\nemailBody += `<li><strong>Name:</strong> ${lastNode}</li>`;\nif (nodeType !== 'N/A') {\n  emailBody += `<li><strong>Type:</strong> ${nodeType}</li>`;\n}\nemailBody += `</ul>`;\n\nif (errorData.execution) {\n  emailBody += `<h3 style=\"color: #388e3c;\">📊 EXECUTION INFO</h3>`;\n  emailBody += `<ul style=\"background-color: #e8f5e9; padding: 15px; border-left: 4px solid #388e3c;\">`;\n  emailBody += `<li><strong>Execution ID:</strong> ${errorData.execution.id}</li>`;\n  emailBody += `<li><strong>Mode:</strong> ${errorData.execution.mode}</li>`;\n  if (errorData.execution.url) {\n    emailBody += `<li><strong>View in n8n:</strong> <a href=\"${errorData.execution.url}\">${errorData.execution.url}</a></li>`;\n  }\n  emailBody += `</ul>`;\n}\n\nif (errorData.workflow) {\n  emailBody += `<h3 style=\"color: #7b1fa2;\">📋 WORKFLOW</h3>`;\n  emailBody += `<ul style=\"background-color: #f3e5f5; padding: 15px; border-left: 4px solid #7b1fa2;\">`;\n  emailBody += `<li><strong>Name:</strong> ${errorData.workflow.name}</li>`;\n  emailBody += `<li><strong>ID:</strong> ${errorData.workflow.id}</li>`;\n  emailBody += `</ul>`;\n}\n\nemailBody += `<h3 style=\"color: #455a64;\">🕐 TIMESTAMP</h3>`;\nemailBody += `<p style=\"background-color: #eceff1; padding: 15px; border-left: 4px solid #455a64;\">`;\nemailBody += `${new Date().toISOString()}`;\nemailBody += `</p>`;\n\nif (stackTrace && stackTrace !== 'Stacktrace') {\n  emailBody += `<h3 style=\"color: #d32f2f;\">📚 STACK TRACE</h3>`;\n  emailBody += `<pre style=\"background-color: #ffebee; padding: 15px; border-left: 4px solid #d32f2f; overflow-x: auto; font-size: 12px;\">${stackTrace}</pre>`;\n}\n\nemailBody += `<hr style=\"border: 1px solid #ddd; margin: 30px 0;\">`;\nemailBody += `<h3 style=\"color: #616161;\">FULL ERROR OBJECT (for debugging)</h3>`;\nemailBody += `<pre style=\"background-color: #f5f5f5; padding: 15px; border: 1px solid #ddd; overflow-x: auto; font-size: 11px;\">${JSON.stringify(errorData, null, 2)}</pre>`;\n\nemailBody += `</body></html>`;\n\nreturn [{\n  json: {\n    subject: `🚨 AI Agent Error: ${errorMessage}`,\n    body: emailBody\n  }\n}];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        832,
        -112
      ],
      "id": "efe85afd-d6bd-40f3-98e2-fa69bf99e7d8",
      "name": "Code in JavaScript"
    },
    {
      "parameters": {
        "sendTo": "user@example.com",
        "subject": "={{ $json.subject }}",
        "message": "={{ $json.body }}",
        "options": {}
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1040,
        -112
      ],
      "id": "598bd7c5-20a0-4804-9dad-75473c13ec02",
      "name": "Send a message"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-5.4",
          "mode": "list",
          "cachedResultName": "gpt-5.4"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        160,
        272
      ],
      "id": "123bcde6-75fa-47f4-9eba-1bef158f8812",
      "name": "GPT 5.4"
    }
  ],
  "connections": {
    "Email Tool": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Calendar Tool": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Internet Research Tool": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Think": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Create sessionID": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ChatGPT Webhook": {
      "main": [
        [
          {
            "node": "Create sessionID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Weather Tool": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "To Do Tool": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets Tool": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Error Trigger": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPT 5.4": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "tags": []
}
